Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mock-apollo-client

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mock-apollo-client - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

9

dist/index.js
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -10,7 +14,8 @@ if (k2 === undefined) k2 = k;

var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createMockSubscription = void 0;
__exportStar(require("./mockClient"), exports);
var mockSubscription_1 = require("./mockSubscription");
Object.defineProperty(exports, "createMockSubscription", { enumerable: true, get: function () { return mockSubscription_1.createMockSubscription; } });

@@ -18,5 +18,4 @@ "use strict";

var mockLink_1 = require("./mockLink");
exports.createMockClient = function (options) {
var _a;
if ((_a = options) === null || _a === void 0 ? void 0 : _a.link) {
var createMockClient = function (options) {
if (options === null || options === void 0 ? void 0 : options.link) {
throw new Error('Providing link to use is not supported.');

@@ -33,1 +32,2 @@ }

};
exports.createMockClient = createMockClient;

@@ -1,2 +0,1 @@

/// <reference types="zen-observable" />
import { ApolloLink, DocumentNode, Observable, Operation, FetchResult } from '@apollo/client/core';

@@ -7,5 +6,3 @@ import { RequestHandler } from './mockClient';

setRequestHandler(requestQuery: DocumentNode, handler: RequestHandler): void;
request: (operation: Operation) => Observable<FetchResult<{
[key: string]: any;
}, Record<string, any>, Record<string, any>>>;
request: (operation: Operation) => Observable<FetchResult<Record<string, any>, Record<string, any>, Record<string, any>>>;
}

@@ -6,6 +6,8 @@ "use strict";

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);

@@ -31,3 +33,3 @@ function __() { this.constructor = d; }

if (!handler) {
throw new Error("Request handler not defined for query: " + graphql_1.print(operation.query));
throw new Error("Request handler not defined for query: ".concat((0, graphql_1.print)(operation.query)));
}

@@ -40,3 +42,4 @@ return new core_1.Observable(function (observer) {

catch (error) {
throw new Error("Unexpected error whilst calling request handler: " + error.message);
var message = error instanceof Error ? error.message : error;
throw new Error("Unexpected error whilst calling request handler: ".concat(message));
}

@@ -57,3 +60,3 @@ if (isPromise(result)) {

else {
throw new Error("Request handler must return a promise or subscription. Received '" + typeof result + "'.");
throw new Error("Request handler must return a promise or subscription. Received '".concat(typeof result, "'."));
}

@@ -66,3 +69,3 @@ return function () { };

MockLink.prototype.setRequestHandler = function (requestQuery, handler) {
var queryWithoutClientDirectives = utilities_1.removeClientSetsFromDocument(requestQuery);
var queryWithoutClientDirectives = (0, utilities_1.removeClientSetsFromDocument)(requestQuery);
if (queryWithoutClientDirectives === null) {

@@ -74,3 +77,3 @@ console.warn('Warning: mock-apollo-client - The query is entirely client side (using @client directives) so the request handler will not be registered.');

if (this.requestHandlers[key]) {
throw new Error("Request handler already defined for query: " + graphql_1.print(requestQuery));
throw new Error("Request handler already defined for query: ".concat((0, graphql_1.print)(requestQuery)));
}

@@ -83,3 +86,3 @@ this.requestHandlers[key] = handler;

var normalise = function (requestQuery) {
var stripped = utilities_1.removeConnectionDirectiveFromDocument(requestQuery);
var stripped = (0, utilities_1.removeConnectionDirectiveFromDocument)(requestQuery);
stripped = stripped !== null

@@ -93,3 +96,3 @@ ? stripTypenames(stripped)

var stripTypenames = function (document) {
return graphql_1.visit(document, {
return (0, graphql_1.visit)(document, {
Field: {

@@ -104,3 +107,3 @@ enter: function (node) { return node.name.value === '__typename'

var normalised = normalise(query);
var queryString = query && graphql_1.print(normalised);
var queryString = query && (0, graphql_1.print)(normalised);
var requestKey = { query: queryString };

@@ -107,0 +110,0 @@ return JSON.stringify(requestKey);

@@ -1,2 +0,1 @@

/// <reference types="zen-observable" />
import { FetchResult } from '@apollo/client/core';

@@ -13,2 +12,8 @@ import type { RequestHandlerResponse } from './mockClient';

};
export interface SubscriptionObserver<T> {
closed: boolean;
next(value: T): void;
error(errorValue: any): void;
complete(): void;
}
export declare class MockSubscription<TData = any> implements IMockSubscription<TData> {

@@ -18,3 +23,3 @@ private observer?;

constructor(options?: MockSubscriptionOptions);
subscribe(observer: ZenObservable.SubscriptionObserver<FetchResult>): void;
subscribe(observer: SubscriptionObserver<FetchResult>): void;
get closed(): boolean;

@@ -26,2 +31,2 @@ next(value: RequestHandlerResponse<TData>): void;

}
export declare const createMockSubscription: <TData = any>(options?: MockSubscriptionOptions | undefined) => IMockSubscription<TData>;
export declare const createMockSubscription: <TData = any>(options?: MockSubscriptionOptions) => IMockSubscription<TData>;

@@ -53,4 +53,5 @@ "use strict";

exports.MockSubscription = MockSubscription;
exports.createMockSubscription = function (options) {
var createMockSubscription = function (options) {
return new MockSubscription(options);
};
exports.createMockSubscription = createMockSubscription;
{
"name": "mock-apollo-client",
"version": "1.2.0",
"version": "1.2.1",
"description": "Library to help unit testing when using apollo-client",

@@ -11,2 +11,3 @@ "main": "dist/index.js",

"test:watch": "jest --watch",
"test:suite": "./runTestSuite.sh",
"deploy": "npm run test && npm run build && npm publish"

@@ -31,11 +32,10 @@ },

"homepage": "https://github.com/mike-gibson/mock-apollo-client#readme",
"dependencies": {},
"devDependencies": {
"@apollo/client": "^3.1.3",
"@types/jest": "^26.0.10",
"@types/node": "^14.6.0",
"@apollo/client": "^3.6.9",
"@types/jest": "^28.1.6",
"@types/node": "^16.11.46",
"graphql": "^15.3.0",
"jest": "^26.4.1",
"ts-jest": "^26.2.0",
"typescript": "^3.9.7"
"jest": "^28.1.3",
"ts-jest": "^28.0.7",
"typescript": "^4.7.4"
},

@@ -42,0 +42,0 @@ "peerDependencies": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc