New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@apollo/client

Package Overview
Dependencies
Maintainers
1
Versions
598
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@apollo/client - npm Package Compare versions

Comparing version 3.0.0-rc.12 to 3.0.0-rc.13

link/batch-http/batch-http.cjs.js

6

cache/inmemory/policies.js

@@ -130,3 +130,3 @@ import { __assign } from 'tslib';

if (typename !== old) {
process.env.NODE_ENV === "production" ? invariant(!old || old === which, 34) : invariant(!old || old === which, "Cannot change root " + which + " __typename more than once");
process.env.NODE_ENV === "production" ? invariant(!old || old === which, 31) : invariant(!old || old === which, "Cannot change root " + which + " __typename more than once");
this.rootIdsByTypename[typename] = rootId;

@@ -321,3 +321,3 @@ this.rootTypenamesById[rootId] = typename;

if (Array.isArray(existing) || Array.isArray(incoming)) {
throw process.env.NODE_ENV === "production" ? new InvariantError(35) : new InvariantError("Cannot automatically merge arrays");
throw process.env.NODE_ENV === "production" ? new InvariantError(32) : new InvariantError("Cannot automatically merge arrays");
}

@@ -406,3 +406,3 @@ if (existing && typeof existing === "object" &&

var responseName = aliases && aliases[s] || s;
process.env.NODE_ENV === "production" ? invariant(hasOwn.call(response, responseName), 36) : invariant(hasOwn.call(response, responseName), "Missing field '" + responseName + "' while computing key fields");
process.env.NODE_ENV === "production" ? invariant(hasOwn.call(response, responseName), 33) : invariant(hasOwn.call(response, responseName), "Missing field '" + responseName + "' while computing key fields");
keyObj[prevKey = s] = response[responseName];

@@ -409,0 +409,0 @@ }

@@ -9,21 +9,5 @@ export { ApolloClient, ApolloClientOptions, DefaultOptions } from '../ApolloClient';

export * from '../cache';
export { empty } from '../link/core/empty';
export { from } from '../link/core/from';
export { split } from '../link/core/split';
export { concat } from '../link/core/concat';
export { execute } from '../link/core/execute';
export { ApolloLink } from '../link/core/ApolloLink';
export * from '../link/core/types';
export { parseAndCheckHttpResponse, ServerParseError } from '../link/http/parseAndCheckHttpResponse';
export { serializeFetchParameter, ClientParseError } from '../link/http/serializeFetchParameter';
export { HttpOptions, fallbackHttpConfig, selectHttpOptionsAndBody, UriFunction } from '../link/http/selectHttpOptionsAndBody';
export { checkFetcher } from '../link/http/checkFetcher';
export { createSignalIfSupported } from '../link/http/createSignalIfSupported';
export { selectURI } from '../link/http/selectURI';
export { createHttpLink } from '../link/http/createHttpLink';
export { HttpLink } from '../link/http/HttpLink';
export { fromError } from '../link/utils/fromError';
export { toPromise } from '../link/utils/toPromise';
export { fromPromise } from '../link/utils/fromPromise';
export { ServerError, throwServerError } from '../link/utils/throwServerError';
export * from '../link/core';
export * from '../link/http';
export * from '../link/utils';
export { Observable, Observer, ObservableSubscription } from '../utilities/observables/Observable';

@@ -30,0 +14,0 @@ import gql from 'graphql-tag';

@@ -183,3 +183,3 @@ import { __awaiter, __generator, __assign } from 'tslib';

fragment = fragmentMap[selection.name.value];
process.env.NODE_ENV === "production" ? invariant(fragment, 14) : invariant(fragment, "No fragment named " + selection.name.value);
process.env.NODE_ENV === "production" ? invariant(fragment, 11) : invariant(fragment, "No fragment named " + selection.name.value);
}

@@ -186,0 +186,0 @@ if (fragment && fragment.typeCondition) {

@@ -170,2 +170,10 @@ import { __extends, __assign } from 'tslib';

var qid = this.queryManager.generateQueryId();
if (combinedOptions.notifyOnNetworkStatusChange) {
var currentResult = this.getCurrentResult();
var queryInfo = this.queryManager.getQueryStoreValue(this.queryId);
if (queryInfo) {
queryInfo.networkStatus = NetworkStatus.fetchMore;
}
this.observer.next(__assign(__assign({}, currentResult), { loading: true, networkStatus: NetworkStatus.fetchMore }));
}
return this.queryManager.fetchQuery(qid, combinedOptions, NetworkStatus.fetchMore).then(function (fetchMoreResult) {

@@ -204,2 +212,3 @@ var data = fetchMoreResult.data;

variables: options.variables,
context: options.context,
})

@@ -206,0 +215,0 @@ .subscribe({

@@ -68,3 +68,3 @@ /// <reference types="zen-observable" />

setObservableQuery(observableQuery: ObservableQuery<any, any>): void;
startGraphQLSubscription<T = any>({ query, fetchPolicy, variables, }: SubscriptionOptions): Observable<FetchResult<T>>;
startGraphQLSubscription<T = any>({ query, fetchPolicy, variables, context, }: SubscriptionOptions): Observable<FetchResult<T>>;
stopQuery(queryId: string): void;

@@ -71,0 +71,0 @@ private stopQueryNoBroadcast;

@@ -49,3 +49,3 @@ import { __awaiter, __generator, __assign } from 'tslib';

});
this.cancelPendingFetches(process.env.NODE_ENV === "production" ? new InvariantError(15) : new InvariantError('QueryManager stopped while query was in flight'));
this.cancelPendingFetches(process.env.NODE_ENV === "production" ? new InvariantError(12) : new InvariantError('QueryManager stopped while query was in flight'));
};

@@ -64,4 +64,4 @@ QueryManager.prototype.cancelPendingFetches = function (error) {

case 0:
process.env.NODE_ENV === "production" ? invariant(mutation, 16) : invariant(mutation, 'mutation option is required. You must specify your GraphQL document in the mutation option.');
process.env.NODE_ENV === "production" ? invariant(!fetchPolicy || fetchPolicy === 'no-cache', 17) : invariant(!fetchPolicy || fetchPolicy === 'no-cache', "Mutations only support a 'no-cache' fetchPolicy. If you don't want to disable the cache, remove your fetchPolicy setting to proceed with the default mutation behavior.");
process.env.NODE_ENV === "production" ? invariant(mutation, 13) : invariant(mutation, 'mutation option is required. You must specify your GraphQL document in the mutation option.');
process.env.NODE_ENV === "production" ? invariant(!fetchPolicy || fetchPolicy === 'no-cache', 14) : invariant(!fetchPolicy || fetchPolicy === 'no-cache', "Mutations only support a 'no-cache' fetchPolicy. If you don't want to disable the cache, remove your fetchPolicy setting to proceed with the default mutation behavior.");
mutationId = this.generateMutationId();

@@ -281,7 +281,7 @@ mutation = this.transform(mutation).document;

var _this = this;
process.env.NODE_ENV === "production" ? invariant(options.query, 18) : invariant(options.query, 'query option is required. You must specify your GraphQL document ' +
process.env.NODE_ENV === "production" ? invariant(options.query, 15) : invariant(options.query, 'query option is required. You must specify your GraphQL document ' +
'in the query option.');
process.env.NODE_ENV === "production" ? invariant(options.query.kind === 'Document', 19) : invariant(options.query.kind === 'Document', 'You must wrap the query string in a "gql" tag.');
process.env.NODE_ENV === "production" ? invariant(!options.returnPartialData, 20) : invariant(!options.returnPartialData, 'returnPartialData option only supported on watchQuery.');
process.env.NODE_ENV === "production" ? invariant(!options.pollInterval, 21) : invariant(!options.pollInterval, 'pollInterval option only supported on watchQuery.');
process.env.NODE_ENV === "production" ? invariant(options.query.kind === 'Document', 16) : invariant(options.query.kind === 'Document', 'You must wrap the query string in a "gql" tag.');
process.env.NODE_ENV === "production" ? invariant(!options.returnPartialData, 17) : invariant(!options.returnPartialData, 'returnPartialData option only supported on watchQuery.');
process.env.NODE_ENV === "production" ? invariant(!options.pollInterval, 18) : invariant(!options.pollInterval, 'pollInterval option only supported on watchQuery.');
var queryId = this.generateQueryId();

@@ -312,3 +312,3 @@ return this.fetchQuery(queryId, options).finally(function () { return _this.stopQuery(queryId); });

QueryManager.prototype.clearStore = function () {
this.cancelPendingFetches(process.env.NODE_ENV === "production" ? new InvariantError(22) : new InvariantError('Store reset while query was in flight (not completed in link chain)'));
this.cancelPendingFetches(process.env.NODE_ENV === "production" ? new InvariantError(19) : new InvariantError('Store reset while query was in flight (not completed in link chain)'));
this.queries.forEach(function (queryInfo) {

@@ -355,7 +355,7 @@ if (queryInfo.observableQuery) {

var _this = this;
var query = _a.query, fetchPolicy = _a.fetchPolicy, variables = _a.variables;
var query = _a.query, fetchPolicy = _a.fetchPolicy, variables = _a.variables, _b = _a.context, context = _b === void 0 ? {} : _b;
query = this.transform(query).document;
variables = this.getVariables(query, variables);
var makeObservable = function (variables) {
return _this.getObservableFromLink(query, {}, variables, false).map(function (result) {
return _this.getObservableFromLink(query, context, variables, false).map(function (result) {
if (!fetchPolicy || fetchPolicy !== 'no-cache') {

@@ -381,3 +381,3 @@ if (!graphQLResultHasError(result)) {

if (this.transform(query).hasClientExports) {
var observablePromise_1 = this.localState.addExportedVariables(query, variables).then(makeObservable);
var observablePromise_1 = this.localState.addExportedVariables(query, variables, context).then(makeObservable);
return new Observable(function (observer) {

@@ -384,0 +384,0 @@ var sub = null;

@@ -61,3 +61,3 @@ import { invariant } from 'ts-invariant';

}
process.env.NODE_ENV === "production" ? invariant(pollInterval, 23) : invariant(pollInterval, 'Attempted to start a polling query without a polling interval.');
process.env.NODE_ENV === "production" ? invariant(pollInterval, 21) : invariant(pollInterval, 'Attempted to start a polling query without a polling interval.');
if (this.shouldFetch === false) {

@@ -64,0 +64,0 @@ return;

@@ -43,2 +43,3 @@ import { DocumentNode } from 'graphql';

onError?: (error: Error) => void;
context?: Record<string, any>;
};

@@ -49,2 +50,3 @@ export interface SubscriptionOptions<TVariables = OperationVariables> {

fetchPolicy?: FetchPolicy;
context?: Record<string, any>;
}

@@ -51,0 +53,0 @@ export declare type RefetchQueryDescription = Array<string | PureQueryOptions>;

@@ -88,3 +88,3 @@ import { __extends } from 'tslib';

ApolloLink.prototype.request = function (operation, forward) {
throw process.env.NODE_ENV === "production" ? new InvariantError(11) : new InvariantError('request is not implemented');
throw process.env.NODE_ENV === "production" ? new InvariantError(20) : new InvariantError('request is not implemented');
};

@@ -91,0 +91,0 @@ ApolloLink.prototype.onError = function (reason) {

@@ -5,3 +5,3 @@ import { InvariantError } from 'ts-invariant';

if (!fetcher && typeof fetch === 'undefined') {
throw process.env.NODE_ENV === "production" ? new InvariantError(13) : new InvariantError("\n\"fetch\" has not been found globally and no fetcher has been configured. To fix this, install a fetch package (like https://www.npmjs.com/package/cross-fetch), instantiate the fetcher, and pass it into your HttpLink constructor. For example:\n\nimport fetch from 'cross-fetch';\nimport { ApolloClient, HttpLink } from '@apollo/client';\nconst client = new ApolloClient({\n link: new HttpLink({ uri: '/graphql', fetch })\n});\n ");
throw process.env.NODE_ENV === "production" ? new InvariantError(35) : new InvariantError("\n\"fetch\" has not been found globally and no fetcher has been configured. To fix this, install a fetch package (like https://www.npmjs.com/package/cross-fetch), instantiate the fetcher, and pass it into your HttpLink constructor. For example:\n\nimport fetch from 'cross-fetch';\nimport { ApolloClient, HttpLink } from '@apollo/client';\nconst client = new ApolloClient({\n link: new HttpLink({ uri: '/graphql', fetch })\n});\n ");
}

@@ -8,0 +8,0 @@ };

@@ -9,3 +9,3 @@ import { InvariantError } from 'ts-invariant';

catch (e) {
var parseError = process.env.NODE_ENV === "production" ? new InvariantError(12) : new InvariantError("Network request failed. " + label + " is not serializable: " + e.message);
var parseError = process.env.NODE_ENV === "production" ? new InvariantError(34) : new InvariantError("Network request failed. " + label + " is not serializable: " + e.message);
parseError.parseError = e;

@@ -12,0 +12,0 @@ throw parseError;

@@ -14,3 +14,3 @@ import { InvariantError } from 'ts-invariant';

if (OPERATION_FIELDS.indexOf(key) < 0) {
throw process.env.NODE_ENV === "production" ? new InvariantError(32) : new InvariantError("illegal argument: " + key);
throw process.env.NODE_ENV === "production" ? new InvariantError(43) : new InvariantError("illegal argument: " + key);
}

@@ -17,0 +17,0 @@ }

{
"name": "@apollo/client",
"version": "3.0.0-rc.12",
"version": "3.0.0-rc.13",
"description": "A fully-featured caching GraphQL client.",

@@ -35,3 +35,4 @@ "private": false,

"graphql": "^14.0.0 || ^15.0.0",
"react": "^16.8.0"
"react": "^16.8.0",
"subscriptions-transport-ws": "^0.9.0"
},

@@ -72,2 +73,3 @@ "peerDependenciesMeta": {

"graphql": "15.3.0",
"graphql-tools": "^6.0.12",
"jest": "26.1.0",

@@ -86,5 +88,7 @@ "jest-junit": "11.0.1",

"rxjs": "6.6.0",
"subscriptions-transport-ws": "^0.9.17",
"ts-jest": "26.1.1",
"tsc-watch": "3.0.1",
"typescript": "3.9.6"
"typescript": "3.9.6",
"wait-for-observables": "^1.0.3"
},

@@ -91,0 +95,0 @@ "publishConfig": {

@@ -409,5 +409,2 @@ 'use strict';

}
if (_this.previousOptions.skip) {
return;
}
onNewData();

@@ -414,0 +411,0 @@ },

@@ -13,3 +13,3 @@ import { invariant } from 'ts-invariant';

}
process.env.NODE_ENV === "production" ? invariant(context.client, 4) : invariant(context.client, 'ApolloProvider was not passed a client instance. Make ' +
process.env.NODE_ENV === "production" ? invariant(context.client, 6) : invariant(context.client, 'ApolloProvider was not passed a client instance. Make ' +
'sure you pass in your client via the "client" prop.');

@@ -16,0 +16,0 @@ return (React.createElement(ApolloContext.Provider, { value: context }, children));

@@ -218,5 +218,2 @@ import { __extends, __assign } from 'tslib';

}
if (_this.previousOptions.skip) {
return;
}
onNewData();

@@ -223,0 +220,0 @@ },

@@ -410,5 +410,2 @@ 'use strict';

}
if (_this.previousOptions.skip) {
return;
}
onNewData();

@@ -415,0 +412,0 @@ },

@@ -7,3 +7,3 @@ import { invariant } from 'ts-invariant';

var client = React.useContext(getApolloContext()).client;
process.env.NODE_ENV === "production" ? invariant(client, 6) : invariant(client, 'No Apollo Client instance can be found. Please ensure that you ' +
process.env.NODE_ENV === "production" ? invariant(client, 4) : invariant(client, 'No Apollo Client instance can be found. Please ensure that you ' +
'have called `ApolloProvider` higher up in your tree.');

@@ -10,0 +10,0 @@ return client;

@@ -14,3 +14,3 @@ import { invariant } from 'ts-invariant';

evaledValue = variables && variables[ifArgument.value.name.value];
process.env.NODE_ENV === "production" ? invariant(evaledValue !== void 0, 40) : invariant(evaledValue !== void 0, "Invalid variable referenced in @" + directive.name.value + " directive.");
process.env.NODE_ENV === "production" ? invariant(evaledValue !== void 0, 36) : invariant(evaledValue !== void 0, "Invalid variable referenced in @" + directive.name.value + " directive.");
}

@@ -52,8 +52,8 @@ else {

var directiveName = directive.name.value;
process.env.NODE_ENV === "production" ? invariant(directiveArguments && directiveArguments.length === 1, 41) : invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @" + directiveName + " directive.");
process.env.NODE_ENV === "production" ? invariant(directiveArguments && directiveArguments.length === 1, 37) : invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @" + directiveName + " directive.");
var ifArgument = directiveArguments[0];
process.env.NODE_ENV === "production" ? invariant(ifArgument.name && ifArgument.name.value === 'if', 42) : invariant(ifArgument.name && ifArgument.name.value === 'if', "Invalid argument for the @" + directiveName + " directive.");
process.env.NODE_ENV === "production" ? invariant(ifArgument.name && ifArgument.name.value === 'if', 38) : invariant(ifArgument.name && ifArgument.name.value === 'if', "Invalid argument for the @" + directiveName + " directive.");
var ifValue = ifArgument.value;
process.env.NODE_ENV === "production" ? invariant(ifValue &&
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 43) : invariant(ifValue &&
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 39) : invariant(ifValue &&
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), "Argument for the @" + directiveName + " directive must be a variable or a boolean value.");

@@ -60,0 +60,0 @@ result.push({ directive: directive, ifArgument: ifArgument });

@@ -9,3 +9,3 @@ import { __assign, __spreadArrays } from 'tslib';

if (definition.kind === 'OperationDefinition') {
throw process.env.NODE_ENV === "production" ? new InvariantError(37) : new InvariantError("Found a " + definition.operation + " operation" + (definition.name ? " named '" + definition.name.value + "'" : '') + ". " +
throw process.env.NODE_ENV === "production" ? new InvariantError(40) : new InvariantError("Found a " + definition.operation + " operation" + (definition.name ? " named '" + definition.name.value + "'" : '') + ". " +
'No operations are allowed when using a fragment as a query. Only fragments are allowed.');

@@ -18,3 +18,3 @@ }

if (typeof actualFragmentName === 'undefined') {
process.env.NODE_ENV === "production" ? invariant(fragments.length === 1, 38) : invariant(fragments.length === 1, "Found " + fragments.length + " fragments. `fragmentName` must be provided when there is not exactly 1 fragment.");
process.env.NODE_ENV === "production" ? invariant(fragments.length === 1, 41) : invariant(fragments.length === 1, "Found " + fragments.length + " fragments. `fragmentName` must be provided when there is not exactly 1 fragment.");
actualFragmentName = fragments[0].name.value;

@@ -56,3 +56,3 @@ }

var fragment = fragmentMap && fragmentMap[selection.name.value];
process.env.NODE_ENV === "production" ? invariant(fragment, 39) : invariant(fragment, "No fragment named " + selection.name.value + ".");
process.env.NODE_ENV === "production" ? invariant(fragment, 42) : invariant(fragment, "No fragment named " + selection.name.value + ".");
return fragment;

@@ -59,0 +59,0 @@ }

@@ -5,3 +5,3 @@ import { invariant, InvariantError } from 'ts-invariant';

function checkDocument(doc) {
process.env.NODE_ENV === "production" ? invariant(doc && doc.kind === 'Document', 24) : invariant(doc && doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql");
process.env.NODE_ENV === "production" ? invariant(doc && doc.kind === 'Document', 22) : invariant(doc && doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql");
var operations = doc.definitions

@@ -11,7 +11,7 @@ .filter(function (d) { return d.kind !== 'FragmentDefinition'; })

if (definition.kind !== 'OperationDefinition') {
throw process.env.NODE_ENV === "production" ? new InvariantError(25) : new InvariantError("Schema type definitions not allowed in queries. Found: \"" + definition.kind + "\"");
throw process.env.NODE_ENV === "production" ? new InvariantError(23) : new InvariantError("Schema type definitions not allowed in queries. Found: \"" + definition.kind + "\"");
}
return definition;
});
process.env.NODE_ENV === "production" ? invariant(operations.length <= 1, 26) : invariant(operations.length <= 1, "Ambiguous GraphQL document: contains " + operations.length + " operations");
process.env.NODE_ENV === "production" ? invariant(operations.length <= 1, 24) : invariant(operations.length <= 1, "Ambiguous GraphQL document: contains " + operations.length + " operations");
return doc;

@@ -35,10 +35,10 @@ }

var queryDef = getOperationDefinition(doc);
process.env.NODE_ENV === "production" ? invariant(queryDef && queryDef.operation === 'query', 27) : invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.');
process.env.NODE_ENV === "production" ? invariant(queryDef && queryDef.operation === 'query', 25) : invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.');
return queryDef;
}
function getFragmentDefinition(doc) {
process.env.NODE_ENV === "production" ? invariant(doc.kind === 'Document', 28) : invariant(doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql");
process.env.NODE_ENV === "production" ? invariant(doc.definitions.length <= 1, 29) : invariant(doc.definitions.length <= 1, 'Fragment must have exactly one definition.');
process.env.NODE_ENV === "production" ? invariant(doc.kind === 'Document', 26) : invariant(doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql");
process.env.NODE_ENV === "production" ? invariant(doc.definitions.length <= 1, 27) : invariant(doc.definitions.length <= 1, 'Fragment must have exactly one definition.');
var fragmentDef = doc.definitions[0];
process.env.NODE_ENV === "production" ? invariant(fragmentDef.kind === 'FragmentDefinition', 30) : invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.');
process.env.NODE_ENV === "production" ? invariant(fragmentDef.kind === 'FragmentDefinition', 28) : invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.');
return fragmentDef;

@@ -66,3 +66,3 @@ }

}
throw process.env.NODE_ENV === "production" ? new InvariantError(31) : new InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.');
throw process.env.NODE_ENV === "production" ? new InvariantError(29) : new InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.');
}

@@ -69,0 +69,0 @@ function getDefaultValues(definition) {

@@ -70,3 +70,3 @@ import { InvariantError } from 'ts-invariant';

else {
throw process.env.NODE_ENV === "production" ? new InvariantError(33) : new InvariantError("The inline argument \"" + name.value + "\" of kind \"" + value.kind + "\"" +
throw process.env.NODE_ENV === "production" ? new InvariantError(30) : new InvariantError("The inline argument \"" + name.value + "\" of kind \"" + value.kind + "\"" +
'is not supported. Use variables instead of inline arguments to ' +

@@ -73,0 +73,0 @@ 'overcome this limitation.');

@@ -16,5 +16,6 @@ /// <reference types="zen-observable" />

setups: any[];
private observer;
operation: Operation;
private observers;
constructor();
request(_req: any): Observable<FetchResult<{
request(operation: Operation): Observable<FetchResult<{
[key: string]: any;

@@ -21,0 +22,0 @@ }, Record<string, any>, Record<string, any>>>;

@@ -10,9 +10,11 @@ import { __extends } from "tslib";

_this.setups = [];
_this.observers = [];
return _this;
}
MockSubscriptionLink.prototype.request = function (_req) {
MockSubscriptionLink.prototype.request = function (operation) {
var _this = this;
this.operation = operation;
return new Observable(function (observer) {
_this.setups.forEach(function (x) { return x(); });
_this.observer = observer;
_this.observers.push(observer);
return function () {

@@ -27,19 +29,23 @@ _this.unsubscribers.forEach(function (x) { return x(); });

setTimeout(function () {
var observer = _this.observer;
if (!observer)
var observers = _this.observers;
if (!observers.length)
throw new Error('subscription torn down');
if (complete && observer.complete)
observer.complete();
if (result.result && observer.next)
observer.next(result.result);
if (result.error && observer.error)
observer.error(result.error);
observers.forEach(function (observer) {
if (complete && observer.complete)
observer.complete();
if (result.result && observer.next)
observer.next(result.result);
if (result.error && observer.error)
observer.error(result.error);
});
}, result.delay || 0);
};
MockSubscriptionLink.prototype.simulateComplete = function () {
var observer = this.observer;
if (!observer)
var observers = this.observers;
if (!observers.length)
throw new Error('subscription torn down');
if (observer.complete)
observer.complete();
observers.forEach(function (observer) {
if (observer.complete)
observer.complete();
});
};

@@ -46,0 +52,0 @@ MockSubscriptionLink.prototype.onSetup = function (listener) {

@@ -22,3 +22,3 @@ 'use strict';

evaledValue = variables && variables[ifArgument.value.name.value];
process.env.NODE_ENV === "production" ? tsInvariant.invariant(evaledValue !== void 0, 40) : tsInvariant.invariant(evaledValue !== void 0, "Invalid variable referenced in @" + directive.name.value + " directive.");
process.env.NODE_ENV === "production" ? tsInvariant.invariant(evaledValue !== void 0, 36) : tsInvariant.invariant(evaledValue !== void 0, "Invalid variable referenced in @" + directive.name.value + " directive.");
}

@@ -60,8 +60,8 @@ else {

var directiveName = directive.name.value;
process.env.NODE_ENV === "production" ? tsInvariant.invariant(directiveArguments && directiveArguments.length === 1, 41) : tsInvariant.invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @" + directiveName + " directive.");
process.env.NODE_ENV === "production" ? tsInvariant.invariant(directiveArguments && directiveArguments.length === 1, 37) : tsInvariant.invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @" + directiveName + " directive.");
var ifArgument = directiveArguments[0];
process.env.NODE_ENV === "production" ? tsInvariant.invariant(ifArgument.name && ifArgument.name.value === 'if', 42) : tsInvariant.invariant(ifArgument.name && ifArgument.name.value === 'if', "Invalid argument for the @" + directiveName + " directive.");
process.env.NODE_ENV === "production" ? tsInvariant.invariant(ifArgument.name && ifArgument.name.value === 'if', 38) : tsInvariant.invariant(ifArgument.name && ifArgument.name.value === 'if', "Invalid argument for the @" + directiveName + " directive.");
var ifValue = ifArgument.value;
process.env.NODE_ENV === "production" ? tsInvariant.invariant(ifValue &&
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 43) : tsInvariant.invariant(ifValue &&
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 39) : tsInvariant.invariant(ifValue &&
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), "Argument for the @" + directiveName + " directive must be a variable or a boolean value.");

@@ -79,3 +79,3 @@ result.push({ directive: directive, ifArgument: ifArgument });

if (definition.kind === 'OperationDefinition') {
throw process.env.NODE_ENV === "production" ? new tsInvariant.InvariantError(37) : new tsInvariant.InvariantError("Found a " + definition.operation + " operation" + (definition.name ? " named '" + definition.name.value + "'" : '') + ". " +
throw process.env.NODE_ENV === "production" ? new tsInvariant.InvariantError(40) : new tsInvariant.InvariantError("Found a " + definition.operation + " operation" + (definition.name ? " named '" + definition.name.value + "'" : '') + ". " +
'No operations are allowed when using a fragment as a query. Only fragments are allowed.');

@@ -88,3 +88,3 @@ }

if (typeof actualFragmentName === 'undefined') {
process.env.NODE_ENV === "production" ? tsInvariant.invariant(fragments.length === 1, 38) : tsInvariant.invariant(fragments.length === 1, "Found " + fragments.length + " fragments. `fragmentName` must be provided when there is not exactly 1 fragment.");
process.env.NODE_ENV === "production" ? tsInvariant.invariant(fragments.length === 1, 41) : tsInvariant.invariant(fragments.length === 1, "Found " + fragments.length + " fragments. `fragmentName` must be provided when there is not exactly 1 fragment.");
actualFragmentName = fragments[0].name.value;

@@ -126,3 +126,3 @@ }

var fragment = fragmentMap && fragmentMap[selection.name.value];
process.env.NODE_ENV === "production" ? tsInvariant.invariant(fragment, 39) : tsInvariant.invariant(fragment, "No fragment named " + selection.name.value + ".");
process.env.NODE_ENV === "production" ? tsInvariant.invariant(fragment, 42) : tsInvariant.invariant(fragment, "No fragment named " + selection.name.value + ".");
return fragment;

@@ -200,3 +200,3 @@ }

else {
throw process.env.NODE_ENV === "production" ? new tsInvariant.InvariantError(33) : new tsInvariant.InvariantError("The inline argument \"" + name.value + "\" of kind \"" + value.kind + "\"" +
throw process.env.NODE_ENV === "production" ? new tsInvariant.InvariantError(30) : new tsInvariant.InvariantError("The inline argument \"" + name.value + "\" of kind \"" + value.kind + "\"" +
'is not supported. Use variables instead of inline arguments to ' +

@@ -319,3 +319,3 @@ 'overcome this limitation.');

function checkDocument(doc) {
process.env.NODE_ENV === "production" ? tsInvariant.invariant(doc && doc.kind === 'Document', 24) : tsInvariant.invariant(doc && doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql");
process.env.NODE_ENV === "production" ? tsInvariant.invariant(doc && doc.kind === 'Document', 22) : tsInvariant.invariant(doc && doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql");
var operations = doc.definitions

@@ -325,7 +325,7 @@ .filter(function (d) { return d.kind !== 'FragmentDefinition'; })

if (definition.kind !== 'OperationDefinition') {
throw process.env.NODE_ENV === "production" ? new tsInvariant.InvariantError(25) : new tsInvariant.InvariantError("Schema type definitions not allowed in queries. Found: \"" + definition.kind + "\"");
throw process.env.NODE_ENV === "production" ? new tsInvariant.InvariantError(23) : new tsInvariant.InvariantError("Schema type definitions not allowed in queries. Found: \"" + definition.kind + "\"");
}
return definition;
});
process.env.NODE_ENV === "production" ? tsInvariant.invariant(operations.length <= 1, 26) : tsInvariant.invariant(operations.length <= 1, "Ambiguous GraphQL document: contains " + operations.length + " operations");
process.env.NODE_ENV === "production" ? tsInvariant.invariant(operations.length <= 1, 24) : tsInvariant.invariant(operations.length <= 1, "Ambiguous GraphQL document: contains " + operations.length + " operations");
return doc;

@@ -349,10 +349,10 @@ }

var queryDef = getOperationDefinition(doc);
process.env.NODE_ENV === "production" ? tsInvariant.invariant(queryDef && queryDef.operation === 'query', 27) : tsInvariant.invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.');
process.env.NODE_ENV === "production" ? tsInvariant.invariant(queryDef && queryDef.operation === 'query', 25) : tsInvariant.invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.');
return queryDef;
}
function getFragmentDefinition(doc) {
process.env.NODE_ENV === "production" ? tsInvariant.invariant(doc.kind === 'Document', 28) : tsInvariant.invariant(doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql");
process.env.NODE_ENV === "production" ? tsInvariant.invariant(doc.definitions.length <= 1, 29) : tsInvariant.invariant(doc.definitions.length <= 1, 'Fragment must have exactly one definition.');
process.env.NODE_ENV === "production" ? tsInvariant.invariant(doc.kind === 'Document', 26) : tsInvariant.invariant(doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql");
process.env.NODE_ENV === "production" ? tsInvariant.invariant(doc.definitions.length <= 1, 27) : tsInvariant.invariant(doc.definitions.length <= 1, 'Fragment must have exactly one definition.');
var fragmentDef = doc.definitions[0];
process.env.NODE_ENV === "production" ? tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition', 30) : tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.');
process.env.NODE_ENV === "production" ? tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition', 28) : tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.');
return fragmentDef;

@@ -380,3 +380,3 @@ }

}
throw process.env.NODE_ENV === "production" ? new tsInvariant.InvariantError(31) : new tsInvariant.InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.');
throw process.env.NODE_ENV === "production" ? new tsInvariant.InvariantError(29) : new tsInvariant.InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.');
}

@@ -383,0 +383,0 @@ function getDefaultValues(definition) {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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