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.50 to 3.0.0-beta.51

6

ApolloClient.js

@@ -144,10 +144,8 @@ import { __assign } from 'tslib';

ApolloClient.prototype.writeQuery = function (options) {
var result = this.cache.writeQuery(options);
this.cache.writeQuery(options);
this.queryManager.broadcastQueries();
return result;
};
ApolloClient.prototype.writeFragment = function (options) {
var result = this.cache.writeFragment(options);
this.cache.writeFragment(options);
this.queryManager.broadcastQueries();
return result;
};

@@ -154,0 +152,0 @@ ApolloClient.prototype.__actionHookForDevTools = function (cb) {

import { DocumentNode } from 'graphql';
import { StoreObject } from '../../utilities/graphql/storeUtils';
import { StoreObject, Reference } from '../../utilities/graphql/storeUtils';
import { DataProxy } from './types/DataProxy';

@@ -8,3 +8,3 @@ import { Cache } from './types/Cache';

abstract read<T, TVariables = any>(query: Cache.ReadOptions<TVariables>): T | null;
abstract write<TResult = any, TVariables = any>(write: Cache.WriteOptions<TResult, TVariables>): void;
abstract write<TResult = any, TVariables = any>(write: Cache.WriteOptions<TResult, TVariables>): Reference | undefined;
abstract diff<T>(query: Cache.DiffOptions): Cache.DiffResult<T>;

@@ -27,5 +27,5 @@ abstract watch(watch: Cache.WatchOptions): () => void;

readFragment<FragmentType, TVariables = any>(options: DataProxy.Fragment<TVariables>, optimistic?: boolean): FragmentType | null;
writeQuery<TData = any, TVariables = any>(options: Cache.WriteQueryOptions<TData, TVariables>): void;
writeFragment<TData = any, TVariables = any>(options: Cache.WriteFragmentOptions<TData, TVariables>): void;
writeQuery<TData = any, TVariables = any>(options: Cache.WriteQueryOptions<TData, TVariables>): Reference | undefined;
writeFragment<TData = any, TVariables = any>(options: Cache.WriteFragmentOptions<TData, TVariables>): Reference | undefined;
}
//# sourceMappingURL=cache.d.ts.map

@@ -39,3 +39,3 @@ import { getFragmentQueryDocument } from '../../utilities/graphql/fragments.js';

ApolloCache.prototype.writeQuery = function (options) {
this.write({
return this.write({
dataId: options.id || 'ROOT_QUERY',

@@ -49,3 +49,3 @@ result: options.data,

ApolloCache.prototype.writeFragment = function (options) {
this.write({
return this.write({
dataId: options.id,

@@ -52,0 +52,0 @@ result: options.data,

@@ -10,3 +10,3 @@ import { DataProxy } from './DataProxy';

interface WriteOptions<TResult = any, TVariables = any> extends DataProxy.Query<TVariables> {
dataId: string;
dataId?: string;
result: TResult;

@@ -13,0 +13,0 @@ broadcast?: boolean;

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

import { DocumentNode } from 'graphql';
export declare type SafeReadonly<T> = T extends object ? Readonly<T> : T;

@@ -6,6 +5,6 @@ export declare class MissingFieldError {

readonly path: (string | number)[];
readonly query: DocumentNode;
readonly variables: Record<string, any>;
constructor(message: string, path: (string | number)[], query: DocumentNode, variables: Record<string, any>);
readonly query: import('graphql').DocumentNode;
readonly variables?: Record<string, any> | undefined;
constructor(message: string, path: (string | number)[], query: import('graphql').DocumentNode, variables?: Record<string, any> | undefined);
}
//# sourceMappingURL=common.d.ts.map

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

interface Fragment<TVariables> {
id: string;
id?: string;
fragment: DocumentNode;

@@ -13,0 +13,0 @@ fragmentName?: string;

import { KeyTrie } from 'optimism';
import { StoreValue, StoreObject, Reference } from '../../utilities/graphql/storeUtils';
import { NormalizedCache, NormalizedCacheObject } from './types';
import { NormalizedCache, NormalizedCacheObject, Modifiers, Modifier } from './types';
import { Policies } from './policies';

@@ -18,3 +18,4 @@ import { SafeReadonly } from '../core/types/common';

protected lookup(dataId: string, dependOnExistence?: boolean): StoreObject | undefined;
merge(dataId: string, incoming: StoreObject): StoreObject;
merge(dataId: string, incoming: StoreObject): void;
modify(dataId: string, modifiers: Modifier<any> | Modifiers): boolean;
delete(dataId: string, fieldName?: string, args?: Record<string, any>): boolean;

@@ -54,8 +55,7 @@ evict(options: Cache.EvictOptions): boolean;

addLayer(layerId: string, replay: (layer: EntityStore) => any): EntityStore;
removeLayer(layerId: string): Root;
removeLayer(): Root;
}
}
export declare function supportsResultCaching(store: any): store is EntityStore;
export declare function defaultNormalizedCacheFactory(seed?: NormalizedCacheObject): NormalizedCache;
export {};
//# sourceMappingURL=entityStore.d.ts.map

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

import { hasOwn, fieldNameFromStoreName } from './helpers.js';
import './policies.js';
var DELETE = Object.create(null);
var delModifier = function () { return DELETE; };
var EntityStore = (function () {

@@ -67,56 +68,92 @@ function EntityStore(policies, group) {

delete this.refs[dataId];
var fieldsToDirty_1 = Object.create(null);
if (!existing)
fieldsToDirty_1.__exists = 1;
Object.keys(incoming).forEach(function (storeFieldName) {
if (!existing || existing[storeFieldName] !== merged[storeFieldName]) {
fieldsToDirty_1[fieldNameFromStoreName(storeFieldName)] = 1;
if (merged[storeFieldName] === void 0 && !(_this instanceof Layer)) {
delete merged[storeFieldName];
if (this.group.caching) {
var fieldsToDirty_1 = Object.create(null);
if (!existing)
fieldsToDirty_1.__exists = 1;
Object.keys(incoming).forEach(function (storeFieldName) {
if (!existing || existing[storeFieldName] !== merged[storeFieldName]) {
fieldsToDirty_1[fieldNameFromStoreName(storeFieldName)] = 1;
if (merged[storeFieldName] === void 0 && !(_this instanceof Layer)) {
delete merged[storeFieldName];
}
}
}
});
Object.keys(fieldsToDirty_1).forEach(function (fieldName) { return _this.group.dirty(dataId, fieldName); });
});
Object.keys(fieldsToDirty_1).forEach(function (fieldName) { return _this.group.dirty(dataId, fieldName); });
}
}
return merged;
};
EntityStore.prototype.delete = function (dataId, fieldName, args) {
EntityStore.prototype.modify = function (dataId, modifiers) {
var _this = this;
var storeObject = this.lookup(dataId);
if (!storeObject)
return false;
var changedFields = Object.create(null);
if (fieldName && args) {
var storeFieldName = this.policies.getStoreFieldName({
typename: this.getFieldValue(storeObject, "__typename"),
fieldName: fieldName,
args: args,
});
if (storeObject[storeFieldName] !== void 0) {
changedFields[storeFieldName] = void 0;
}
}
else {
if (storeObject) {
var changedFields_1 = Object.create(null);
var needToMerge_1 = false;
var allDeleted_1 = true;
var readField_1 = function (fieldNameOrOptions, from) { return _this.policies.readField(typeof fieldNameOrOptions === "string" ? {
fieldName: fieldNameOrOptions,
from: from || makeReference(dataId),
} : fieldNameOrOptions, {
toReference: _this.toReference,
getFieldValue: _this.getFieldValue,
}); };
Object.keys(storeObject).forEach(function (storeFieldName) {
if (storeObject[storeFieldName] !== void 0 &&
(!fieldName ||
fieldName === fieldNameFromStoreName(storeFieldName))) {
changedFields[storeFieldName] = void 0;
var fieldName = fieldNameFromStoreName(storeFieldName);
var fieldValue = storeObject[storeFieldName];
if (fieldValue === void 0)
return;
var modify = typeof modifiers === "function"
? modifiers
: modifiers[storeFieldName] || modifiers[fieldName];
if (modify) {
var newValue = modify === delModifier ? DELETE :
modify(maybeDeepFreeze(fieldValue), {
DELETE: DELETE,
fieldName: fieldName,
storeFieldName: storeFieldName,
isReference: isReference,
toReference: _this.toReference,
readField: readField_1,
});
if (newValue === DELETE)
newValue = void 0;
if (newValue !== fieldValue) {
changedFields_1[storeFieldName] = newValue;
needToMerge_1 = true;
fieldValue = newValue;
}
}
if (fieldValue !== void 0) {
allDeleted_1 = false;
}
});
}
if (Object.keys(changedFields).length) {
var merged_1 = this.merge(dataId, changedFields);
if (Object.keys(merged_1).every(function (key) { return merged_1[key] === void 0; })) {
if (this instanceof Layer) {
this.data[dataId] = void 0;
if (needToMerge_1) {
this.merge(dataId, changedFields_1);
if (allDeleted_1) {
if (this instanceof Layer) {
this.data[dataId] = void 0;
}
else {
delete this.data[dataId];
}
this.group.dirty(dataId, "__exists");
}
else {
delete this.data[dataId];
}
this.group.dirty(dataId, "__exists");
return true;
}
return true;
}
return false;
};
EntityStore.prototype.delete = function (dataId, fieldName, args) {
var _a;
var storeObject = this.lookup(dataId);
if (storeObject) {
var typename = this.getFieldValue(storeObject, "__typename");
var storeFieldName = fieldName && args
? this.policies.getStoreFieldName({ typename: typename, fieldName: fieldName, args: args })
: fieldName;
return this.modify(dataId, storeFieldName ? (_a = {},
_a[storeFieldName] = delModifier,
_a) : delModifier);
}
return false;
};
EntityStore.prototype.evict = function (options) {

@@ -251,3 +288,3 @@ var evicted = false;

};
Root.prototype.removeLayer = function (layerId) {
Root.prototype.removeLayer = function () {
return this;

@@ -254,0 +291,0 @@ };

@@ -5,4 +5,4 @@ import './fixPolyfills';

import { Cache } from '../core/types/Cache';
import { StoreObject } from '../../utilities/graphql/storeUtils';
import { ApolloReducerConfig, NormalizedCacheObject } from './types';
import { StoreObject, Reference } from '../../utilities/graphql/storeUtils';
import { ApolloReducerConfig, NormalizedCacheObject, ModifyOptions } from './types';
import { PossibleTypesMap, Policies, TypePolicies } from './policies';

@@ -28,3 +28,4 @@ export interface InMemoryCacheConfig extends ApolloReducerConfig {

read<T>(options: Cache.ReadOptions): T | null;
write(options: Cache.WriteOptions): void;
write(options: Cache.WriteOptions): Reference | undefined;
modify(options: ModifyOptions): boolean;
diff<T>(options: Cache.DiffOptions): Cache.DiffResult<T>;

@@ -31,0 +32,0 @@ watch(watch: Cache.WatchOptions): () => void;

@@ -5,6 +5,7 @@ import { __extends, __assign } from 'tslib';

import { ApolloCache } from '../core/cache.js';
import { Policies, defaultDataIdFromObject } from './policies.js';
import { hasOwn } from './helpers.js';
import { EntityStore, supportsResultCaching } from './entityStore.js';
import { StoreReader } from './readFromStore.js';
import { StoreWriter } from './writeToStore.js';
import { Policies, defaultDataIdFromObject } from './policies.js';

@@ -29,2 +30,3 @@ var defaultConfig = {

_this.policies = new Policies({
cache: _this,
dataIdFromObject: _this.config.dataIdFromObject,

@@ -39,9 +41,6 @@ possibleTypes: _this.config.possibleTypes,

_this.optimisticData = _this.data;
_this.storeWriter = new StoreWriter({
policies: _this.policies,
reader: _this.storeReader = new StoreReader({
addTypename: _this.addTypename,
policies: _this.policies,
}),
});
_this.storeWriter = new StoreWriter(_this, _this.storeReader = new StoreReader({
cache: _this,
addTypename: _this.addTypename,
}));
var cache = _this;

@@ -85,13 +84,35 @@ var maybeBroadcastWatch = cache.maybeBroadcastWatch;

InMemoryCache.prototype.write = function (options) {
this.storeWriter.writeQueryToStore({
store: this.data,
query: options.query,
result: options.result,
dataId: options.dataId,
variables: options.variables,
});
if (options.broadcast !== false) {
this.broadcastWatches();
try {
++this.txCount;
return this.storeWriter.writeToStore({
store: this.data,
query: options.query,
result: options.result,
dataId: options.dataId,
variables: options.variables,
});
}
finally {
if (!--this.txCount && options.broadcast !== false) {
this.broadcastWatches();
}
}
};
InMemoryCache.prototype.modify = function (options) {
if (hasOwn.call(options, "id") && !options.id) {
return false;
}
var store = options.optimistic
? this.optimisticData
: this.data;
try {
++this.txCount;
return store.modify(options.id || "ROOT_QUERY", options.fields);
}
finally {
if (!--this.txCount && options.broadcast !== false) {
this.broadcastWatches();
}
}
};
InMemoryCache.prototype.diff = function (options) {

@@ -130,12 +151,17 @@ return this.storeReader.diffQueryAgainstStore({

InMemoryCache.prototype.evict = function (idOrOptions, fieldName, args) {
var evicted = this.optimisticData.evict(typeof idOrOptions === "string" ? {
id: idOrOptions,
fieldName: fieldName,
args: args,
} : idOrOptions);
if (typeof idOrOptions === "string" ||
idOrOptions.broadcast !== false) {
this.broadcastWatches();
try {
++this.txCount;
return this.optimisticData.evict(typeof idOrOptions === "string" ? {
id: idOrOptions,
fieldName: fieldName,
args: args,
} : idOrOptions);
}
return evicted;
finally {
if (!--this.txCount &&
(typeof idOrOptions === "string" ||
idOrOptions.broadcast !== false)) {
this.broadcastWatches();
}
}
};

@@ -142,0 +168,0 @@ InMemoryCache.prototype.reset = function () {

import { InlineFragmentNode, FragmentDefinitionNode, SelectionSetNode, FieldNode } from "graphql";
import { FragmentMap } from '../../utilities/graphql/fragments';
import { StoreValue, StoreObject, Reference, isReference } from '../../utilities/graphql/storeUtils';
import { IdGetter } from "./types";
import { IdGetter, FieldSpecifier, ReadFieldOptions, ReadFieldFunction } from "./types";
import { FieldValueToBeMerged } from './helpers';
import { FieldValueGetter, ToReferenceFunction } from './entityStore';
import { InMemoryCache } from './inMemoryCache';
import { SafeReadonly } from '../core/types/common';

@@ -39,12 +40,2 @@ export declare type TypePolicies = {

declare type StorageType = Record<string, any>;
interface FieldSpecifier {
typename?: string;
fieldName: string;
field?: FieldNode;
args?: Record<string, any>;
variables?: Record<string, any>;
}
export interface ReadFieldOptions extends FieldSpecifier {
from?: StoreObject | Reference;
}
export interface FieldFunctionOptions<TArgs = Record<string, any>, TVars = Record<string, any>> {

@@ -58,5 +49,5 @@ args: TArgs | null;

toReference: ToReferenceFunction;
readField<T = StoreValue>(options: ReadFieldOptions): SafeReadonly<T> | undefined;
readField<T = StoreValue>(fieldName: string, from?: StoreObject | Reference): SafeReadonly<T> | undefined;
storage: StorageType | null;
cache: InMemoryCache;
readField: ReadFieldFunction;
mergeObjects<T extends StoreObject | Reference>(existing: T, incoming: T): T | undefined;

@@ -73,6 +64,8 @@ }

private typePolicies;
readonly cache: InMemoryCache;
readonly rootIdsByTypename: Record<string, string>;
readonly rootTypenamesById: Record<string, string>;
readonly usingPossibleTypes = false;
constructor(config?: {
constructor(config: {
cache: InMemoryCache;
dataIdFromObject?: KeyFieldsFunction;

@@ -97,4 +90,3 @@ possibleTypes?: PossibleTypesMap;

export interface ReadMergeContext {
variables: Record<string, any>;
varString: string;
variables?: Record<string, any>;
toReference: ToReferenceFunction;

@@ -101,0 +93,0 @@ getFieldValue: FieldValueGetter;

@@ -7,5 +7,4 @@ import { __assign } from 'tslib';

import { KeyTrie } from 'optimism';
import { fieldNameFromStoreName, storeValueIsStoreObject, isFieldValueToBeMerged } from './helpers.js';
import { fieldNameFromStoreName, storeValueIsStoreObject, isFieldValueToBeMerged, hasOwn } from './helpers.js';
var hasOwn = Object.prototype.hasOwnProperty;
function argsFromFieldSpecifier(spec) {

@@ -35,3 +34,2 @@ return spec.args !== void 0 ? spec.args :

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

@@ -44,2 +42,3 @@ this.typePolicies = Object.create(null);

this.config = __assign({ dataIdFromObject: defaultDataIdFromObject }, config);
this.cache = this.config.cache;
this.setRootTypename("Query");

@@ -300,2 +299,3 @@ this.setRootTypename("Mutation");

storage: storage,
cache: policies.cache,
readField: function (fieldNameOrOptions, from) {

@@ -302,0 +302,0 @@ var options = typeof fieldNameOrOptions === "string" ? {

@@ -5,3 +5,3 @@ import { SelectionSetNode } from 'graphql';

import { DiffQueryAgainstStoreOptions, ReadQueryOptions, NormalizedCache } from './types';
import { Policies } from './policies';
import { InMemoryCache } from './inMemoryCache';
import { MissingFieldError } from '../core/types/common';

@@ -16,4 +16,4 @@ export declare type VariableMap = {

export interface StoreReaderConfig {
cache: InMemoryCache;
addTypename?: boolean;
policies: Policies;
}

@@ -20,0 +20,0 @@ export declare class StoreReader {

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

var store = _a.store, query = _a.query, _b = _a.rootId, rootId = _b === void 0 ? 'ROOT_QUERY' : _b, variables = _a.variables, _c = _a.returnPartialData, returnPartialData = _c === void 0 ? true : _c;
var policies = this.config.policies;
var policies = this.config.cache.policies;
variables = __assign(__assign({}, getDefaultValues(getQueryDefinition(query))), variables);

@@ -58,0 +58,0 @@ var execResult = this.executeSelectionSet({

@@ -1,7 +0,8 @@

import { DocumentNode } from 'graphql';
import { DocumentNode, FieldNode } from 'graphql';
import { Transaction } from '../core/cache';
import { StoreValue, StoreObject } from '../../utilities/graphql/storeUtils';
import { StoreObject, StoreValue, isReference, Reference } from '../../utilities/graphql/storeUtils';
import { FieldValueGetter, ToReferenceFunction } from './entityStore';
import { KeyFieldsFunction } from './policies';
export { StoreObject, StoreValue };
import { SafeReadonly } from '../core/types/common';
export { StoreObject, StoreValue, Reference };
export interface IdGetterObj extends Object {

@@ -16,3 +17,5 @@ __typename?: string;

get(dataId: string, fieldName: string): StoreValue;
merge(dataId: string, incoming: StoreObject): StoreObject;
merge(dataId: string, incoming: StoreObject): void;
modify(dataId: string, modifiers: Modifier<any> | Modifiers): boolean;
delete(dataId: string, fieldName?: string): boolean;
clear(): void;

@@ -59,2 +62,33 @@ toObject(): NormalizedCacheObject;

export declare type CustomResolverMap = CacheResolverMap;
export interface FieldSpecifier {
typename?: string;
fieldName: string;
field?: FieldNode;
args?: Record<string, any>;
variables?: Record<string, any>;
}
export interface ReadFieldOptions extends FieldSpecifier {
from?: StoreObject | Reference;
}
export interface ReadFieldFunction {
<V = StoreValue>(options: ReadFieldOptions): SafeReadonly<V> | undefined;
<V = StoreValue>(fieldName: string, from?: StoreObject | Reference): SafeReadonly<V> | undefined;
}
export interface ModifyOptions {
id?: string;
fields: Modifiers | Modifier<any>;
optimistic?: boolean;
broadcast?: boolean;
}
export declare type Modifier<T> = (value: T, details: {
DELETE: any;
fieldName: string;
storeFieldName: string;
isReference: typeof isReference;
toReference: ToReferenceFunction;
readField: ReadFieldFunction;
}) => T;
export declare type Modifiers = {
[fieldName: string]: Modifier<any>;
};
//# sourceMappingURL=types.d.ts.map
import { SelectionSetNode, DocumentNode } from 'graphql';
import { FragmentMap } from '../../utilities/graphql/fragments';
import { Policies, ReadMergeContext } from './policies';
import { Reference } from '../../utilities/graphql/storeUtils';
import { ReadMergeContext } from './policies';
import { NormalizedCache } from './types';
import { StoreReader } from './readFromStore';
import { InMemoryCache } from './inMemoryCache';
export interface WriteContext extends ReadMergeContext {

@@ -13,17 +15,16 @@ readonly store: NormalizedCache;

merge<T>(existing: T, incoming: T): T;
varString: string;
}
export interface StoreWriterConfig {
reader?: StoreReader;
policies: Policies;
export interface WriteToStoreOptions {
query: DocumentNode;
result: Object;
dataId?: string;
store: NormalizedCache;
variables?: Object;
}
export declare class StoreWriter {
private config;
constructor(config: StoreWriterConfig);
writeQueryToStore({ query, result, dataId, store, variables, }: {
query: DocumentNode;
result: Object;
dataId?: string;
store?: NormalizedCache;
variables?: Object;
}): NormalizedCache;
readonly cache: InMemoryCache;
private reader?;
constructor(cache: InMemoryCache, reader?: StoreReader | undefined);
writeToStore({ query, result, dataId, store, variables, }: WriteToStoreOptions): Reference | undefined;
private processSelectionSet;

@@ -30,0 +31,0 @@ private processFieldValue;

import { __assign } from 'tslib';
import { InvariantError } from 'ts-invariant';
import { createFragmentMap, getFragmentFromSelection } from '../../utilities/graphql/fragments.js';
import { getTypenameFromResult, isField, resultKeyNameFromField, makeReference } from '../../utilities/graphql/storeUtils.js';
import { isReference, makeReference, getTypenameFromResult, isField, resultKeyNameFromField } from '../../utilities/graphql/storeUtils.js';
import { getOperationDefinition, getDefaultValues, getFragmentDefinitions } from '../../utilities/graphql/getFromAST.js';

@@ -9,21 +9,17 @@ import { shouldInclude, hasDirectives } from '../../utilities/graphql/directives.js';

import { makeProcessedFieldsMerger } from './helpers.js';
import { EntityStore } from './entityStore.js';
var StoreWriter = (function () {
function StoreWriter(config) {
this.config = config;
function StoreWriter(cache, reader) {
this.cache = cache;
this.reader = reader;
}
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 ? new EntityStore.Root({
policies: this.config.policies,
}) : _c, variables = _a.variables;
StoreWriter.prototype.writeToStore = function (_a) {
var query = _a.query, result = _a.result, dataId = _a.dataId, store = _a.store, variables = _a.variables;
var operationDefinition = getOperationDefinition(query);
store.retain(dataId);
var merger = makeProcessedFieldsMerger();
variables = __assign(__assign({}, getDefaultValues(operationDefinition)), variables);
this.processSelectionSet({
var objOrRef = this.processSelectionSet({
result: result || Object.create(null),
dataId: dataId,
selectionSet: operationDefinition.selectionSet,
typename: this.config.policies.rootTypenamesById[dataId],
context: {

@@ -42,16 +38,17 @@ store: store,

});
return store;
var ref = isReference(objOrRef) ? objOrRef :
dataId && makeReference(dataId) || void 0;
if (ref) {
store.retain(ref.__ref);
}
return ref;
};
StoreWriter.prototype.processSelectionSet = function (_a) {
var _this = this;
var dataId = _a.dataId, result = _a.result, selectionSet = _a.selectionSet, context = _a.context, typename = _a.typename, _b = _a.out, out = _b === void 0 ? {
var dataId = _a.dataId, result = _a.result, selectionSet = _a.selectionSet, context = _a.context, _b = _a.out, out = _b === void 0 ? {
shouldApplyMerges: false,
} : _b;
var _c = this.config, policies = _c.policies, reader = _c.reader;
var mergedFields = Object.create(null);
var _d = policies.identify(result, selectionSet, context.fragmentMap), id = _d[0], keyObject = _d[1];
var policies = this.cache.policies;
var _c = policies.identify(result, selectionSet, context.fragmentMap), id = _c[0], keyObject = _c[1];
dataId = dataId || id;
if (keyObject) {
mergedFields = context.merge(mergedFields, keyObject);
}
if ("string" === typeof dataId) {

@@ -63,7 +60,11 @@ var sets = context.written[dataId] || (context.written[dataId] = []);

sets.push(selectionSet);
if (reader && reader.isFresh(result, context.store, ref, selectionSet, context.varString)) {
if (this.reader && this.reader.isFresh(result, context.store, ref, selectionSet, context.varString)) {
return ref;
}
}
typename = typename ||
var mergedFields = Object.create(null);
if (keyObject) {
mergedFields = context.merge(mergedFields, keyObject);
}
var typename = (dataId && policies.rootTypenamesById[dataId]) ||
getTypenameFromResult(result, selectionSet, context.fragmentMap) ||

@@ -70,0 +71,0 @@ (dataId && context.store.get(dataId, "__typename"));

import { GraphQLError } from 'graphql';
import { ServerParseError } from '../link/http/parseAndCheckHttpResponse';
import { ServerError } from '../link/utils/throwServerError';
export declare function isApolloError(err: Error): err is ApolloError;

@@ -6,7 +8,7 @@ export declare class ApolloError extends Error {

graphQLErrors: ReadonlyArray<GraphQLError>;
networkError: Error | null;
networkError: Error | ServerParseError | ServerError | null;
extraInfo: any;
constructor({ graphQLErrors, networkError, errorMessage, extraInfo, }: {
graphQLErrors?: ReadonlyArray<GraphQLError>;
networkError?: Error | null;
networkError?: Error | ServerParseError | ServerError | null;
errorMessage?: string;

@@ -13,0 +15,0 @@ extraInfo?: any;

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

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

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

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

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

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

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

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

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

{
"name": "@apollo/client",
"version": "3.0.0-beta.50",
"version": "3.0.0-beta.51",
"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, 4) : invariant(context && context.client, 'Could not find "client" in the context of ApolloConsumer. ' +
process.env.NODE_ENV === "production" ? invariant(context && context.client, 7) : 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, 8) : 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));

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

var client = React.useContext(getApolloContext()).client;
process.env.NODE_ENV === "production" ? invariant(client, 6) : invariant(client, 'No Apollo Client instance can be found. Please ensure that you ' +
process.env.NODE_ENV === "production" ? invariant(client, 9) : 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, 7) : invariant(!!document && !!document.kind, "Argument of " + document + " passed to parser was not a valid GraphQL " +
process.env.NODE_ENV === "production" ? invariant(!!document && !!document.kind, 10) : 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), 8) : invariant(!fragments.length ||
(queries.length || mutations.length || subscriptions.length), 11) : 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, 9) : 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, 12) : 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, 10) : invariant(definitions.length === 1, "react-apollo only supports one definition per HOC. " + document + " had " +
process.env.NODE_ENV === "production" ? invariant(definitions.length === 1, 13) : 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");

@@ -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, 37) : invariant(evaledValue !== void 0, "Invalid variable referenced in @" + directive.name.value + " directive.");
process.env.NODE_ENV === "production" ? invariant(evaledValue !== void 0, 40) : 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, 38) : invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @" + directiveName + " directive.");
process.env.NODE_ENV === "production" ? invariant(directiveArguments && directiveArguments.length === 1, 41) : 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', 39) : 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', 42) : 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'), 40) : invariant(ifValue &&
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 43) : 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(41) : new InvariantError("Found a " + definition.operation + " operation" + (definition.name ? " named '" + definition.name.value + "'" : '') + ". " +
throw process.env.NODE_ENV === "production" ? new InvariantError(37) : 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, 42) : 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, 38) : 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, 43) : invariant(fragment, "No fragment named " + selection.name.value + ".");
process.env.NODE_ENV === "production" ? invariant(fragment, 39) : invariant(fragment, "No fragment named " + selection.name.value + ".");
return fragment;

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

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

evaledValue = variables && variables[ifArgument.value.name.value];
process.env.NODE_ENV === "production" ? tsInvariant.invariant(evaledValue !== void 0, 37) : tsInvariant.invariant(evaledValue !== void 0, "Invalid variable referenced in @" + directive.name.value + " directive.");
process.env.NODE_ENV === "production" ? tsInvariant.invariant(evaledValue !== void 0, 40) : 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, 38) : 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, 41) : 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', 39) : 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', 42) : 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'), 40) : tsInvariant.invariant(ifValue &&
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 43) : 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(41) : new tsInvariant.InvariantError("Found a " + definition.operation + " operation" + (definition.name ? " named '" + definition.name.value + "'" : '') + ". " +
throw process.env.NODE_ENV === "production" ? new tsInvariant.InvariantError(37) : 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, 42) : 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, 38) : 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, 43) : tsInvariant.invariant(fragment, "No fragment named " + selection.name.value + ".");
process.env.NODE_ENV === "production" ? tsInvariant.invariant(fragment, 39) : tsInvariant.invariant(fragment, "No fragment named " + selection.name.value + ".");
return fragment;

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

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