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.15 to 3.0.0-beta.16

utilities/index.d.ts

2

cache/inmemory/entityStore.js

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

}
process.env.NODE_ENV === "production" ? invariant(!isReference(existing) || isReference(incoming), 56) : invariant(!isReference(existing) || isReference(incoming), "Store error: the application attempted to write an object with no provided id but the store already contains an id of " + existing.__ref + " for this object.");
process.env.NODE_ENV === "production" ? invariant(!isReference(existing) || isReference(incoming), 54) : invariant(!isReference(existing) || isReference(incoming), "Store error: the application attempted to write an object with no provided id but the store already contains an id of " + existing.__ref + " for this object.");
if (equal(existing, incoming)) {

@@ -303,0 +303,0 @@ return existing;

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

@@ -9,6 +10,7 @@ [__typename: string]: TypePolicy;

declare type KeySpecifier = (string | any[])[];
declare type KeyFieldsFunction = (this: Policies, object: Readonly<StoreObject>, context: {
declare type KeyFieldsFunction = (object: Readonly<StoreObject>, context: {
typename: string;
selectionSet?: SelectionSetNode;
fragmentMap?: FragmentMap;
policies: Policies;
}) => ReturnType<IdGetter>;

@@ -24,5 +26,6 @@ declare type TypePolicy = {

};
declare type KeyArgsFunction = (this: Policies, field: FieldNode, context: {
declare type KeyArgsFunction = (field: FieldNode, context: {
typename: string;
variables: Record<string, any>;
policies: Policies;
}) => ReturnType<IdGetter>;

@@ -35,17 +38,17 @@ export declare type FieldPolicy<TValue> = {

interface FieldFunctionOptions {
args: Record<string, any>;
field: FieldNode;
args: Record<string, any> | null;
field: string | FieldNode;
variables?: Record<string, any>;
policies: Policies;
isReference: typeof isReference;
toReference: Policies["toReference"];
getFieldValue<T = StoreValue>(field: string | FieldNode, foreignRef?: Reference): Readonly<T>;
}
interface FieldReadFunction<TExisting, TResult = TExisting> {
(this: Policies, existing: Readonly<TExisting> | undefined, options: FieldFunctionOptions): TResult;
call(self: Policies, existing: Readonly<TExisting> | undefined, options: FieldFunctionOptions): TResult;
declare type StorageType = Record<string, any>;
interface ReadFunctionOptions extends FieldFunctionOptions {
storage: StorageType;
invalidate(): void;
readField<T = StoreValue>(nameOrField: string | FieldNode, foreignRef?: Reference): Readonly<T>;
}
interface FieldMergeFunction<TExisting> {
(this: Policies, existing: Readonly<TExisting> | undefined, incoming: Readonly<StoreValue>, options: FieldFunctionOptions): TExisting;
call(self: Policies, existing: Readonly<TExisting> | undefined, incoming: Readonly<StoreValue>, options: FieldFunctionOptions): TExisting;
}
declare type FieldReadFunction<TExisting, TResult = TExisting> = (existing: Readonly<TExisting> | undefined, options: ReadFunctionOptions) => TResult;
declare type FieldMergeFunction<TExisting> = (existing: Readonly<TExisting> | undefined, incoming: Readonly<StoreValue>, options: FieldFunctionOptions) => TExisting;
export declare function defaultDataIdFromObject(object: StoreObject): string;

@@ -61,3 +64,3 @@ export declare type PossibleTypesMap = {

constructor(config?: {
dataIdFromObject?: IdGetter;
dataIdFromObject?: KeyFieldsFunction;
possibleTypes?: PossibleTypesMap;

@@ -74,5 +77,7 @@ typePolicies?: TypePolicies;

private getFieldPolicy;
fragmentMatches(fragment: InlineFragmentNode | FragmentDefinitionNode, typename: string): boolean | "heuristic";
fragmentMatches(fragment: InlineFragmentNode | FragmentDefinitionNode, typename: string): boolean;
getStoreFieldName(typename: string | undefined, field: FieldNode, variables: Record<string, any>): string;
readFieldFromStoreObject(field: FieldNode, getFieldValue: (field: string, foreignRef?: Reference) => any, typename?: string, variables?: Record<string, any>): StoreValue;
private storageTrie;
private fieldDep;
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;

@@ -79,0 +84,0 @@ }

import { __assign } from 'tslib';
import invariant from 'ts-invariant';
import { getFragmentFromSelection } from '../../utilities/graphql/fragments.js';
import { makeReference, getTypenameFromResult, valueToObjectRepresentation, storeKeyNameFromField, argumentsObjectFromField, isReference, isField } from '../../utilities/graphql/storeUtils.js';
import { makeReference, getTypenameFromResult, valueToObjectRepresentation, storeKeyNameFromField, isReference, argumentsObjectFromField, isField } from '../../utilities/graphql/storeUtils.js';
import { canUseWeakMap } from '../../utilities/common/canUse.js';
import { KeyTrie } from 'optimism';
import { KeyTrie, dep } from 'optimism';
import { fieldNameFromStoreName } from './helpers.js';

@@ -39,2 +39,4 @@

};
this.storageTrie = new KeyTrie(true);
this.fieldDep = dep();
this.config = __assign({ dataIdFromObject: defaultDataIdFromObject }, config);

@@ -56,11 +58,13 @@ if (config.possibleTypes) {

fragmentMap: fragmentMap,
policies: this,
};
var id;
var policy = this.getTypePolicy(typename, false);
if (policy && policy.keyFn) {
id = policy.keyFn.call(this, object, context);
var keyFn = policy && policy.keyFn;
if (keyFn) {
id = keyFn(object, context);
}
else {
id = this.config.dataIdFromObject
? this.config.dataIdFromObject.call(this, object, context)
? this.config.dataIdFromObject(object, context)
: null;

@@ -98,3 +102,4 @@ }

Array.isArray(keyArgs) ? keyArgsFnFromSpecifier(keyArgs) :
typeof keyArgs === "function" ? keyArgs : void 0;
typeof keyArgs === "function" ? keyArgs :
existing.keyFn;
if (typeof read === "function")

@@ -105,2 +110,5 @@ existing.read = read;

}
if (existing.read || existing.merge) {
existing.keyFn = existing.keyFn || simpleKeyArgsFn;
}
});

@@ -114,3 +122,3 @@ }

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

@@ -151,2 +159,3 @@ }

var supertype = fragment.typeCondition.name.value;
process.env.NODE_ENV === "production" ? invariant(typename, 39) : invariant(typename, "Attempted to match fragment " + (fragment.kind === "InlineFragment" ? "" : fragment.name.value + " ") + "with type condition " + supertype + " against object with unknown __typename");
if (typename === supertype)

@@ -169,5 +178,4 @@ return true;

}
return false;
}
return "heuristic";
return false;
};

@@ -179,6 +187,8 @@ Policies.prototype.getStoreFieldName = function (typename, field, variables) {

var policy = this.getFieldPolicy(typename, fieldName, false);
if (policy && policy.keyFn) {
storeFieldName = policy.keyFn.call(this, field, {
var keyFn = policy && policy.keyFn;
if (keyFn) {
storeFieldName = keyFn(field, {
typename: typename,
variables: variables,
policies: this,
}) || fieldName;

@@ -194,19 +204,31 @@ }

};
Policies.prototype.readFieldFromStoreObject = function (field, getFieldValue, typename, variables) {
if (typename === void 0) { typename = getFieldValue("__typename"); }
Policies.prototype.readField = function (objectOrReference, nameOrField, getFieldValue, variables, typename) {
if (typename === void 0) { typename = getFieldValue(objectOrReference, "__typename"); }
var policies = this;
var storeFieldName = policies.getStoreFieldName(typename, field, variables);
var existing = getFieldValue(storeFieldName);
var policy = policies.getFieldPolicy(typename, field.name.value, false);
if (policy && policy.read) {
return policy.read.call(policies, existing, {
args: argumentsObjectFromField(field, variables),
field: field,
var storeFieldName = typeof nameOrField === "string" ? nameOrField
: policies.getStoreFieldName(typename, nameOrField, variables);
var fieldName = fieldNameFromStoreName(storeFieldName);
var existing = getFieldValue(objectOrReference, storeFieldName);
var policy = policies.getFieldPolicy(typename, fieldName, false);
var read = policy && policy.read;
if (read) {
var storage_1 = policies.storageTrie.lookup(isReference(objectOrReference)
? objectOrReference.__ref
: objectOrReference, storeFieldName);
policies.fieldDep(storage_1);
return read(existing, {
args: typeof nameOrField === "string" ? null :
argumentsObjectFromField(nameOrField, variables),
field: typeof nameOrField === "string" ? fieldName : nameOrField,
variables: variables,
policies: policies,
isReference: isReference,
toReference: policies.toReference,
getFieldValue: function (nameOrField, foreignRef) {
return getFieldValue(typeof nameOrField === "string" ? nameOrField :
policies.getStoreFieldName(typename, nameOrField, variables), foreignRef);
storage: storage_1,
readField: function (nameOrField, ref) {
return policies.readField(ref || objectOrReference, nameOrField, getFieldValue, variables);
},
invalidate: function () {
policies.fieldDep.dirty(storage_1);
},
});

@@ -219,11 +241,12 @@ }

var policy = policies.getFieldPolicy(typename, field.name.value, false);
if (policy && policy.merge) {
var merge = policy && policy.merge;
if (merge) {
var args_1 = argumentsObjectFromField(field, variables);
return function (existing, incoming) { return policy.merge.call(policies, existing, incoming, {
return function (existing, incoming) { return merge(existing, incoming, {
args: args_1,
field: field,
variables: variables,
policies: policies,
isReference: isReference,
toReference: policies.toReference,
getFieldValue: emptyGetFieldValueForMerge,
}); };

@@ -234,5 +257,2 @@ }

}());
function emptyGetFieldValueForMerge() {
process.env.NODE_ENV === "production" || invariant.warn("getFieldValue unavailable in merge functions");
}
function keyArgsFnFromSpecifier(specifier) {

@@ -315,3 +335,3 @@ var topLevelArgNames = Object.create(null);

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

@@ -318,0 +338,0 @@ }

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

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

@@ -10,3 +11,2 @@ export declare type VariableMap = {

fieldName: string;
tolerable: boolean;
};

@@ -29,2 +29,5 @@ export declare type ExecResult<R = any> = {

}
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
import { __assign } from 'tslib';
import { invariant } from 'ts-invariant';
import { InvariantError, invariant } from 'ts-invariant';
import { createFragmentMap } from '../../utilities/graphql/fragments.js';

@@ -62,3 +62,3 @@ import { isReference, makeReference, isField, resultKeyNameFromField, isInlineFragment } from '../../utilities/graphql/storeUtils.js';

execResult.missing.forEach(function (info) {
process.env.NODE_ENV === "production" ? invariant(info.tolerable, 53) : invariant(info.tolerable, "Can't find field " + info.fieldName + " on object " + JSON.stringify(info.object, null, 2) + ".");
throw process.env.NODE_ENV === "production" ? new InvariantError(51) : new InvariantError("Can't find field " + info.fieldName + " on object " + JSON.stringify(info.object, null, 2) + ".");
});

@@ -77,22 +77,4 @@ }

var finalResult = { result: null };
function getFieldValue(fieldName, foreignRef) {
var fieldValue;
if (foreignRef)
objectOrReference = foreignRef;
if (isReference(objectOrReference)) {
var dataId = objectOrReference.__ref;
fieldValue = store.getFieldValue(dataId, fieldName);
if (fieldValue === void 0 && fieldName === "__typename") {
return policies.rootTypenamesById[dataId];
}
}
else {
fieldValue = objectOrReference && objectOrReference[fieldName];
}
if (process.env.NODE_ENV !== "production") {
maybeDeepFreeze(fieldValue);
}
return fieldValue;
}
var typename = getFieldValue("__typename");
var getFieldValue = makeFieldValueGetter(policies, store);
var typename = getFieldValue(objectOrReference, "__typename");
if (this.config.addTypename &&

@@ -117,3 +99,3 @@ typeof typename === "string" &&

if (isField(selection)) {
var fieldValue = policies.readFieldFromStoreObject(selection, getFieldValue, typename, variables);
var fieldValue = policies.readField(objectOrReference, selection, getFieldValue, variables, typename);
if (fieldValue === void 0) {

@@ -123,3 +105,2 @@ getMissing().push({

fieldName: selection.name.value,
tolerable: false,
});

@@ -159,17 +140,10 @@ }

else {
process.env.NODE_ENV === "production" ? invariant(fragment = fragmentMap[selection.name.value], 54) : invariant(fragment = fragmentMap[selection.name.value], "No fragment named " + selection.name.value);
process.env.NODE_ENV === "production" ? invariant(fragment = fragmentMap[selection.name.value], 52) : invariant(fragment = fragmentMap[selection.name.value], "No fragment named " + selection.name.value);
}
var match = policies.fragmentMatches(fragment, typename);
if (match) {
var fragmentExecResult = _this.executeSelectionSet({
if (policies.fragmentMatches(fragment, typename)) {
objectsToMerge.push(handleMissing(_this.executeSelectionSet({
selectionSet: fragment.selectionSet,
objectOrReference: objectOrReference,
context: context,
});
if (match === 'heuristic' && fragmentExecResult.missing) {
fragmentExecResult = __assign(__assign({}, fragmentExecResult), { missing: fragmentExecResult.missing.map(function (info) {
return __assign(__assign({}, info), { tolerable: true });
}) });
}
objectsToMerge.push(handleMissing(fragmentExecResult));
})));
}

@@ -225,2 +199,21 @@ }

}());
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) {

@@ -231,3 +224,3 @@ if (!field.selectionSet) {

if (value && typeof value === "object") {
process.env.NODE_ENV === "production" ? invariant(!isReference(value), 55) : invariant(!isReference(value), "Missing selection set for object of type " + getTypenameFromStoreObject(store, value) + " returned for query field " + field.name.value);
process.env.NODE_ENV === "production" ? invariant(!isReference(value), 53) : invariant(!isReference(value), "Missing selection set for object of type " + getTypenameFromStoreObject(store, value) + " returned for query field " + field.name.value);
Object.values(value).forEach(workSet_1.add, workSet_1);

@@ -234,0 +227,0 @@ }

import { SelectionSetNode, DocumentNode } from 'graphql';
import { FragmentMap } from '../../utilities/graphql/fragments';
import { NormalizedCache, StoreObject } from './types';
import { NormalizedCache } from './types';
import { Policies } from './policies';

@@ -10,7 +10,6 @@ export declare type WriteContext = {

};
readonly mergeFields: StoreObjectMergeFunction;
readonly variables?: any;
readonly fragmentMap?: FragmentMap;
merge<T>(existing: T, incoming: T): T;
};
declare type StoreObjectMergeFunction = (existing: StoreObject, incoming: StoreObject) => StoreObject;
export interface StoreWriterConfig {

@@ -33,3 +32,2 @@ policies: Policies;

}
export {};
//# sourceMappingURL=writeToStore.d.ts.map

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

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

@@ -29,4 +29,4 @@ result: result || Object.create(null),

written: Object.create(null),
mergeFields: function (existing, incoming) {
return simpleFieldsMerger.merge(existing, incoming);
merge: function (existing, incoming) {
return simpleMerger.merge(existing, incoming);
},

@@ -45,2 +45,5 @@ variables: __assign(__assign({}, getDefaultValues(operationDefinition)), variables),

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

@@ -50,3 +53,3 @@ result: result,

context: context,
typename: this.policies.rootTypenamesById[dataId],
typename: typename,
});

@@ -61,3 +64,3 @@ if (processed.mergeOverrides) {

var _this = this;
var result = _a.result, selectionSet = _a.selectionSet, context = _a.context, mergeOverrides = _a.mergeOverrides, _b = _a.typename, typename = _b === void 0 ? getTypenameFromResult(result, selectionSet, context.fragmentMap) : _b;
var result = _a.result, selectionSet = _a.selectionSet, context = _a.context, mergeOverrides = _a.mergeOverrides, typename = _a.typename;
var mergedFields = Object.create(null);

@@ -81,5 +84,5 @@ if (typeof typename === "string") {

mergeOverrides = mergeOverrides || Object.create(null);
mergeOverrides[storeFieldName] = context.mergeFields(mergeOverrides[storeFieldName], { merge: merge, child: processed.mergeOverrides });
mergeOverrides[storeFieldName] = context.merge(mergeOverrides[storeFieldName], { merge: merge, child: processed.mergeOverrides });
}
mergedFields = context.mergeFields(mergedFields, (_a = {},
mergedFields = context.merge(mergedFields, (_a = {},
_a[storeFieldName] = processed.result,

@@ -100,3 +103,3 @@ _a));

if (_this.policies.fragmentMatches(fragment, typename)) {
mergedFields = context.mergeFields(mergedFields, _this.processSelectionSet({
var processed = _this.processSelectionSet({
result: result,

@@ -107,3 +110,7 @@ selectionSet: fragment.selectionSet,

typename: typename,
}).result);
});
mergedFields = context.merge(mergedFields, processed.result);
if (processed.mergeOverrides) {
mergeOverrides = context.merge(mergeOverrides, processed.mergeOverrides);
}
}

@@ -152,2 +159,3 @@ }

context: context,
typename: getTypenameFromResult(value, field.selectionSet, context.fragmentMap),
});

@@ -154,0 +162,0 @@ };

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

import { mergeDeep, mergeDeepArray } from '../utilities/common/mergeDeep.js';
import { capitalizeFirstLetter } from '../utilities/common/capitalizeFirstLetter.js';

@@ -86,3 +85,3 @@ var LocalState = (function () {

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

@@ -147,3 +146,4 @@ }

defaultOperationType = definitionOperation
? capitalizeFirstLetter(definitionOperation)
? definitionOperation.charAt(0).toUpperCase() +
definitionOperation.slice(1)
: 'Query';

@@ -196,3 +196,3 @@ _a = this, cache = _a.cache, client = _a.client;

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

@@ -199,0 +199,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(25) : new InvariantError('QueryManager stopped while query was in flight'));
reject(process.env.NODE_ENV === "production" ? new InvariantError(27) : new InvariantError('QueryManager stopped while query was in flight'));
});

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

case 0:
process.env.NODE_ENV === "production" ? invariant(mutation, 26) : 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', 27) : 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, 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.");
mutationId = this.generateQueryId();

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

var stale = isMissing && !(options.returnPartialData ||
options.partialRefetch ||
fetchPolicy === 'cache-only');

@@ -458,3 +459,3 @@ var resultFromStore = {

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

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

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

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

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

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

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

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

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

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

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

returnPartialData?: boolean;
partialRefetch?: boolean;
}

@@ -26,0 +27,0 @@ export interface WatchQueryOptions<TVariables = OperationVariables> extends QueryBaseOptions<TVariables>, ModifiableWatchQueryOptions<TVariables> {

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

previousQuery.document === query.document ||
equal(previousQuery.document, query.document), 43) : invariant(!previousQuery ||
equal(previousQuery.document, query.document), 50) : 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');

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

library = 'node-fetch';
throw process.env.NODE_ENV === "production" ? new InvariantError(14) : new InvariantError('"fetch" has not been found globally and no fetcher has been ' +
throw process.env.NODE_ENV === "production" ? new InvariantError(13) : 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(13) : new InvariantError("Network request failed. " + label + " is not serializable: " + e.message);
var parseError = process.env.NODE_ENV === "production" ? new InvariantError(14) : 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(38) : new InvariantError("illegal argument: " + key);
throw process.env.NODE_ENV === "production" ? new InvariantError(25) : new InvariantError("illegal argument: " + key);
}

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

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

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

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

(this.context && this.context.client);
process.env.NODE_ENV === "production" ? invariant(!!client, 51) : invariant(!!client, 'Could not find "client" in the context or passed in as an option. ' +
process.env.NODE_ENV === "production" ? invariant(!!client, 48) : 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, 52) : invariant(operation.type === type, "Running a " + requiredOperationName + " requires a graphql " +
process.env.NODE_ENV === "production" ? invariant(operation.type === type, 49) : invariant(operation.type === type, "Running a " + requiredOperationName + " requires a graphql " +
(requiredOperationName + ", but a " + usedOperationName + " was used instead."));

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

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

if (partialRefetch &&
!data &&
(!data || Object.keys(data).length === 0) &&
fetchPolicy !== 'cache-only') {

@@ -57,0 +57,0 @@ Object.assign(result, {

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

import { FieldNode, SelectionNode, DirectiveNode, DocumentNode, ArgumentNode } from 'graphql';
import { SelectionNode, DirectiveNode, DocumentNode, ArgumentNode } from 'graphql';
export declare type DirectiveInfo = {

@@ -7,3 +7,2 @@ [fieldName: string]: {

};
export declare function getDirectiveInfoFromField(field: FieldNode, variables: Object): DirectiveInfo;
export declare function shouldInclude(selection: SelectionNode, variables?: {

@@ -10,0 +9,0 @@ [name: string]: any;

import { invariant } from 'ts-invariant';
import './storeUtils.js';
import { visit } from 'graphql/language/visitor';

@@ -12,3 +11,3 @@

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

@@ -46,8 +45,8 @@ else {

var directiveName = directive.name.value;
process.env.NODE_ENV === "production" ? invariant(directiveArguments && directiveArguments.length === 1, 45) : invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @" + directiveName + " directive.");
process.env.NODE_ENV === "production" ? invariant(directiveArguments && directiveArguments.length === 1, 42) : 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', 46) : 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', 43) : 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'), 47) : invariant(ifValue &&
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 44) : invariant(ifValue &&
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), "Argument for the @" + directiveName + " directive must be a variable or a boolean value.");

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

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

import { DocumentNode, OperationDefinitionNode, FragmentDefinitionNode } from 'graphql';
export declare function getMutationDefinition(doc: DocumentNode): OperationDefinitionNode;
export declare function checkDocument(doc: DocumentNode): DocumentNode;
export declare function getOperationDefinition(doc: DocumentNode): OperationDefinitionNode | undefined;
export declare function getOperationDefinitionOrDie(document: DocumentNode): OperationDefinitionNode;
export declare function getOperationName(doc: DocumentNode): string | null;

@@ -12,3 +10,2 @@ export declare function getFragmentDefinitions(doc: DocumentNode): FragmentDefinitionNode[];

export declare function getDefaultValues(definition: OperationDefinitionNode | undefined): Record<string, any>;
export declare function variablesInOperation(operation: OperationDefinitionNode): Set<string>;
//# sourceMappingURL=getFromAST.d.ts.map

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

function checkDocument(doc) {
process.env.NODE_ENV === "production" ? invariant(doc && doc.kind === 'Document', 16) : 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', 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");
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(17) : new InvariantError("Schema type definitions not allowed in queries. Found: \"" + definition.kind + "\"");
throw process.env.NODE_ENV === "production" ? new InvariantError(16) : new InvariantError("Schema type definitions not allowed in queries. Found: \"" + definition.kind + "\"");
}
return definition;
});
process.env.NODE_ENV === "production" ? invariant(operations.length <= 1, 18) : invariant(operations.length <= 1, "Ambiguous GraphQL document: contains " + operations.length + " operations");
process.env.NODE_ENV === "production" ? invariant(operations.length <= 1, 17) : 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', 20) : invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.');
process.env.NODE_ENV === "production" ? invariant(queryDef && queryDef.operation === 'query', 18) : invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.');
return queryDef;
}
function getFragmentDefinition(doc) {
process.env.NODE_ENV === "production" ? invariant(doc.kind === 'Document', 21) : 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, 22) : invariant(doc.definitions.length <= 1, 'Fragment must have exactly one definition.');
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.');
var fragmentDef = doc.definitions[0];
process.env.NODE_ENV === "production" ? invariant(fragmentDef.kind === 'FragmentDefinition', 23) : invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.');
process.env.NODE_ENV === "production" ? invariant(fragmentDef.kind === 'FragmentDefinition', 21) : invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.');
return fragmentDef;

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

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

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

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

import { DirectiveNode, FieldNode, IntValueNode, FloatValueNode, StringValueNode, BooleanValueNode, EnumValueNode, VariableNode, InlineFragmentNode, ValueNode, SelectionNode, NameNode, SelectionSetNode } from 'graphql';
import { DirectiveNode, FieldNode, VariableNode, InlineFragmentNode, ValueNode, SelectionNode, NameNode, SelectionSetNode } from 'graphql';
import { FragmentMap } from './fragments';

@@ -9,6 +9,2 @@ export interface Reference {

export declare type StoreValue = number | string | string[] | Reference | Reference[] | null | undefined | void | Object;
export declare type ScalarValue = StringValueNode | BooleanValueNode | EnumValueNode;
export declare function isScalarValue(value: ValueNode): value is ScalarValue;
export declare type NumberValue = IntValueNode | FloatValueNode;
export declare function isNumberValue(value: ValueNode): value is NumberValue;
export declare function valueToObjectRepresentation(argObj: any, name: NameNode, value: ValueNode, variables?: Object): void;

@@ -28,3 +24,2 @@ export declare function storeKeyNameFromField(field: FieldNode, variables?: Object): string;

export declare type VariableValue = (node: VariableNode) => any;
export declare function valueFromNode(node: ValueNode, onVariable?: VariableValue): any;
//# sourceMappingURL=storeUtils.d.ts.map

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

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

@@ -163,2 +163,5 @@ 'overcome this limitation.');

function getTypenameFromResult(result, selectionSet, fragmentMap) {
if (typeof result.__typename === 'string') {
return result.__typename;
}
for (var _i = 0, _a = selectionSet.selections; _i < _a.length; _i++) {

@@ -178,5 +181,2 @@ var selection = _a[_i];

}
if (typeof result.__typename === 'string') {
return result.__typename;
}
}

@@ -183,0 +183,0 @@ function isField(selection) {

@@ -21,3 +21,2 @@ import { DocumentNode, DirectiveNode, FragmentDefinitionNode, ArgumentNode, FragmentSpreadNode, VariableDefinitionNode } from 'graphql';

export declare function removeConnectionDirectiveFromDocument(doc: DocumentNode): DocumentNode;
export declare function getDirectivesFromDocument(directives: GetDirectiveConfig[], doc: DocumentNode): DocumentNode;
export declare function removeArgumentsFromDocument(config: RemoveArgumentsConfig[], doc: DocumentNode): DocumentNode;

@@ -24,0 +23,0 @@ export declare function removeFragmentSpreadFromDocument(config: RemoveFragmentSpreadConfig[], doc: DocumentNode): DocumentNode;

import { __extends } from "tslib";
import { print } from 'graphql/language/printer';
import stringify from 'fast-json-stable-stringify';
import { equal } from '@wry/equality';
import { Observable } from '../../../utilities/observables/Observable';

@@ -8,3 +9,2 @@ import { ApolloLink } from '../../../link/core/ApolloLink';

import { cloneDeep } from '../../../utilities/common/cloneDeep';
import { isEqual } from '../../../utilities/common/isEqual';
function requestToKey(request, addTypename) {

@@ -48,3 +48,3 @@ var queryString = request.query &&

var mockedResponseVariables = res.request.variables || {};
if (!isEqual(stringify(requestVariables), stringify(mockedResponseVariables))) {
if (!equal(stringify(requestVariables), stringify(mockedResponseVariables))) {
return false;

@@ -51,0 +51,0 @@ }

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 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

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

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