You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

@apollo/client

Package Overview
Dependencies
Maintainers
1
Versions
559
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.0-beta.36 to 3.0.0-beta.37

1

cache/core/cache.d.ts

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

modify(dataId: string, modifiers: Modifier<any> | Modifiers, optimistic?: boolean): boolean;
gc(): string[];
transformForLink(document: DocumentNode): DocumentNode;

@@ -24,0 +25,0 @@ readQuery<QueryType, TVariables = any>(options: DataProxy.Query<TVariables>, optimistic?: boolean): QueryType | null;

@@ -35,2 +35,5 @@ import { getFragmentQueryDocument } from '../../utilities/graphql/fragments.js';

};
ApolloCache.prototype.gc = function () {
return [];
};
ApolloCache.prototype.transformForLink = function (document) {

@@ -37,0 +40,0 @@ return document;

5

cache/core/types/common.d.ts

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

import { SelectionSetNode } from 'graphql';
import { isReference, StoreValue, StoreObject, Reference } from '../../../utilities/graphql/storeUtils';
import { FragmentMap } from '../../../utilities/graphql/fragments';
import { ToReferenceFunction } from '../../inmemory/entityStore';
export declare type SafeReadonly<T> = T extends object ? Readonly<T> : T;

@@ -10,3 +9,3 @@ export declare type Modifier<T> = (value: T, details: {

isReference: typeof isReference;
toReference(object: StoreObject, selectionSet?: SelectionSetNode, fragmentMap?: FragmentMap): Reference;
toReference: ToReferenceFunction;
readField<V = StoreValue>(fieldName: string, objOrRef?: StoreObject | Reference): SafeReadonly<V>;

@@ -13,0 +12,0 @@ }) => T;

@@ -5,5 +5,5 @@ export { Transaction, ApolloCache } from './core/cache';

export { Reference, isReference, makeReference, } from '../utilities/graphql/storeUtils';
export { InMemoryCache, InMemoryCacheConfig, LocalVar, } from './inmemory/inMemoryCache';
export { InMemoryCache, InMemoryCacheConfig, ReactiveVar, } from './inmemory/inMemoryCache';
export { defaultDataIdFromObject, TypePolicies, TypePolicy, FieldPolicy, FieldReadFunction, FieldMergeFunction, FieldFunctionOptions, PossibleTypesMap, } from './inmemory/policies';
export * from './inmemory/types';
//# sourceMappingURL=index.d.ts.map

@@ -32,3 +32,5 @@ import { KeyTrie } from 'optimism';

getFieldValue: <T = StoreValue>(objectOrReference: Reference | StoreObject, storeFieldName: string) => SafeReadonly<T>;
toReference: (object: StoreObject, mergeIntoStore?: boolean) => Reference;
}
export declare type ToReferenceFunction = EntityStore["toReference"];
export declare type FieldValueGetter = EntityStore["getFieldValue"];

@@ -35,0 +37,0 @@ declare class CacheGroup {

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

import { fieldNameFromStoreName } from './helpers.js';
import { Policies } from './policies.js';
import './policies.js';

@@ -26,2 +26,10 @@ var hasOwn = Object.prototype.hasOwnProperty;

: objectOrReference && objectOrReference[storeFieldName]); };
this.toReference = function (object, mergeIntoStore) {
var id = _this.policies.identify(object);
var ref = id && makeReference(id);
if (ref && mergeIntoStore) {
_this.merge(id, object);
}
return ref;
};
}

@@ -102,3 +110,3 @@ EntityStore.prototype.toObject = function () {

isReference: isReference,
toReference: _this.policies.toReference,
toReference: _this.toReference,
readField: readField_1,

@@ -324,11 +332,4 @@ });

}
function defaultNormalizedCacheFactory(seed) {
return new EntityStore.Root({
policies: new Policies,
resultCaching: true,
seed: seed,
});
}
export { EntityStore, defaultNormalizedCacheFactory, supportsResultCaching };
export { EntityStore, supportsResultCaching };
//# sourceMappingURL=entityStore.js.map

@@ -24,3 +24,2 @@ import './fixPolyfills';

readonly policies: Policies;
private silenceBroadcast;
constructor(config?: InMemoryCacheConfig);

@@ -41,3 +40,4 @@ restore(data: NormalizedCacheObject): this;

removeOptimistic(idToRemove: string): void;
performTransaction(transaction: (proxy: InMemoryCache) => any, optimisticId?: string): void;
private txCount;
performTransaction(transaction: (cache: InMemoryCache) => any, optimisticId?: string): void;
recordOptimisticTransaction(transaction: Transaction<NormalizedCacheObject>, id: string): void;

@@ -47,5 +47,6 @@ transformDocument(document: DocumentNode): DocumentNode;

private maybeBroadcastWatch;
makeLocalVar<T>(value?: T): LocalVar<T>;
private varDep;
makeVar<T>(value?: T): ReactiveVar<T>;
}
export declare type LocalVar<T> = (newValue?: T) => T;
export declare type ReactiveVar<T> = (newValue?: T) => T;
//# sourceMappingURL=inMemoryCache.d.ts.map
import { __extends, __assign } from 'tslib';
import { addTypenameToDocument } from '../../utilities/graphql/transform.js';
import { wrap, dep } from 'optimism';
import { dep, wrap } from 'optimism';
import { ApolloCache } from '../core/cache.js';

@@ -23,3 +23,4 @@ import { Policies, defaultDataIdFromObject } from './policies.js';

_this.typenameDocumentCache = new Map();
_this.silenceBroadcast = false;
_this.txCount = 0;
_this.varDep = dep();
_this.config = __assign(__assign({}, defaultConfig), config);

@@ -154,8 +155,15 @@ _this.addTypename = !!_this.config.addTypename;

var perform = function (layer) {
var proxy = Object.create(_this);
proxy.silenceBroadcast = true;
var _a = _this, data = _a.data, optimisticData = _a.optimisticData;
++_this.txCount;
if (layer) {
proxy.data = proxy.optimisticData = layer;
_this.data = _this.optimisticData = layer;
}
return transaction(proxy);
try {
transaction(_this);
}
finally {
--_this.txCount;
_this.data = data;
_this.optimisticData = optimisticData;
}
};

@@ -187,3 +195,3 @@ if (typeof optimisticId === 'string') {

var _this = this;
if (!this.silenceBroadcast) {
if (!this.txCount) {
this.watches.forEach(function (c) { return _this.maybeBroadcastWatch(c); });

@@ -199,12 +207,14 @@ }

};
InMemoryCache.prototype.makeLocalVar = function (value) {
return function LocalVar(newValue) {
InMemoryCache.prototype.makeVar = function (value) {
var cache = this;
return function rv(newValue) {
if (arguments.length > 0) {
if (value !== newValue) {
value = newValue;
localVarDep.dirty(LocalVar);
cache.varDep.dirty(rv);
cache.broadcastWatches();
}
}
else {
localVarDep(LocalVar);
cache.varDep(rv);
}

@@ -216,5 +226,4 @@ return value;

}(ApolloCache));
var localVarDep = dep();
export { InMemoryCache };
//# sourceMappingURL=inMemoryCache.js.map

@@ -6,3 +6,3 @@ import { InlineFragmentNode, FragmentDefinitionNode, SelectionSetNode, FieldNode } from "graphql";

import { FieldValueToBeMerged } from './helpers';
import { FieldValueGetter } from './entityStore';
import { FieldValueGetter, ToReferenceFunction } from './entityStore';
import { SafeReadonly } from '../core/types/common';

@@ -49,3 +49,3 @@ export declare type TypePolicies = {

isReference: typeof isReference;
toReference: Policies["toReference"];
toReference: ToReferenceFunction;
readField<T = StoreValue>(nameOrField: string | FieldNode, foreignObjOrRef?: StoreObject | Reference): SafeReadonly<T>;

@@ -72,3 +72,2 @@ storage: StorageType;

});
toReference: (object: StoreObject, selectionSet?: SelectionSetNode, fragmentMap?: FragmentMap) => Reference;
identify(object: StoreObject, selectionSet?: SelectionSetNode, fragmentMap?: FragmentMap): string | null;

@@ -84,7 +83,12 @@ addTypePolicies(typePolicies: TypePolicies): void;

private storageTrie;
readField<V = StoreValue>(objectOrReference: StoreObject | Reference, nameOrField: string | FieldNode, getFieldValue: FieldValueGetter, variables?: Record<string, any>, typename?: string): SafeReadonly<V>;
readField<V = StoreValue>(objectOrReference: StoreObject | Reference, nameOrField: string | FieldNode, context: ReadMergeContext, typename?: string): SafeReadonly<V>;
hasMergeFunction(typename: string, fieldName: string): boolean;
applyMerges<T extends StoreValue>(existing: T | Reference, incoming: T | FieldValueToBeMerged, getFieldValue: FieldValueGetter, variables: Record<string, any>, storageKeys?: [string | StoreObject, string]): T;
applyMerges<T extends StoreValue>(existing: T | Reference, incoming: T | FieldValueToBeMerged, context: ReadMergeContext, storageKeys?: [string | StoreObject, string]): T;
}
export interface ReadMergeContext {
variables: Record<string, any>;
toReference: ToReferenceFunction;
getFieldValue: FieldValueGetter;
}
export {};
//# sourceMappingURL=policies.d.ts.map
import { __assign } from 'tslib';
import { invariant, InvariantError } from 'ts-invariant';
import { getFragmentFromSelection } from '../../utilities/graphql/fragments.js';
import { makeReference, getTypenameFromResult, argumentsObjectFromField, storeKeyNameFromField, isReference, isField } from '../../utilities/graphql/storeUtils.js';
import { getTypenameFromResult, argumentsObjectFromField, storeKeyNameFromField, isReference, isField } from '../../utilities/graphql/storeUtils.js';
import { canUseWeakMap } from '../../utilities/common/canUse.js';

@@ -24,3 +24,2 @@ import { KeyTrie } from 'optimism';

function Policies(config) {
var _this = this;
if (config === void 0) { config = {}; }

@@ -32,6 +31,2 @@ this.config = config;

this.usingPossibleTypes = false;
this.toReference = function (object, selectionSet, fragmentMap) {
var id = _this.identify(object, selectionSet, fragmentMap);
return id && makeReference(id);
};
this.storageTrie = new KeyTrie(true);

@@ -121,3 +116,3 @@ this.config = __assign({ dataIdFromObject: defaultDataIdFromObject }, config);

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

@@ -208,10 +203,10 @@ this.rootTypenamesById[rootId] = typename;

};
Policies.prototype.readField = function (objectOrReference, nameOrField, getFieldValue, variables, typename) {
if (typename === void 0) { typename = getFieldValue(objectOrReference, "__typename"); }
process.env.NODE_ENV === "production" ? invariant(objectOrReference, 39) : invariant(objectOrReference, "Must provide an object or Reference when calling Policies#readField");
Policies.prototype.readField = function (objectOrReference, nameOrField, context, typename) {
if (typename === void 0) { typename = context.getFieldValue(objectOrReference, "__typename"); }
process.env.NODE_ENV === "production" ? invariant(objectOrReference, 38) : invariant(objectOrReference, "Must provide an object or Reference when calling Policies#readField");
var policies = this;
var storeFieldName = typeof nameOrField === "string" ? nameOrField
: policies.getStoreFieldName(typename, nameOrField, variables);
: policies.getStoreFieldName(typename, nameOrField, context.variables);
var fieldName = fieldNameFromStoreName(storeFieldName);
var existing = getFieldValue(objectOrReference, storeFieldName);
var existing = context.getFieldValue(objectOrReference, storeFieldName);
var policy = policies.getFieldPolicy(typename, fieldName, false);

@@ -223,3 +218,3 @@ var read = policy && policy.read;

: objectOrReference, storeFieldName);
return read(existing, makeFieldFunctionOptions(policies, typename, objectOrReference, nameOrField, storage, getFieldValue, variables));
return read(existing, makeFieldFunctionOptions(policies, typename, objectOrReference, nameOrField, storage, context));
}

@@ -232,3 +227,3 @@ return existing;

};
Policies.prototype.applyMerges = function (existing, incoming, getFieldValue, variables, storageKeys) {
Policies.prototype.applyMerges = function (existing, incoming, context, storageKeys) {
var policies = this;

@@ -242,3 +237,3 @@ if (isFieldValueToBeMerged(incoming)) {

: null;
incoming = merge(existing, incoming.__value, makeFieldFunctionOptions(policies, incoming.__typename, null, field, storage, getFieldValue, variables));
incoming = merge(existing, incoming.__value, makeFieldFunctionOptions(policies, incoming.__typename, null, field, storage, context));
}

@@ -250,3 +245,3 @@ if (incoming && typeof incoming === "object") {

if (Array.isArray(incoming)) {
return incoming.map(function (item) { return policies.applyMerges(void 0, item, getFieldValue, variables); });
return incoming.map(function (item) { return policies.applyMerges(void 0, item, context); });
}

@@ -259,3 +254,3 @@ var e_1 = existing;

Object.keys(i_1).forEach(function (storeFieldName) {
i_1[storeFieldName] = policies.applyMerges(getFieldValue(e_1, storeFieldName), i_1[storeFieldName], getFieldValue, variables, firstStorageKey_1 && [firstStorageKey_1, storeFieldName]);
i_1[storeFieldName] = policies.applyMerges(context.getFieldValue(e_1, storeFieldName), i_1[storeFieldName], context, firstStorageKey_1 && [firstStorageKey_1, storeFieldName]);
});

@@ -267,3 +262,4 @@ }

}());
function makeFieldFunctionOptions(policies, typename, objectOrReference, nameOrField, storage, getFieldValue, variables) {
function makeFieldFunctionOptions(policies, typename, objectOrReference, nameOrField, storage, context) {
var toReference = context.toReference, getFieldValue = context.getFieldValue, variables = context.variables;
var storeFieldName = typeof nameOrField === "string" ? nameOrField :

@@ -281,10 +277,10 @@ policies.getStoreFieldName(typename, nameOrField, variables);

isReference: isReference,
toReference: policies.toReference,
toReference: toReference,
storage: storage,
readField: function (nameOrField, foreignObjOrRef) {
return policies.readField(foreignObjOrRef || objectOrReference, nameOrField, getFieldValue, variables);
return policies.readField(foreignObjOrRef || objectOrReference, nameOrField, context);
},
mergeObjects: function (existing, incoming) {
if (Array.isArray(existing) || Array.isArray(incoming)) {
throw process.env.NODE_ENV === "production" ? new InvariantError(40) : new InvariantError("Cannot automatically merge arrays");
throw process.env.NODE_ENV === "production" ? new InvariantError(39) : new InvariantError("Cannot automatically merge arrays");
}

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

var typesDiffer = eType && iType && eType !== iType;
var applied = policies.applyMerges(typesDiffer ? void 0 : existing, incoming, getFieldValue, variables);
var applied = policies.applyMerges(typesDiffer ? void 0 : existing, incoming, context);
if (typesDiffer ||

@@ -376,3 +372,3 @@ !canBeMerged(existing) ||

var responseName = aliases && aliases[s] || s;
process.env.NODE_ENV === "production" ? invariant(hasOwn.call(response, responseName), 41) : 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];

@@ -379,0 +375,0 @@ }

@@ -60,2 +60,4 @@ import { __assign } from 'tslib';

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

@@ -80,3 +82,3 @@ });

result: {},
missing: [process.env.NODE_ENV === "production" ? new InvariantError(52) : new InvariantError("Dangling reference to missing " + objectOrReference.__ref + " object")],
missing: [process.env.NODE_ENV === "production" ? new InvariantError(51) : new InvariantError("Dangling reference to missing " + objectOrReference.__ref + " object")],
};

@@ -108,6 +110,6 @@ }

if (isField(selection)) {
var fieldValue = policies.readField(objectOrReference, selection, store.getFieldValue, variables, typename);
var fieldValue = policies.readField(objectOrReference, selection, context);
if (fieldValue === void 0) {
if (!addTypenameToDocument.added(selection)) {
getMissing().push(process.env.NODE_ENV === "production" ? new InvariantError(53) : new InvariantError("Can't find field " + selection.name.value + " on " + (isReference(objectOrReference)
getMissing().push(process.env.NODE_ENV === "production" ? new InvariantError(52) : new InvariantError("Can't find field " + selection.name.value + " on " + (isReference(objectOrReference)
? objectOrReference.__ref + " object"

@@ -149,3 +151,3 @@ : "object " + JSON.stringify(objectOrReference, null, 2))));

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], 53) : invariant(fragment = fragmentMap[selection.name.value], "No fragment named " + selection.name.value);
}

@@ -209,3 +211,3 @@ if (policies.fragmentMatches(fragment, typename)) {

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), 54) : 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);

@@ -212,0 +214,0 @@ }

@@ -5,4 +5,4 @@ import { DocumentNode } from 'graphql';

import { StoreValue, StoreObject } from '../../utilities/graphql/storeUtils';
import { FieldValueGetter } from './entityStore';
export { StoreValue };
import { FieldValueGetter, ToReferenceFunction } from './entityStore';
export { StoreObject, StoreValue };
export interface IdGetterObj extends Object {

@@ -26,2 +26,3 @@ __typename?: string;

getFieldValue: FieldValueGetter;
toReference: ToReferenceFunction;
}

@@ -28,0 +29,0 @@ export interface NormalizedCacheObject {

import { SelectionSetNode, DocumentNode } from 'graphql';
import { FragmentMap } from '../../utilities/graphql/fragments';
import { Policies } from './policies';
import { Policies, ReadMergeContext } from './policies';
import { NormalizedCache } from './types';
export declare type WriteContext = {
export interface WriteContext extends ReadMergeContext {
readonly store: NormalizedCache;

@@ -10,6 +10,5 @@ readonly written: {

};
readonly variables?: any;
readonly fragmentMap?: FragmentMap;
merge<T>(existing: T, incoming: T): T;
};
}
export interface StoreWriterConfig {

@@ -16,0 +15,0 @@ policies: Policies;

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

import { makeProcessedFieldsMerger } from './helpers.js';
import { defaultNormalizedCacheFactory } from './entityStore.js';
import { EntityStore } from './entityStore.js';

@@ -17,3 +17,5 @@ var StoreWriter = (function () {

StoreWriter.prototype.writeQueryToStore = function (_a) {
var query = _a.query, result = _a.result, _b = _a.dataId, dataId = _b === void 0 ? 'ROOT_QUERY' : _b, _c = _a.store, store = _c === void 0 ? defaultNormalizedCacheFactory() : _c, variables = _a.variables;
var query = _a.query, result = _a.result, _b = _a.dataId, dataId = _b === void 0 ? 'ROOT_QUERY' : _b, _c = _a.store, store = _c === void 0 ? new EntityStore.Root({
policies: this.policies,
}) : _c, variables = _a.variables;
var operationDefinition = getOperationDefinition(query);

@@ -34,2 +36,4 @@ store.retain(dataId);

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

@@ -57,3 +61,3 @@ });

if (out.shouldApplyMerges) {
processed = policies.applyMerges(makeReference(dataId), processed, store.getFieldValue, context.variables);
processed = policies.applyMerges(makeReference(dataId), processed, context);
}

@@ -60,0 +64,0 @@ store.merge(dataId, processed);

import { ExecutionResult, DocumentNode, FieldNode, ASTNode } from 'graphql';
import { ApolloCache } from '../cache/core/cache';
import { FragmentMap } from '../utilities/graphql/fragments';
import { StoreObject } from '../utilities/graphql/storeUtils';
import { ApolloClient } from '../ApolloClient';

@@ -49,8 +50,5 @@ import { Resolvers, OperationVariables } from './types';

serverQuery(document: DocumentNode): DocumentNode;
prepareContext(context?: {}): {
prepareContext(context?: Record<string, any>): {
cache: ApolloCache<TCacheShape>;
getCacheKey: (obj: {
__typename: string;
id: string | number;
}) => any;
getCacheKey(obj: StoreObject): string;
};

@@ -57,0 +55,0 @@ addExportedVariables(document: DocumentNode, variables?: OperationVariables, context?: {}): Promise<{

@@ -77,14 +77,7 @@ import { __awaiter, __generator, __assign } from 'tslib';

LocalState.prototype.prepareContext = function (context) {
if (context === void 0) { context = {}; }
var cache = this.cache;
var newContext = __assign(__assign({}, context), { cache: cache, getCacheKey: function (obj) {
if (cache.config) {
return cache.config.dataIdFromObject(obj);
}
else {
process.env.NODE_ENV === "production" ? invariant(false, 26) : invariant(false, 'To use context.getCacheKey, you need to use a cache that has ' +
'a configurable dataIdFromObject, like apollo-cache-inmemory.');
}
return __assign(__assign({}, context), { cache: cache,
getCacheKey: function (obj) {
return cache.identify(obj);
} });
return newContext;
};

@@ -194,3 +187,3 @@ LocalState.prototype.addExportedVariables = function (document, variables, context) {

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

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

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

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

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

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

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

{
"name": "@apollo/client",
"version": "3.0.0-beta.36",
"version": "3.0.0-beta.37",
"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, 50) : 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, 51) : 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 @@ };

@@ -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, 43) : invariant(evaledValue !== void 0, "Invalid variable referenced in @" + directive.name.value + " directive.");
process.env.NODE_ENV === "production" ? invariant(evaledValue !== void 0, 42) : 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, 44) : invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @" + directiveName + " directive.");
process.env.NODE_ENV === "production" ? invariant(directiveArguments && directiveArguments.length === 1, 43) : 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', 45) : 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', 44) : 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'), 46) : invariant(ifValue &&
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 45) : 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(47) : 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, 48) : 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, 49) : 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 @@ }

@@ -1,8 +0,6 @@

import { __spreadArrays } from 'tslib';
import { invariant, InvariantError } from 'ts-invariant';
import { assign } from '../common/assign.js';
import { valueToObjectRepresentation } from './storeUtils.js';
function checkDocument(doc) {
process.env.NODE_ENV === "production" ? invariant(doc && doc.kind === 'Document', 28) : 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', 27) : 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

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

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

@@ -36,10 +34,10 @@ }

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

@@ -67,22 +65,15 @@ }

}
throw process.env.NODE_ENV === "production" ? new InvariantError(35) : new InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.');
throw process.env.NODE_ENV === "production" ? new InvariantError(34) : new InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.');
}
function getDefaultValues(definition) {
if (definition &&
definition.variableDefinitions &&
definition.variableDefinitions.length) {
var defaultValues = definition.variableDefinitions
.filter(function (_a) {
var defaultValue = _a.defaultValue;
return defaultValue;
})
.map(function (_a) {
var variable = _a.variable, defaultValue = _a.defaultValue;
var defaultValueObj = {};
valueToObjectRepresentation(defaultValueObj, variable.name, defaultValue);
return defaultValueObj;
var defaultValues = Object.create(null);
var defs = definition && definition.variableDefinitions;
if (defs && defs.length) {
defs.forEach(function (def) {
if (def.defaultValue) {
valueToObjectRepresentation(defaultValues, def.variable.name, def.defaultValue);
}
});
return assign.apply(void 0, __spreadArrays([{}], defaultValues));
}
return {};
return defaultValues;
}

@@ -89,0 +80,0 @@

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

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

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

evaledValue = variables && variables[ifArgument.value.name.value];
process.env.NODE_ENV === "production" ? tsInvariant.invariant(evaledValue !== void 0, 43) : tsInvariant.invariant(evaledValue !== void 0, "Invalid variable referenced in @" + directive.name.value + " directive.");
process.env.NODE_ENV === "production" ? tsInvariant.invariant(evaledValue !== void 0, 42) : 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, 44) : 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, 43) : 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', 45) : 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', 44) : 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'), 46) : tsInvariant.invariant(ifValue &&
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 45) : 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(47) : 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.');

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

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

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

var fragment = fragmentMap && fragmentMap[selection.name.value];
process.env.NODE_ENV === "production" ? tsInvariant.invariant(fragment, 49) : 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;

@@ -135,18 +135,2 @@ }

function assign(target) {
var sources = [];
for (var _i = 1; _i < arguments.length; _i++) {
sources[_i - 1] = arguments[_i];
}
sources.forEach(function (source) {
if (typeof source === 'undefined' || source === null) {
return;
}
Object.keys(source).forEach(function (key) {
target[key] = source[key];
});
});
return target;
}
function makeReference(id) {

@@ -217,3 +201,3 @@ return { __ref: String(id) };

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

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

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

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

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

@@ -366,10 +350,10 @@ }

var queryDef = getOperationDefinition(doc);
process.env.NODE_ENV === "production" ? tsInvariant.invariant(queryDef && queryDef.operation === 'query', 31) : tsInvariant.invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.');
process.env.NODE_ENV === "production" ? tsInvariant.invariant(queryDef && queryDef.operation === 'query', 30) : 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', 32) : 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, 33) : tsInvariant.invariant(doc.definitions.length <= 1, 'Fragment must have exactly one definition.');
process.env.NODE_ENV === "production" ? tsInvariant.invariant(doc.kind === 'Document', 31) : 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, 32) : 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', 34) : tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.');
process.env.NODE_ENV === "production" ? tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition', 33) : tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.');
return fragmentDef;

@@ -397,22 +381,15 @@ }

}
throw process.env.NODE_ENV === "production" ? new tsInvariant.InvariantError(35) : 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(34) : new tsInvariant.InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.');
}
function getDefaultValues(definition) {
if (definition &&
definition.variableDefinitions &&
definition.variableDefinitions.length) {
var defaultValues = definition.variableDefinitions
.filter(function (_a) {
var defaultValue = _a.defaultValue;
return defaultValue;
})
.map(function (_a) {
var variable = _a.variable, defaultValue = _a.defaultValue;
var defaultValueObj = {};
valueToObjectRepresentation(defaultValueObj, variable.name, defaultValue);
return defaultValueObj;
var defaultValues = Object.create(null);
var defs = definition && definition.variableDefinitions;
if (defs && defs.length) {
defs.forEach(function (def) {
if (def.defaultValue) {
valueToObjectRepresentation(defaultValues, def.variable.name, def.defaultValue);
}
});
return assign.apply(void 0, tslib.__spreadArrays([{}], defaultValues));
}
return {};
return defaultValues;
}

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc