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.32 to 3.0.0-beta.33

2

cache/index.d.ts

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

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

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

get(dataId: string, fieldName: string): StoreValue;
private lookup;
protected lookup(dataId: string, dependOnExistence?: boolean): StoreObject;
merge(dataId: string, incoming: StoreObject): void;

@@ -15,0 +15,0 @@ delete(dataId: string, fieldName?: string): boolean;

import { __assign, __extends } from 'tslib';
import { invariant } from 'ts-invariant';
import { isReference } from '../../utilities/graphql/storeUtils.js';

@@ -8,3 +7,3 @@ import { canUseWeakMap } from '../../utilities/common/canUse.js';

import { KeyTrie, dep } from 'optimism';
import { fieldNameFromStoreName, getTypenameFromStoreObject } from './helpers.js';
import { fieldNameFromStoreName } from './helpers.js';

@@ -45,14 +44,16 @@ var hasOwn = Object.prototype.hasOwnProperty;

var existing = this.lookup(dataId);
var merged = new DeepMerger(storeObjectReconciler).merge(existing, incoming, this);
var merged = new DeepMerger(storeObjectReconciler).merge(existing, incoming);
this.data[dataId] = merged;
if (merged !== existing) {
this.data[dataId] = merged;
delete this.refs[dataId];
if (this.group.caching) {
var fieldsToDirty_1 = Object.create(null);
if (!existing)
this.group.dirty(dataId, "__exists");
fieldsToDirty_1.__exists = 1;
Object.keys(incoming).forEach(function (storeFieldName) {
if (!existing || incoming[storeFieldName] !== existing[storeFieldName]) {
_this.group.dirty(dataId, storeFieldName);
if (!existing || existing[storeFieldName] !== merged[storeFieldName]) {
fieldsToDirty_1[fieldNameFromStoreName(storeFieldName)] = 1;
}
});
Object.keys(fieldsToDirty_1).forEach(function (fieldName) { return _this.group.dirty(dataId, fieldName); });
}

@@ -79,3 +80,3 @@ }

delete this.refs[dataId];
var fieldsToDirty_1 = new Set();
var fieldsToDirty_2 = new Set();
if (fieldName) {

@@ -86,3 +87,3 @@ var cleaned_1 = this.data[dataId] = __assign({}, storeObject);

});
fieldsToDirty_1.add(fieldName);
fieldsToDirty_2.add(fieldName);
}

@@ -92,8 +93,8 @@ else {

storeNamesToDelete.forEach(function (storeFieldName) {
fieldsToDirty_1.add(fieldNameFromStoreName(storeFieldName));
fieldsToDirty_2.add(fieldNameFromStoreName(storeFieldName));
});
fieldsToDirty_1.add("__exists");
fieldsToDirty_2.add("__exists");
}
if (this.group.caching) {
fieldsToDirty_1.forEach(function (fieldName) {
fieldsToDirty_2.forEach(function (fieldName) {
_this.group.dirty(dataId, fieldName);

@@ -108,3 +109,6 @@ });

EntityStore.prototype.evict = function (dataId, fieldName) {
var evicted = this.delete(dataId, fieldName);
var evicted = false;
if (hasOwn.call(this.data, dataId)) {
evicted = this.delete(dataId, fieldName);
}
if (this instanceof Layer) {

@@ -261,3 +265,7 @@ evicted = this.parent.evict(dataId, fieldName) || evicted;

if (this.group.caching) {
Object.keys(this.data).forEach(function (dataId) { return _this.delete(dataId); });
Object.keys(this.data).forEach(function (dataId) {
if (_this.data[dataId] !== parent.lookup(dataId)) {
_this.delete(dataId);
}
});
}

@@ -279,22 +287,7 @@ return parent;

}(EntityStore));
var storeObjectReconciler = function (existingObject, incomingObject, property, store) {
var existing = existingObject[property];
var incoming = incomingObject[property];
if (existing !== incoming &&
this.isObject(existing) &&
this.isObject(incoming)) {
var eType = getTypenameFromStoreObject(store, existing);
var iType = getTypenameFromStoreObject(store, incoming);
if (typeof eType === 'string' &&
typeof iType === 'string' &&
eType !== iType) {
return incoming;
}
process.env.NODE_ENV === "production" ? invariant(!isReference(existing) || isReference(incoming), 56) : invariant(!isReference(existing) || isReference(incoming), "Store error: the application attempted to write an object with no provided id but the store already contains an id of " + existing.__ref + " for this object.");
if (equal(existing, incoming)) {
return existing;
}
}
return incoming;
};
function storeObjectReconciler(existingObject, incomingObject, property) {
var existingValue = existingObject[property];
var incomingValue = incomingObject[property];
return equal(existingValue, incomingValue) ? existingValue : incomingValue;
}
function supportsResultCaching(store) {

@@ -301,0 +294,0 @@ return !!(store instanceof EntityStore && store.group.caching);

@@ -25,7 +25,9 @@ import { InlineFragmentNode, FragmentDefinitionNode, SelectionSetNode, FieldNode } from "graphql";

};
declare type KeyArgsFunction = (field: FieldNode, context: {
declare type KeyArgsFunction = (args: Record<string, any>, context: {
typename: string;
fieldName: string;
field: FieldNode;
variables: Record<string, any>;
policies: Policies;
}) => ReturnType<IdGetter>;
}) => KeySpecifier | ReturnType<IdGetter>;
declare type SafeReadonly<T> = T extends object ? Readonly<T> : T;

@@ -39,7 +41,7 @@ export declare type FieldPolicy<TExisting = any, TIncoming = TExisting, TReadResult = TExisting> = {

declare type StorageType = Record<string, any>;
interface FieldFunctionOptions {
args: Record<string, any> | null;
export interface FieldFunctionOptions<TArgs = Record<string, any>, TVars = Record<string, any>> {
args: TArgs | null;
fieldName: string;
field: FieldNode | null;
variables?: Record<string, any>;
variables?: TVars;
policies: Policies;

@@ -52,3 +54,3 @@ isReference: typeof isReference;

}
export declare type FieldReadFunction<TExisting = any, TReadResult = TExisting> = (existing: SafeReadonly<TExisting> | undefined, options: FieldFunctionOptions) => TReadResult;
export declare type FieldReadFunction<TExisting = any, TReadResult = TExisting> = (existing: SafeReadonly<TExisting> | undefined, options: FieldFunctionOptions) => TReadResult | undefined;
export declare type FieldMergeFunction<TExisting = any, TIncoming = TExisting> = (existing: SafeReadonly<TExisting> | undefined, incoming: SafeReadonly<TIncoming>, options: FieldFunctionOptions) => TExisting;

@@ -55,0 +57,0 @@ export declare function defaultDataIdFromObject(object: StoreObject): string;

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

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

var nullKeyFieldsFn = function () { return null; };
var simpleKeyArgsFn = function (field) { return field.name.value; };
var simpleKeyArgsFn = function (_args, context) { return context.fieldName; };
var Policies = (function () {

@@ -197,12 +197,17 @@ function Policies(config) {

var fieldName = field.name.value;
var policy = this.getFieldPolicy(typename, fieldName, false);
var storeFieldName;
if (typeof typename === "string") {
var policy = this.getFieldPolicy(typename, fieldName, false);
var keyFn = policy && policy.keyFn;
if (keyFn) {
storeFieldName = keyFn(field, {
typename: typename,
variables: variables,
policies: this,
}) || fieldName;
var keyFn = policy && policy.keyFn;
if (keyFn) {
var args = argumentsObjectFromField(field, variables);
var context = { typename: typename, fieldName: fieldName, field: field, variables: variables, policies: this };
while (keyFn) {
var specifierOrString = keyFn(args, context);
if (Array.isArray(specifierOrString)) {
keyFn = keyArgsFnFromSpecifier(specifierOrString);
}
else {
storeFieldName = specifierOrString || fieldName;
break;
}
}

@@ -313,20 +318,6 @@ }

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

@@ -333,0 +324,0 @@ }

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

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

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

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

catch (e) {
var parseError = process.env.NODE_ENV === "production" ? new InvariantError(14) : new InvariantError("Network request failed. " + label + " is not serializable: " + e.message);
var parseError = process.env.NODE_ENV === "production" ? new InvariantError(13) : 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.32",
"version": "3.0.0-beta.33",
"description": "A fully-featured caching GraphQL client.",

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

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

return React.createElement(ApolloContext.Consumer, null, function (context) {
process.env.NODE_ENV === "production" ? invariant(context && context.client, 6) : invariant(context && context.client, 'Could not find "client" in the context of ApolloConsumer. ' +
process.env.NODE_ENV === "production" ? invariant(context && context.client, 5) : 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, 7) : 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, 7) : invariant(client, 'No Apollo Client instance can be found. Please ensure that you ' +
process.env.NODE_ENV === "production" ? invariant(client, 6) : 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;

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 too big to display

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