Socket
Socket
Sign inDemoInstall

@apollo/client

Package Overview
Dependencies
Maintainers
1
Versions
574
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-beta.16 to 3.0.0-beta.17

11

cache/inmemory/helpers.d.ts

@@ -0,5 +1,14 @@

import { FieldNode } from 'graphql';
import { NormalizedCache, StoreObject } from './types';
import { Reference } from '../../utilities/graphql/storeUtils';
import { Reference, StoreValue } from '../../utilities/graphql/storeUtils';
import { DeepMerger } from '../../utilities/common/mergeDeep';
export declare function getTypenameFromStoreObject(store: NormalizedCache, objectOrReference: StoreObject | Reference): string | undefined;
export declare function fieldNameFromStoreName(storeFieldName: string): string;
export interface FieldValueToBeMerged {
__field: FieldNode;
__typename: string;
__value: StoreValue;
}
export declare function isFieldValueToBeMerged(value: any): value is FieldValueToBeMerged;
export declare function makeProcessedFieldsMerger(): DeepMerger<[]>;
//# sourceMappingURL=helpers.d.ts.map

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

import { isReference } from '../../utilities/graphql/storeUtils.js';
import { isReference, isField } from '../../utilities/graphql/storeUtils.js';
import { DeepMerger } from '../../utilities/common/mergeDeep.js';

@@ -13,4 +14,26 @@ function getTypenameFromStoreObject(store, objectOrReference) {

}
function isFieldValueToBeMerged(value) {
var field = value && value.__field;
return field && isField(field);
}
function makeProcessedFieldsMerger() {
return new DeepMerger(reconcileProcessedFields);
}
var reconcileProcessedFields = function (existingObject, incomingObject, property) {
var existing = existingObject[property];
var incoming = incomingObject[property];
if (isFieldValueToBeMerged(existing)) {
existing.__value = this.merge(existing.__value, isFieldValueToBeMerged(incoming)
? incoming.__value
: incoming);
return existing;
}
if (isFieldValueToBeMerged(incoming)) {
incoming.__value = this.merge(existing, incoming.__value);
return incoming;
}
return this.merge(existing, incoming);
};
export { fieldNameFromStoreName, getTypenameFromStoreObject };
export { fieldNameFromStoreName, getTypenameFromStoreObject, isFieldValueToBeMerged, makeProcessedFieldsMerger };
//# sourceMappingURL=helpers.js.map

15

cache/inmemory/policies.d.ts
import { InlineFragmentNode, FragmentDefinitionNode, SelectionSetNode, FieldNode } from "graphql";
import { FragmentMap } from '../../utilities/graphql/fragments';
import { StoreValue, Reference, isReference } from '../../utilities/graphql/storeUtils';
import { IdGetter, StoreObject } from "./types";
import { FieldValueGetter } from './readFromStore';
import { IdGetter, StoreObject, NormalizedCache } from "./types";
import { FieldValueToBeMerged } from './helpers';
export declare type TypePolicies = {

@@ -35,5 +35,7 @@ [__typename: string]: TypePolicy;

};
export declare type FieldValueGetter = ReturnType<Policies["makeFieldValueGetter"]>;
interface FieldFunctionOptions {
args: Record<string, any> | null;
field: string | FieldNode;
fieldName: string;
field: FieldNode | null;
variables?: Record<string, any>;

@@ -46,5 +48,5 @@ policies: Policies;

interface ReadFunctionOptions extends FieldFunctionOptions {
readField<T = StoreValue>(nameOrField: string | FieldNode, foreignObjOrRef?: StoreObject | Reference): Readonly<T>;
storage: StorageType;
invalidate(): void;
readField<T = StoreValue>(nameOrField: string | FieldNode, foreignRef?: Reference): Readonly<T>;
}

@@ -76,2 +78,3 @@ declare type FieldReadFunction<TExisting, TResult = TExisting> = (existing: Readonly<TExisting> | undefined, options: ReadFunctionOptions) => TResult;

fragmentMatches(fragment: InlineFragmentNode | FragmentDefinitionNode, typename: string): boolean;
makeFieldValueGetter(store: NormalizedCache): <T = StoreValue>(objectOrReference: Reference | StoreObject, storeFieldName: string) => Readonly<T>;
getStoreFieldName(typename: string | undefined, field: FieldNode, variables: Record<string, any>): string;

@@ -81,6 +84,6 @@ private storageTrie;

readField<V = StoreValue>(objectOrReference: StoreObject | Reference, nameOrField: string | FieldNode, getFieldValue: FieldValueGetter, variables?: Record<string, any>, typename?: string): Readonly<V>;
getFieldMergeFunction(typename: string, field: FieldNode, variables?: Record<string, any>): StoreValueMergeFunction;
hasMergeFunction(typename: string, fieldName: string): boolean;
applyMerges<T extends StoreValue>(existing: T | Reference, incoming: T | FieldValueToBeMerged, getFieldValue: FieldValueGetter, variables: Record<string, any>): T;
}
export declare type StoreValueMergeFunction = (existing: StoreValue, incoming: StoreValue) => StoreValue;
export {};
//# sourceMappingURL=policies.d.ts.map
import { __assign } from 'tslib';
import invariant from 'ts-invariant';
import { getFragmentFromSelection } from '../../utilities/graphql/fragments.js';
import { makeReference, getTypenameFromResult, valueToObjectRepresentation, storeKeyNameFromField, isReference, argumentsObjectFromField, isField } from '../../utilities/graphql/storeUtils.js';
import { makeReference, getTypenameFromResult, valueToObjectRepresentation, isReference, storeKeyNameFromField, argumentsObjectFromField, isField } from '../../utilities/graphql/storeUtils.js';
import { canUseWeakMap } from '../../utilities/common/canUse.js';
import { KeyTrie, dep } from 'optimism';
import { fieldNameFromStoreName } from './helpers.js';
import { maybeDeepFreeze } from '../../utilities/common/maybeDeepFreeze.js';
import { fieldNameFromStoreName, isFieldValueToBeMerged } from './helpers.js';

@@ -175,2 +176,22 @@ var hasOwn = Object.prototype.hasOwnProperty;

};
Policies.prototype.makeFieldValueGetter = function (store) {
var policies = this;
return function getFieldValue(objectOrReference, storeFieldName) {
var fieldValue;
if (isReference(objectOrReference)) {
var dataId = objectOrReference.__ref;
fieldValue = store.getFieldValue(dataId, storeFieldName);
if (fieldValue === void 0 && storeFieldName === "__typename") {
return policies.rootTypenamesById[dataId];
}
}
else {
fieldValue = objectOrReference && objectOrReference[storeFieldName];
}
if (process.env.NODE_ENV !== "production") {
maybeDeepFreeze(fieldValue);
}
return fieldValue;
};
};
Policies.prototype.getStoreFieldName = function (typename, field, variables) {

@@ -214,3 +235,4 @@ var fieldName = field.name.value;

argumentsObjectFromField(nameOrField, variables),
field: typeof nameOrField === "string" ? fieldName : nameOrField,
field: typeof nameOrField === "string" ? null : nameOrField,
fieldName: fieldName,
variables: variables,

@@ -221,4 +243,4 @@ policies: policies,

storage: storage_1,
readField: function (nameOrField, ref) {
return policies.readField(ref || objectOrReference, nameOrField, getFieldValue, variables);
readField: function (nameOrField, foreignObjOrRef) {
return policies.readField(foreignObjOrRef || objectOrReference, nameOrField, getFieldValue, variables);
},

@@ -232,17 +254,38 @@ invalidate: function () {

};
Policies.prototype.getFieldMergeFunction = function (typename, field, variables) {
Policies.prototype.hasMergeFunction = function (typename, fieldName) {
var policy = this.getFieldPolicy(typename, fieldName, false);
return !!(policy && policy.merge);
};
Policies.prototype.applyMerges = function (existing, incoming, getFieldValue, variables) {
var policies = this;
var policy = policies.getFieldPolicy(typename, field.name.value, false);
var merge = policy && policy.merge;
if (merge) {
var args_1 = argumentsObjectFromField(field, variables);
return function (existing, incoming) { return merge(existing, incoming, {
args: args_1,
field: field,
variables: variables,
policies: policies,
isReference: isReference,
toReference: policies.toReference,
}); };
if (isFieldValueToBeMerged(incoming)) {
var field = incoming.__field;
var fieldName = field.name.value;
var policy = policies.getFieldPolicy(incoming.__typename, fieldName, false);
var applied = policies.applyMerges(existing, incoming.__value, getFieldValue, variables);
var merge = policy && policy.merge;
if (merge) {
if (process.env.NODE_ENV !== "production") {
maybeDeepFreeze(existing);
}
return merge(existing, applied, {
args: argumentsObjectFromField(field, variables),
field: field,
fieldName: fieldName,
variables: variables,
policies: policies,
isReference: isReference,
toReference: policies.toReference,
});
}
return applied;
}
if (incoming && typeof incoming === "object") {
var e_1 = existing;
var i_1 = incoming;
Object.keys(i_1).forEach(function (storeFieldName) {
i_1[storeFieldName] = policies.applyMerges(getFieldValue(e_1, storeFieldName), i_1[storeFieldName], getFieldValue, variables);
});
}
return incoming;
};

@@ -261,9 +304,9 @@ return Policies;

if (field.arguments && field.arguments.length > 0) {
var args_2 = Object.create(null);
var args_1 = Object.create(null);
field.arguments.forEach(function (arg) {
if (topLevelArgNames[arg.name.value] === true) {
valueToObjectRepresentation(args_2, arg.name, arg.value, context.variables);
valueToObjectRepresentation(args_1, arg.name, arg.value, context.variables);
}
});
return fieldName + ":" + JSON.stringify(computeKeyObject(args_2, specifier));
return fieldName + ":" + JSON.stringify(computeKeyObject(args_1, specifier));
}

@@ -270,0 +313,0 @@ return fieldName;

@@ -1,4 +0,3 @@

import { Reference, StoreValue } from '../../utilities/graphql/storeUtils';
import { Cache } from '../core/types/Cache';
import { DiffQueryAgainstStoreOptions, ReadQueryOptions, StoreObject, NormalizedCache } from './types';
import { DiffQueryAgainstStoreOptions, ReadQueryOptions, StoreObject } from './types';
import { Policies } from './policies';

@@ -28,5 +27,2 @@ export declare type VariableMap = {

}
export declare type FieldValueGetter = ReturnType<typeof makeFieldValueGetter>;
declare function makeFieldValueGetter(policies: Policies, store: NormalizedCache): <T = StoreValue>(objectOrReference: Reference | StoreObject, storeFieldName: string) => Readonly<T>;
export {};
//# sourceMappingURL=readFromStore.d.ts.map

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

fragmentMap: createFragmentMap(getFragmentDefinitions(query)),
getFieldValue: policies.makeFieldValueGetter(store),
},

@@ -74,6 +75,5 @@ });

var selectionSet = _a.selectionSet, objectOrReference = _a.objectOrReference, context = _a.context;
var store = context.store, fragmentMap = context.fragmentMap, variables = context.variables, policies = context.policies;
var fragmentMap = context.fragmentMap, variables = context.variables, policies = context.policies, getFieldValue = context.getFieldValue;
var objectsToMerge = [];
var finalResult = { result: null };
var getFieldValue = makeFieldValueGetter(policies, store);
var typename = getFieldValue(objectOrReference, "__typename");

@@ -196,21 +196,2 @@ if (this.config.addTypename &&

}());
function makeFieldValueGetter(policies, store) {
return function getFieldValue(objectOrReference, storeFieldName) {
var fieldValue;
if (isReference(objectOrReference)) {
var dataId = objectOrReference.__ref;
fieldValue = store.getFieldValue(dataId, storeFieldName);
if (fieldValue === void 0 && storeFieldName === "__typename") {
return policies.rootTypenamesById[dataId];
}
}
else {
fieldValue = objectOrReference && objectOrReference[storeFieldName];
}
if (process.env.NODE_ENV !== "production") {
maybeDeepFreeze(fieldValue);
}
return fieldValue;
};
}
function assertSelectionSetForIdValue(store, field, fieldValue) {

@@ -217,0 +198,0 @@ if (!field.selectionSet) {

import { SelectionSetNode, DocumentNode } from 'graphql';
import { FragmentMap } from '../../utilities/graphql/fragments';
import { Policies, FieldValueGetter } from './policies';
import { NormalizedCache } from './types';
import { Policies } from './policies';
export declare type WriteContext = {

@@ -12,2 +12,3 @@ readonly store: NormalizedCache;

readonly fragmentMap?: FragmentMap;
getFieldValue: FieldValueGetter;
merge<T>(existing: T, incoming: T): T;

@@ -14,0 +15,0 @@ };

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

import { cloneDeep } from '../../utilities/common/cloneDeep.js';
import { DeepMerger } from '../../utilities/common/mergeDeep.js';
import { maybeDeepFreeze } from '../../utilities/common/maybeDeepFreeze.js';
import { makeProcessedFieldsMerger } from './helpers.js';
import { defaultNormalizedCacheFactory } from './entityStore.js';

@@ -21,3 +20,3 @@

store.retain(dataId);
var simpleMerger = new DeepMerger;
var merger = makeProcessedFieldsMerger();
return this.writeSelectionSetToStore({

@@ -31,6 +30,7 @@ result: result || Object.create(null),

merge: function (existing, incoming) {
return simpleMerger.merge(existing, incoming);
return merger.merge(existing, incoming);
},
variables: __assign(__assign({}, getDefaultValues(operationDefinition)), variables),
fragmentMap: createFragmentMap(getFragmentDefinitions(query)),
getFieldValue: this.policies.makeFieldValueGetter(store),
},

@@ -41,2 +41,3 @@ });

var dataId = _a.dataId, result = _a.result, selectionSet = _a.selectionSet, context = _a.context;
var policies = this.policies;
var store = context.store, written = context.written;

@@ -47,6 +48,6 @@ var sets = written[dataId] || (written[dataId] = []);

sets.push(selectionSet);
var entityRef = makeReference(dataId);
var typename = getTypenameFromResult(result, selectionSet, context.fragmentMap) ||
store.getFieldValue(dataId, "__typename") ||
this.policies.rootTypenamesById[dataId];
var processed = this.processSelectionSet({
context.getFieldValue(entityRef, "__typename");
store.merge(dataId, policies.applyMerges(entityRef, this.processSelectionSet({
result: result,

@@ -56,7 +57,3 @@ selectionSet: selectionSet,

typename: typename,
});
if (processed.mergeOverrides) {
walkWithMergeOverrides(store.get(dataId), processed.result, processed.mergeOverrides);
}
store.merge(dataId, processed.result);
}), context.getFieldValue, context.variables));
return store;

@@ -66,3 +63,3 @@ };

var _this = this;
var result = _a.result, selectionSet = _a.selectionSet, context = _a.context, mergeOverrides = _a.mergeOverrides, typename = _a.typename;
var result = _a.result, selectionSet = _a.selectionSet, context = _a.context, typename = _a.typename;
var mergedFields = Object.create(null);

@@ -77,2 +74,3 @@ if (typeof typename === "string") {

}
var policies = _this.policies;
if (isField(selection)) {

@@ -82,14 +80,13 @@ var resultFieldKey = resultKeyNameFromField(selection);

if (typeof value !== 'undefined') {
var storeFieldName = _this.policies.getStoreFieldName(typename, selection, context.variables);
var processed = _this.processFieldValue(value, selection, context);
var merge = _this.policies.getFieldMergeFunction(typename, selection, context.variables);
if (merge || processed.mergeOverrides) {
mergeOverrides = mergeOverrides || Object.create(null);
mergeOverrides[storeFieldName] = context.merge(mergeOverrides[storeFieldName], { merge: merge, child: processed.mergeOverrides });
}
var storeFieldName = policies.getStoreFieldName(typename, selection, context.variables);
var incomingValue = _this.processFieldValue(value, selection, context);
mergedFields = context.merge(mergedFields, (_a = {},
_a[storeFieldName] = processed.result,
_a[storeFieldName] = policies.hasMergeFunction(typename, selection.name.value) ? {
__field: selection,
__typename: typename,
__value: incomingValue,
} : incomingValue,
_a));
}
else if (_this.policies.usingPossibleTypes &&
else if (policies.usingPossibleTypes &&
!(selection.directives &&

@@ -105,21 +102,13 @@ selection.directives.some(function (_a) {

var fragment = getFragmentFromSelection(selection, context.fragmentMap);
if (_this.policies.fragmentMatches(fragment, typename)) {
var processed = _this.processSelectionSet({
if (policies.fragmentMatches(fragment, typename)) {
mergedFields = context.merge(mergedFields, _this.processSelectionSet({
result: result,
selectionSet: fragment.selectionSet,
context: context,
mergeOverrides: mergeOverrides,
typename: typename,
});
mergedFields = context.merge(mergedFields, processed.result);
if (processed.mergeOverrides) {
mergeOverrides = context.merge(mergeOverrides, processed.mergeOverrides);
}
}));
}
}
});
return {
result: mergedFields,
mergeOverrides: mergeOverrides,
};
return mergedFields;
};

@@ -129,17 +118,6 @@ StoreWriter.prototype.processFieldValue = function (value, field, context) {

if (!field.selectionSet || value === null) {
return {
result: process.env.NODE_ENV === 'production' ? value : cloneDeep(value),
};
return process.env.NODE_ENV === 'production' ? value : cloneDeep(value);
}
if (Array.isArray(value)) {
var overrides_1;
var result = value.map(function (item, i) {
var _a = _this.processFieldValue(item, field, context), result = _a.result, mergeOverrides = _a.mergeOverrides;
if (mergeOverrides) {
overrides_1 = overrides_1 || [];
overrides_1[i] = { child: mergeOverrides };
}
return result;
});
return { result: result, mergeOverrides: overrides_1 };
return value.map(function (item, i) { return _this.processFieldValue(item, field, context); });
}

@@ -155,3 +133,3 @@ if (value) {

});
return { result: makeReference(dataId) };
return makeReference(dataId);
}

@@ -168,20 +146,4 @@ }

}());
function walkWithMergeOverrides(existingObject, incomingObject, overrides) {
Object.keys(overrides).forEach(function (name) {
var _a = overrides[name], merge = _a.merge, child = _a.child;
var existingValue = existingObject && existingObject[name];
var incomingValue = incomingObject && incomingObject[name];
if (child) {
walkWithMergeOverrides(existingValue, incomingValue, child);
}
if (merge) {
if (process.env.NODE_ENV !== "production") {
maybeDeepFreeze(existingValue);
}
incomingObject[name] = merge(existingValue, incomingValue);
}
});
}
export { StoreWriter };
//# sourceMappingURL=writeToStore.js.map

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

else {
process.env.NODE_ENV === "production" ? invariant(false, 23) : invariant(false, 'To use context.getCacheKey, you need to use a cache that has ' +
process.env.NODE_ENV === "production" ? invariant(false, 34) : invariant(false, 'To use context.getCacheKey, you need to use a cache that has ' +
'a configurable dataIdFromObject, like apollo-cache-inmemory.');

@@ -194,3 +194,3 @@ }

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

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

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

this.fetchQueryRejectFns.forEach(function (reject) {
reject(process.env.NODE_ENV === "production" ? new InvariantError(27) : new InvariantError('QueryManager stopped while query was in flight'));
reject(process.env.NODE_ENV === "production" ? new InvariantError(23) : new InvariantError('QueryManager stopped while query was in flight'));
});

@@ -61,4 +61,4 @@ };

case 0:
process.env.NODE_ENV === "production" ? invariant(mutation, 28) : 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', 29) : 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, 24) : 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', 25) : 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.generateQueryId();

@@ -458,3 +458,3 @@ mutation = this.transform(mutation).document;

if (shouldSubscribe === void 0) { shouldSubscribe = true; }
process.env.NODE_ENV === "production" ? invariant(options.fetchPolicy !== 'standby', 30) : invariant(options.fetchPolicy !== 'standby', 'client.watchQuery cannot be called with fetchPolicy set to "standby"');
process.env.NODE_ENV === "production" ? invariant(options.fetchPolicy !== 'standby', 26) : invariant(options.fetchPolicy !== 'standby', 'client.watchQuery cannot be called with fetchPolicy set to "standby"');
options.variables = this.getVariables(options.query, options.variables);

@@ -484,7 +484,7 @@ if (typeof options.notifyOnNetworkStatusChange === 'undefined') {

var _this = this;
process.env.NODE_ENV === "production" ? invariant(options.query, 31) : invariant(options.query, 'query option is required. You must specify your GraphQL document ' +
process.env.NODE_ENV === "production" ? invariant(options.query, 27) : 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', 32) : invariant(options.query.kind === 'Document', 'You must wrap the query string in a "gql" tag.');
process.env.NODE_ENV === "production" ? invariant(!options.returnPartialData, 33) : invariant(!options.returnPartialData, 'returnPartialData option only supported on watchQuery.');
process.env.NODE_ENV === "production" ? invariant(!options.pollInterval, 34) : invariant(!options.pollInterval, 'pollInterval option only supported on watchQuery.');
process.env.NODE_ENV === "production" ? invariant(options.query.kind === 'Document', 28) : invariant(options.query.kind === 'Document', 'You must wrap the query string in a "gql" tag.');
process.env.NODE_ENV === "production" ? invariant(!options.returnPartialData, 29) : invariant(!options.returnPartialData, 'returnPartialData option only supported on watchQuery.');
process.env.NODE_ENV === "production" ? invariant(!options.pollInterval, 30) : invariant(!options.pollInterval, 'pollInterval option only supported on watchQuery.');
return new Promise(function (resolve, reject) {

@@ -557,3 +557,3 @@ var watchedQuery = _this.watchQuery(options, false);

this.fetchQueryRejectFns.forEach(function (reject) {
reject(process.env.NODE_ENV === "production" ? new InvariantError(35) : new InvariantError('Store reset while query was in flight (not completed in link chain)'));
reject(process.env.NODE_ENV === "production" ? new InvariantError(31) : new InvariantError('Store reset while query was in flight (not completed in link chain)'));
});

@@ -677,3 +677,3 @@ var resetIds = [];

var foundObservableQuery = this.getQuery(queryIdOrObservable).observableQuery;
process.env.NODE_ENV === "production" ? invariant(foundObservableQuery, 36) : invariant(foundObservableQuery, "ObservableQuery with this id doesn't exist: " + queryIdOrObservable);
process.env.NODE_ENV === "production" ? invariant(foundObservableQuery, 32) : invariant(foundObservableQuery, "ObservableQuery with this id doesn't exist: " + queryIdOrObservable);
observableQuery = foundObservableQuery;

@@ -867,3 +867,3 @@ }

var pollInterval = options.pollInterval;
process.env.NODE_ENV === "production" ? invariant(pollInterval, 37) : invariant(pollInterval, 'Attempted to start a polling query without a polling interval.');
process.env.NODE_ENV === "production" ? invariant(pollInterval, 33) : invariant(pollInterval, 'Attempted to start a polling query without a polling interval.');
if (!this.ssrMode) {

@@ -870,0 +870,0 @@ var info = this.pollingInfoByQueryId.get(queryId);

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

previousQuery.document === query.document ||
equal(previousQuery.document, query.document), 50) : invariant(!previousQuery ||
equal(previousQuery.document, query.document), 45) : invariant(!previousQuery ||
previousQuery.document === query.document ||

@@ -23,0 +23,0 @@ equal(previousQuery.document, query.document), 'Internal Error: may not update existing query string in store');

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

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

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

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

library = 'node-fetch';
throw process.env.NODE_ENV === "production" ? new InvariantError(13) : new InvariantError('"fetch" has not been found globally and no fetcher has been ' +
throw process.env.NODE_ENV === "production" ? new InvariantError(7) : new InvariantError('"fetch" has not been found globally and no fetcher has been ' +
'configured. To fix this, install a fetch package ' +

@@ -11,0 +11,0 @@ ("(like https://www.npmjs.com/package/" + library + "), instantiate the ") +

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

catch (e) {
var parseError = process.env.NODE_ENV === "production" ? new InvariantError(14) : new InvariantError("Network request failed. " + label + " is not serializable: " + e.message);
var parseError = process.env.NODE_ENV === "production" ? new InvariantError(6) : 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(25) : new InvariantError("illegal argument: " + key);
throw process.env.NODE_ENV === "production" ? new InvariantError(36) : new InvariantError("illegal argument: " + key);
}

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

{
"name": "@apollo/client",
"version": "3.0.0-beta.16",
"version": "3.0.0-beta.17",
"description": "A fully-featured caching GraphQL client.",

@@ -5,0 +5,0 @@ "private": false,

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

return React.createElement(ApolloContext.Consumer, null, function (context) {
process.env.NODE_ENV === "production" ? invariant(context && context.client, 6) : invariant(context && context.client, 'Could not find "client" in the context of ApolloConsumer. ' +
process.env.NODE_ENV === "production" ? invariant(context && context.client, 17) : invariant(context && context.client, 'Could not find "client" in the context of ApolloConsumer. ' +
'Wrap the root component in an <ApolloProvider>.');

@@ -12,0 +12,0 @@ return props.children(context.client);

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

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

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

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

(this.context && this.context.client);
process.env.NODE_ENV === "production" ? invariant(!!client, 48) : invariant(!!client, 'Could not find "client" in the context or passed in as an option. ' +
process.env.NODE_ENV === "production" ? invariant(!!client, 49) : invariant(!!client, 'Could not find "client" in the context or passed in as an option. ' +
'Wrap the root component in an <ApolloProvider>, or pass an ' +

@@ -49,3 +49,3 @@ 'ApolloClient instance in via options.');

var usedOperationName = operationName(operation.type);
process.env.NODE_ENV === "production" ? invariant(operation.type === type, 49) : invariant(operation.type === type, "Running a " + requiredOperationName + " requires a graphql " +
process.env.NODE_ENV === "production" ? invariant(operation.type === type, 50) : invariant(operation.type === type, "Running a " + requiredOperationName + " requires a graphql " +
(requiredOperationName + ", but a " + usedOperationName + " was used instead."));

@@ -52,0 +52,0 @@ };

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

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

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

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

var variables, type, name;
process.env.NODE_ENV === "production" ? invariant(!!document && !!document.kind, 8) : invariant(!!document && !!document.kind, "Argument of " + document + " passed to parser was not a valid GraphQL " +
process.env.NODE_ENV === "production" ? invariant(!!document && !!document.kind, 19) : invariant(!!document && !!document.kind, "Argument of " + document + " passed to parser was not a valid GraphQL " +
"DocumentNode. You may need to use 'graphql-tag' or another method " +

@@ -45,6 +45,6 @@ "to convert your operation into a document");

process.env.NODE_ENV === "production" ? invariant(!fragments.length ||
(queries.length || mutations.length || subscriptions.length), 9) : invariant(!fragments.length ||
(queries.length || mutations.length || subscriptions.length), 20) : invariant(!fragments.length ||
(queries.length || mutations.length || subscriptions.length), "Passing only a fragment to 'graphql' is not yet supported. " +
"You must include a query, subscription or mutation as well");
process.env.NODE_ENV === "production" ? invariant(queries.length + mutations.length + subscriptions.length <= 1, 10) : invariant(queries.length + mutations.length + subscriptions.length <= 1, "react-apollo only supports a query, subscription, or a mutation per HOC. " +
process.env.NODE_ENV === "production" ? invariant(queries.length + mutations.length + subscriptions.length <= 1, 21) : invariant(queries.length + mutations.length + subscriptions.length <= 1, "react-apollo only supports a query, subscription, or a mutation per HOC. " +
(document + " had " + queries.length + " queries, " + subscriptions.length + " ") +

@@ -61,3 +61,3 @@ ("subscriptions and " + mutations.length + " mutations. ") +

: subscriptions;
process.env.NODE_ENV === "production" ? invariant(definitions.length === 1, 11) : invariant(definitions.length === 1, "react-apollo only supports one definition per HOC. " + document + " had " +
process.env.NODE_ENV === "production" ? invariant(definitions.length === 1, 22) : invariant(definitions.length === 1, "react-apollo only supports one definition per HOC. " + document + " had " +
(definitions.length + " definitions. ") +

@@ -64,0 +64,0 @@ "You can use 'compose' to join multiple operation types to a component");

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

if (definition.kind === 'OperationDefinition') {
throw process.env.NODE_ENV === "production" ? new InvariantError(45) : new InvariantError("Found a " + definition.operation + " operation" + (definition.name ? " named '" + definition.name.value + "'" : '') + ". " +
throw process.env.NODE_ENV === "production" ? new InvariantError(46) : 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, 46) : 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, 47) : 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, 47) : invariant(fragment, "No fragment named " + selection.name.value + ".");
process.env.NODE_ENV === "production" ? invariant(fragment, 48) : invariant(fragment, "No fragment named " + selection.name.value + ".");
return fragment;

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

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

function checkDocument(doc) {
process.env.NODE_ENV === "production" ? invariant(doc && doc.kind === 'Document', 15) : 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', 8) : 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

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

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

@@ -37,10 +37,10 @@ }

var queryDef = getOperationDefinition(doc);
process.env.NODE_ENV === "production" ? invariant(queryDef && queryDef.operation === 'query', 18) : invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.');
process.env.NODE_ENV === "production" ? invariant(queryDef && queryDef.operation === 'query', 11) : invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.');
return queryDef;
}
function getFragmentDefinition(doc) {
process.env.NODE_ENV === "production" ? invariant(doc.kind === 'Document', 19) : 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, 20) : invariant(doc.definitions.length <= 1, 'Fragment must have exactly one definition.');
process.env.NODE_ENV === "production" ? invariant(doc.kind === 'Document', 12) : 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, 13) : 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', 21) : invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.');
process.env.NODE_ENV === "production" ? invariant(fragmentDef.kind === 'FragmentDefinition', 14) : invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.');
return fragmentDef;

@@ -68,3 +68,3 @@ }

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

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

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

else {
throw process.env.NODE_ENV === "production" ? new InvariantError(26) : new InvariantError("The inline argument \"" + name.value + "\" of kind \"" + value.kind + "\"" +
throw process.env.NODE_ENV === "production" ? new InvariantError(37) : 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.');

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

if (definition.kind === 'OperationDefinition') {
throw process.env.NODE_ENV === "production" ? new tsInvariant.InvariantError(45) : new tsInvariant.InvariantError("Found a " + definition.operation + " operation" + (definition.name ? " named '" + definition.name.value + "'" : '') + ". " +
throw process.env.NODE_ENV === "production" ? new tsInvariant.InvariantError(46) : 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.');

@@ -77,3 +77,3 @@ }

if (typeof actualFragmentName === 'undefined') {
process.env.NODE_ENV === "production" ? tsInvariant.invariant(fragments.length === 1, 46) : 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, 47) : 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;

@@ -115,3 +115,3 @@ }

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

@@ -205,3 +205,3 @@ }

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

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

function checkDocument(doc) {
process.env.NODE_ENV === "production" ? tsInvariant.invariant(doc && doc.kind === 'Document', 15) : 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', 8) : 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

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

if (definition.kind !== 'OperationDefinition') {
throw process.env.NODE_ENV === "production" ? new tsInvariant.InvariantError(16) : new tsInvariant.InvariantError("Schema type definitions not allowed in queries. Found: \"" + definition.kind + "\"");
throw process.env.NODE_ENV === "production" ? new tsInvariant.InvariantError(9) : 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, 17) : tsInvariant.invariant(operations.length <= 1, "Ambiguous GraphQL document: contains " + operations.length + " operations");
process.env.NODE_ENV === "production" ? tsInvariant.invariant(operations.length <= 1, 10) : tsInvariant.invariant(operations.length <= 1, "Ambiguous GraphQL document: contains " + operations.length + " operations");
return doc;

@@ -354,10 +354,10 @@ }

var queryDef = getOperationDefinition(doc);
process.env.NODE_ENV === "production" ? tsInvariant.invariant(queryDef && queryDef.operation === 'query', 18) : tsInvariant.invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.');
process.env.NODE_ENV === "production" ? tsInvariant.invariant(queryDef && queryDef.operation === 'query', 11) : 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', 19) : 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, 20) : tsInvariant.invariant(doc.definitions.length <= 1, 'Fragment must have exactly one definition.');
process.env.NODE_ENV === "production" ? tsInvariant.invariant(doc.kind === 'Document', 12) : 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, 13) : 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', 21) : tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.');
process.env.NODE_ENV === "production" ? tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition', 14) : tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.');
return fragmentDef;

@@ -385,3 +385,3 @@ }

}
throw process.env.NODE_ENV === "production" ? new tsInvariant.InvariantError(22) : 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(15) : new tsInvariant.InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.');
}

@@ -388,0 +388,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 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

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