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

@apollo/client

Package Overview
Dependencies
Maintainers
1
Versions
596
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@apollo/client - npm Package Compare versions

Comparing version 3.0.0-rc.2 to 3.0.0-rc.3

2

cache/core/types/common.d.ts

@@ -26,2 +26,3 @@ import { FieldNode } from 'graphql';

export declare type ToReferenceFunction = (object: StoreObject, mergeIntoStore?: boolean) => Reference | undefined;
export declare type CanReadFunction = (value: StoreValue) => boolean;
export declare type Modifier<T> = (value: T, details: {

@@ -32,2 +33,3 @@ DELETE: any;

readField: ReadFieldFunction;
canRead: CanReadFunction;
isReference: typeof isReference;

@@ -34,0 +36,0 @@ toReference: ToReferenceFunction;

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

missing?: MissingFieldError[];
optimistic?: boolean;
};

@@ -29,0 +30,0 @@ }

3

cache/inmemory/entityStore.d.ts

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

import { Cache } from '../core/types/Cache';
import { SafeReadonly, Modifier, Modifiers, ToReferenceFunction } from '../core/types/common';
import { SafeReadonly, Modifier, Modifiers, ToReferenceFunction, CanReadFunction } from '../core/types/common';
export declare abstract class EntityStore implements NormalizedCache {

@@ -34,2 +34,3 @@ readonly policies: Policies;

getFieldValue: <T = StoreValue>(objectOrReference: StoreObject | Reference, storeFieldName: string) => SafeReadonly<T>;
canRead: CanReadFunction;
toReference: ToReferenceFunction;

@@ -36,0 +37,0 @@ }

@@ -23,2 +23,7 @@ import { __assign, __extends } from 'tslib';

: objectOrReference && objectOrReference[storeFieldName]); };
this.canRead = function (objOrRef) {
return isReference(objOrRef)
? _this.has(objOrRef.__ref)
: typeof objOrRef === "object";
};
this.toReference = function (object, mergeIntoStore) {

@@ -97,2 +102,3 @@ var id = _this.policies.identify(object)[0];

} : fieldNameOrOptions, {
canRead: _this.canRead,
toReference: _this.toReference,

@@ -117,2 +123,3 @@ getFieldValue: _this.getFieldValue,

toReference: _this.toReference,
canRead: _this.canRead,
readField: readField_1,

@@ -171,3 +178,5 @@ });

}
this.group.dirty(options.id, options.fieldName || "__exists");
if (options.fieldName || evicted) {
this.group.dirty(options.id, options.fieldName || "__exists");
}
}

@@ -174,0 +183,0 @@ return evicted;

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

import { InMemoryCache } from './inMemoryCache';
import { SafeReadonly, FieldSpecifier, ToReferenceFunction, ReadFieldFunction, ReadFieldOptions } from '../core/types/common';
import { SafeReadonly, FieldSpecifier, ToReferenceFunction, ReadFieldFunction, ReadFieldOptions, CanReadFunction } from '../core/types/common';
export declare type TypePolicies = {

@@ -52,2 +52,3 @@ [__typename: string]: TypePolicy;

readField: ReadFieldFunction;
canRead: CanReadFunction;
mergeObjects<T extends StoreObject | Reference>(existing: T, incoming: T): T | undefined;

@@ -90,2 +91,3 @@ }

variables?: Record<string, any>;
canRead: CanReadFunction;
toReference: ToReferenceFunction;

@@ -92,0 +94,0 @@ getFieldValue: FieldValueGetter;

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

function makeFieldFunctionOptions(policies, objectOrReference, fieldSpec, storage, context) {
var toReference = context.toReference, getFieldValue = context.getFieldValue, variables = context.variables;
var storeFieldName = policies.getStoreFieldName(fieldSpec);
var fieldName = fieldNameFromStoreName(storeFieldName);
var variables = fieldSpec.variables || context.variables;
return {

@@ -295,5 +295,6 @@ args: argsFromFieldSpecifier(fieldSpec),

isReference: isReference,
toReference: toReference,
toReference: context.toReference,
storage: storage,
cache: policies.cache,
canRead: context.canRead,
readField: function (fieldNameOrOptions, from) {

@@ -303,4 +304,10 @@ var options = typeof fieldNameOrOptions === "string" ? {

from: from,
} : fieldNameOrOptions;
return policies.readField(options.from ? options : __assign(__assign({}, options), { from: objectOrReference }), context);
} : __assign({}, fieldNameOrOptions);
if (void 0 === options.from) {
options.from = objectOrReference;
}
if (void 0 === options.variables) {
options.variables = variables;
}
return policies.readField(options, context);
},

@@ -313,4 +320,4 @@ mergeObjects: function (existing, incoming) {

incoming && typeof incoming === "object") {
var eType = getFieldValue(existing, "__typename");
var iType = getFieldValue(incoming, "__typename");
var eType = context.getFieldValue(existing, "__typename");
var iType = context.getFieldValue(incoming, "__typename");
var typesDiffer = eType && iType && eType !== iType;

@@ -317,0 +324,0 @@ var applied = policies.applyMerges(typesDiffer ? void 0 : existing, incoming, context);

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

import { getTypenameFromStoreObject } from './helpers.js';
import { supportsResultCaching } from './entityStore.js';
import { supportsResultCaching, EntityStore } from './entityStore.js';

@@ -69,2 +69,3 @@ function missingFromInvariant(err, context) {

toReference: store.toReference,
canRead: store.canRead,
getFieldValue: store.getFieldValue,

@@ -82,2 +83,3 @@ path: [],

complete: !hasMissingFields,
optimistic: !(store instanceof EntityStore.Root),
};

@@ -103,3 +105,3 @@ };

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

@@ -141,3 +143,3 @@ }

if (!addTypenameToDocument.added(selection)) {
getMissing().push(missingFromInvariant(process.env.NODE_ENV === "production" ? new InvariantError(47) : new InvariantError("Can't find field '" + selection.name.value + "' on " + (isReference(objectOrReference)
getMissing().push(missingFromInvariant(process.env.NODE_ENV === "production" ? new InvariantError(48) : new InvariantError("Can't find field '" + selection.name.value + "' on " + (isReference(objectOrReference)
? objectOrReference.__ref + " object"

@@ -178,3 +180,3 @@ : "object " + JSON.stringify(objectOrReference, null, 2))), context));

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

@@ -242,3 +244,3 @@ if (policies.fragmentMatches(fragment, typename)) {

if (value && typeof value === "object") {
process.env.NODE_ENV === "production" ? invariant(!isReference(value), 49) : 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), 50) : 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);

@@ -245,0 +247,0 @@ }

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

import { KeyFieldsFunction } from './policies';
import { ToReferenceFunction, Modifier, Modifiers } from '../core/types/common';
import { Modifier, Modifiers, ToReferenceFunction, CanReadFunction } from '../core/types/common';
export { StoreObject, StoreValue, Reference };

@@ -28,2 +28,3 @@ export interface IdGetterObj extends Object {

toReference: ToReferenceFunction;
canRead: CanReadFunction;
}

@@ -30,0 +31,0 @@ export interface NormalizedCacheObject {

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

toReference: store.toReference,
canRead: store.canRead,
getFieldValue: store.getFieldValue,

@@ -104,3 +105,3 @@ },

!hasDirectives(["defer", "client"], selection)) {
throw process.env.NODE_ENV === "production" ? new InvariantError(50) : new InvariantError("Missing field '" + resultFieldKey + "' in " + JSON.stringify(result, null, 2).substring(0, 100));
throw process.env.NODE_ENV === "production" ? new InvariantError(46) : new InvariantError("Missing field '" + resultFieldKey + "' in " + JSON.stringify(result, null, 2).substring(0, 100));
}

@@ -107,0 +108,0 @@ }

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

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

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

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

}
if (!partial) {
if (partial) {
this.resetLastResults();
}
else {
this.updateLastResult(result);

@@ -149,3 +152,3 @@ }

if (fetchPolicy === 'cache-only') {
return Promise.reject(process.env.NODE_ENV === "production" ? new InvariantError(6) : new InvariantError('cache-only fetchPolicy option should not be used together with query refetch.'));
return Promise.reject(process.env.NODE_ENV === "production" ? new InvariantError(3) : new InvariantError('cache-only fetchPolicy option should not be used together with query refetch.'));
}

@@ -152,0 +155,0 @@ if (fetchPolicy !== 'no-cache' &&

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

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

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

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

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

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

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

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

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

}
if (diff.optimistic) {
return returnPartialData ? [
resultsFromCache(diff, queryInfo.markReady()),
] : [];
}
if (returnPartialData) {

@@ -599,0 +604,0 @@ return [

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

ApolloLink.prototype.request = function (operation, forward) {
throw process.env.NODE_ENV === "production" ? new InvariantError(13) : 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(12) : 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(11) : 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-rc.2",
"version": "3.0.0-rc.3",
"description": "A fully-featured caching GraphQL client.",

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

@@ -8,3 +8,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, 8) : invariant(context && context.client, 'Could not find "client" in the context of ApolloConsumer. ' +
'Wrap the root component in an <ApolloProvider>.');

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

@@ -13,3 +13,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, 7) : invariant(context.client, 'ApolloProvider was not passed a client instance. Make ' +
'sure you pass in your client via the "client" prop.');

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

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

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

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

@@ -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, 9) : 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), 10) : 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, 11) : 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, 12) : 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");

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

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