Socket
Socket
Sign inDemoInstall

apollo-cache-inmemory

Package Overview
Dependencies
Maintainers
2
Versions
149
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apollo-cache-inmemory - npm Package Compare versions

Comparing version 1.1.7 to 1.1.8

6

CHANGELOG.md
# Change log
### vNEXT
- Added `getCacheKey` function to cacheResolver context [#2998](https://github.com/apollographql/apollo-client/pull/2998)
- Changed `cacheResolvers` to `cacheRedirects`, added deprecation warning [#3001](https://github.com/apollographql/apollo-client/pull/3001)
### 1.1.8
- dependency updates
- Fix IntrospectionResultData type definition [#2959](https://github.com/apollographql/apollo-client/issues/2959)
### 1.1.7

@@ -6,0 +12,0 @@ - update to latest apollo-utilities to support directives in cache

24

lib/bundle.umd.js

@@ -250,3 +250,3 @@ (function (global, factory) {

hasMissingField: false,
cacheResolvers: {},
cacheRedirects: {},
};

@@ -435,11 +435,15 @@ matches = context.fragmentMatcherFunction(idValue, fragment.typeCondition.name.value, fakeContext);

if (typeof fieldValue === 'undefined') {
if (context.cacheResolvers &&
if (context.cacheRedirects &&
obj &&
(obj.__typename || objId === 'ROOT_QUERY')) {
var typename = obj.__typename || 'Query';
var type = context.cacheResolvers[typename];
var type = context.cacheRedirects[typename];
if (type) {
var resolver = type[fieldName];
if (resolver) {
fieldValue = resolver(obj, args);
fieldValue = resolver(obj, args, {
getCacheKey: function (obj) {
return apolloUtilities.toIdValue(context.dataIdFromObject(obj));
},
});
}

@@ -475,3 +479,4 @@ }

returnPartialData: returnPartialData,
cacheResolvers: (config && config.cacheResolvers) || {},
dataIdFromObject: (config && config.dataIdFromObject) || null,
cacheRedirects: (config && config.cacheRedirects) || {},
hasMissingField: false,

@@ -648,4 +653,9 @@ };

_this.config = __assign$3({}, defaultConfig, config);
if (_this.config.customResolvers)
_this.config.cacheResolvers = _this.config.customResolvers;
if (_this.config.customResolvers) {
console.warn('customResolvers have been renamed to cacheRedirects. Please update your config as we will be deprecating customResolvers in the next major version.');
_this.config.cacheRedirects = _this.config.customResolvers;
}
if (_this.config.cacheResolvers)
console.warn('cacheResolvers have been renamed to cacheRedirects. Please update your config as we will be deprecating cacheResolvers in the next major version.');
_this.config.cacheRedirects = _this.config.cacheResolvers;
_this.addTypename = _this.config.addTypename;

@@ -652,0 +662,0 @@ _this.data = _this.config.storeFactory();

@@ -52,4 +52,9 @@ var __extends = (this && this.__extends) || (function () {

_this.config = __assign({}, defaultConfig, config);
if (_this.config.customResolvers)
_this.config.cacheResolvers = _this.config.customResolvers;
if (_this.config.customResolvers) {
console.warn('customResolvers have been renamed to cacheRedirects. Please update your config as we will be deprecating customResolvers in the next major version.');
_this.config.cacheRedirects = _this.config.customResolvers;
}
if (_this.config.cacheResolvers)
console.warn('cacheResolvers have been renamed to cacheRedirects. Please update your config as we will be deprecating cacheResolvers in the next major version.');
_this.config.cacheRedirects = _this.config.cacheResolvers;
_this.addTypename = _this.config.addTypename;

@@ -56,0 +61,0 @@ _this.data = _this.config.storeFactory();

@@ -10,3 +10,3 @@ var __assign = (this && this.__assign) || Object.assign || function(t) {

import graphqlAnywhere from 'graphql-anywhere';
import { assign, isEqual, getDefaultValues, getQueryDefinition, isJsonValue, isIdValue, getStoreKeyName, } from 'apollo-utilities';
import { assign, isEqual, getDefaultValues, getQueryDefinition, isJsonValue, isIdValue, toIdValue, getStoreKeyName, } from 'apollo-utilities';
export var ID_KEY = typeof Symbol !== 'undefined' ? Symbol('id') : '@@id';

@@ -25,11 +25,15 @@ export function readQueryFromStore(options) {

if (typeof fieldValue === 'undefined') {
if (context.cacheResolvers &&
if (context.cacheRedirects &&
obj &&
(obj.__typename || objId === 'ROOT_QUERY')) {
var typename = obj.__typename || 'Query';
var type = context.cacheResolvers[typename];
var type = context.cacheRedirects[typename];
if (type) {
var resolver = type[fieldName];
if (resolver) {
fieldValue = resolver(obj, args);
fieldValue = resolver(obj, args, {
getCacheKey: function (obj) {
return toIdValue(context.dataIdFromObject(obj));
},
});
}

@@ -65,3 +69,4 @@ }

returnPartialData: returnPartialData,
cacheResolvers: (config && config.cacheResolvers) || {},
dataIdFromObject: (config && config.dataIdFromObject) || null,
cacheRedirects: (config && config.cacheRedirects) || {},
hasMissingField: false,

@@ -68,0 +73,0 @@ };

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

addTypename?: boolean;
cacheResolvers?: CacheResolverMap;
cacheRedirects?: CacheResolverMap;
storeFactory?: NormalizedCacheFactory;

@@ -51,3 +51,4 @@ };

hasMissingField: boolean;
cacheResolvers: CacheResolverMap;
cacheRedirects: CacheResolverMap;
dataIdFromObject?: IdGetter;
};

@@ -65,3 +66,3 @@ export interface FragmentMatcherInterface {

__schema: {
types: [{
types: {
kind: string;

@@ -72,3 +73,3 @@ name: string;

}[];
}];
}[];
};

@@ -78,3 +79,3 @@ };

[argName: string]: any;
}) => any;
}, context: any) => any;
export declare type CacheResolverMap = {

@@ -81,0 +82,0 @@ [typeName: string]: {

@@ -135,3 +135,3 @@ var __extends = (this && this.__extends) || (function () {

hasMissingField: false,
cacheResolvers: {},
cacheRedirects: {},
};

@@ -138,0 +138,0 @@ matches = context.fragmentMatcherFunction(idValue, fragment.typeCondition.name.value, fakeContext);

{
"name": "apollo-cache-inmemory",
"version": "1.1.7",
"version": "1.1.8",
"description": "Core abstract of Caching layer for Apollo Client",

@@ -35,12 +35,10 @@ "author": "James Baxley <james@meteor.com>",

"prepublishOnly": "npm run build",
"build:browser":
"browserify ./lib/bundle.umd.js --i apollo-cache --i apollo-utilities --i graphql -o=./lib/bundle.js && npm run minify:browser",
"minify:browser":
"uglifyjs -c -m -o ./lib/bundle.min.js -- ./lib/bundle.js",
"build:browser": "browserify ./lib/bundle.umd.js --i apollo-cache --i apollo-utilities --i graphql -o=./lib/bundle.js && npm run minify:browser",
"minify:browser": "uglifyjs -c -m -o ./lib/bundle.min.js -- ./lib/bundle.js",
"filesize": "npm run build:browser"
},
"dependencies": {
"apollo-cache": "^1.1.2",
"apollo-utilities": "^1.0.6",
"graphql-anywhere": "^4.1.3"
"apollo-cache": "^1.1.3",
"apollo-utilities": "^1.0.7",
"graphql-anywhere": "^4.1.4"
},

@@ -60,3 +58,3 @@ "peerDependencies": {

"rimraf": "2.6.2",
"rollup": "0.55.1",
"rollup": "0.55.5",
"ts-jest": "20.0.14",

@@ -72,4 +70,9 @@ "tslint": "5.9.1",

"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
"moduleFileExtensions": ["ts", "tsx", "js", "json"]
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"json"
]
}
}

@@ -870,3 +870,3 @@ import gql, { disableFragmentWarnings } from 'graphql-tag';

const cacheResolvers = {
const cacheRedirects = {
Query: {

@@ -877,3 +877,3 @@ person: (_: any, args: any) => toIdValue(args['id']),

const config = { dataIdFromObject, cacheResolvers };
const config = { dataIdFromObject, cacheRedirects };

@@ -880,0 +880,0 @@ const { result } = diffQueryAgainstStore({

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

this.config = { ...defaultConfig, ...config };
// backwards compat
if ((this.config as any).customResolvers)
this.config.cacheResolvers = (this.config as any).customResolvers;
if ((this.config as any).customResolvers) {
console.warn(
'customResolvers have been renamed to cacheRedirects. Please update your config as we will be deprecating customResolvers in the next major version.',
);
this.config.cacheRedirects = (this.config as any).customResolvers;
}
if ((this.config as any).cacheResolvers)
console.warn(
'cacheResolvers have been renamed to cacheRedirects. Please update your config as we will be deprecating cacheResolvers in the next major version.',
);
this.config.cacheRedirects = (this.config as any).cacheResolvers;
this.addTypename = this.config.addTypename;

@@ -59,0 +71,0 @@ this.data = this.config.storeFactory();

@@ -11,2 +11,3 @@ import graphqlAnywhere, { Resolver, ExecInfo } from 'graphql-anywhere';

isIdValue,
toIdValue,
getStoreKeyName,

@@ -75,3 +76,3 @@ } from 'apollo-utilities';

if (
context.cacheResolvers &&
context.cacheRedirects &&
obj &&

@@ -83,3 +84,3 @@ (obj.__typename || objId === 'ROOT_QUERY')

// Look for the type in the custom resolver map
const type = context.cacheResolvers[typename];
const type = context.cacheRedirects[typename];
if (type) {

@@ -89,3 +90,6 @@ // Look for the field in the custom resolver map

if (resolver) {
fieldValue = resolver(obj, args);
fieldValue = resolver(obj, args, {
getCacheKey: (obj: { __typename: string; id: string | number }) =>
toIdValue(context.dataIdFromObject(obj)),
});
}

@@ -168,3 +172,4 @@ }

returnPartialData,
cacheResolvers: (config && config.cacheResolvers) || {},
dataIdFromObject: (config && config.dataIdFromObject) || null,
cacheRedirects: (config && config.cacheRedirects) || {},
// Flag set during execution

@@ -171,0 +176,0 @@ hasMissingField: false,

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

addTypename?: boolean;
cacheResolvers?: CacheResolverMap;
cacheRedirects?: CacheResolverMap;
storeFactory?: NormalizedCacheFactory;

@@ -79,3 +79,4 @@ };

hasMissingField: boolean;
cacheResolvers: CacheResolverMap;
cacheRedirects: CacheResolverMap;
dataIdFromObject?: IdGetter;
};

@@ -114,11 +115,9 @@

__schema: {
types: [
{
kind: string;
types: {
kind: string;
name: string;
possibleTypes: {
name: string;
possibleTypes: {
name: string;
}[];
}
];
}[];
}[];
};

@@ -130,2 +129,3 @@ };

args: { [argName: string]: any },
context: any,
) => any;

@@ -132,0 +132,0 @@

@@ -253,3 +253,3 @@ import {

hasMissingField: false,
cacheResolvers: {},
cacheRedirects: {},
};

@@ -256,0 +256,0 @@ matches = context.fragmentMatcherFunction(

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc