apollo-cache-inmemory
Advanced tools
Comparing version 1.1.5 to 1.1.7
@@ -5,2 +5,8 @@ # Change log | ||
### 1.1.7 | ||
- update to latest apollo-utilities to support directives in cache | ||
### 1.1.6 (unpublished) | ||
- update to latest apollo-utilities | ||
### 1.1.5 | ||
@@ -7,0 +13,0 @@ - Update to latest apollo-cache base [#2818](https://github.com/apollographql/apollo-client/pull/2818) |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('apollo-cache'), require('apollo-utilities'), require('graphql/language/printer'), require('graphql-anywhere')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'apollo-cache', 'apollo-utilities', 'graphql/language/printer', 'graphql-anywhere'], factory) : | ||
(factory((global.apollo = global.apollo || {}, global.apollo.cache = global.apollo.cache || {}, global.apollo.cache.inmemory = {}),global.apolloCache.core,global.apollo.utilities,global.printer,global.graphqlAnywhere)); | ||
}(this, (function (exports,apolloCache,apolloUtilities,printer,graphqlAnywhere) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('apollo-utilities'), require('graphql/language/printer'), require('graphql-anywhere'), require('apollo-cache')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'apollo-utilities', 'graphql/language/printer', 'graphql-anywhere', 'apollo-cache'], factory) : | ||
(factory((global.apollo = global.apollo || {}, global.apollo.cache = global.apollo.cache || {}, global.apollo.cache.inmemory = {}),global.apollo.utilities,global.printer,global.graphqlAnywhere,global.apolloCache.core)); | ||
}(this, (function (exports,apolloUtilities,printer,graphqlAnywhere,apolloCache) { 'use strict'; | ||
@@ -120,3 +120,3 @@ graphqlAnywhere = graphqlAnywhere && graphqlAnywhere.hasOwnProperty('default') ? graphqlAnywhere['default'] : graphqlAnywhere; | ||
var __extends$1 = (undefined && undefined.__extends) || (function () { | ||
var __extends = (undefined && undefined.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
@@ -131,3 +131,3 @@ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
})(); | ||
var __assign$1 = (undefined && undefined.__assign) || Object.assign || function(t) { | ||
var __assign = (undefined && undefined.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
@@ -141,3 +141,3 @@ s = arguments[i]; | ||
var WriteError = (function (_super) { | ||
__extends$1(WriteError, _super); | ||
__extends(WriteError, _super); | ||
function WriteError() { | ||
@@ -285,3 +285,3 @@ var _this = _super !== null && _super.apply(this, arguments) || this; | ||
cache.delete(generatedKey); | ||
cache.set(realKey, __assign$1({}, generated, real)); | ||
cache.set(realKey, __assign({}, generated, real)); | ||
}); | ||
@@ -373,3 +373,3 @@ } | ||
} | ||
var newStoreObj = __assign$1({}, store.get(dataId), (_b = {}, _b[storeFieldName] = storeValue, _b)); | ||
var newStoreObj = __assign({}, store.get(dataId), (_b = {}, _b[storeFieldName] = storeValue, _b)); | ||
if (shouldMerge) { | ||
@@ -418,3 +418,3 @@ mergeWithGenerated(generatedKey, storeValue.id, store); | ||
var __assign$2 = (undefined && undefined.__assign) || Object.assign || function(t) { | ||
var __assign$1 = (undefined && undefined.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
@@ -430,3 +430,3 @@ s = arguments[i]; | ||
var optsPatch = { returnPartialData: false }; | ||
return diffQueryAgainstStore(__assign$2({}, options, optsPatch)).result; | ||
return diffQueryAgainstStore(__assign$1({}, options, optsPatch)).result; | ||
} | ||
@@ -504,3 +504,3 @@ var readStoreResolver = function (fieldName, idValue, args, context, _a) { | ||
if (apolloUtilities.isIdValue(value)) { | ||
return __assign$2({}, value, { previousResult: previousResult }); | ||
return __assign$1({}, value, { previousResult: previousResult }); | ||
} | ||
@@ -556,3 +556,3 @@ else if (Array.isArray(value)) { | ||
var __assign$3 = (undefined && undefined.__assign) || Object.assign || function(t) { | ||
var __assign$2 = (undefined && undefined.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
@@ -578,3 +578,3 @@ s = arguments[i]; | ||
RecordingCache.prototype.toObject = function () { | ||
return __assign$3({}, this.data, this.recordedData); | ||
return __assign$2({}, this.data, this.recordedData); | ||
}; | ||
@@ -602,3 +602,3 @@ RecordingCache.prototype.get = function (dataId) { | ||
this.clear(); | ||
this.recordedData = __assign$3({}, newData); | ||
this.recordedData = __assign$2({}, newData); | ||
}; | ||
@@ -612,3 +612,3 @@ return RecordingCache; | ||
var __extends = (undefined && undefined.__extends) || (function () { | ||
var __extends$1 = (undefined && undefined.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
@@ -623,3 +623,3 @@ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
})(); | ||
var __assign = (undefined && undefined.__assign) || Object.assign || function(t) { | ||
var __assign$3 = (undefined && undefined.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
@@ -650,3 +650,3 @@ s = arguments[i]; | ||
var InMemoryCache = (function (_super) { | ||
__extends(InMemoryCache, _super); | ||
__extends$1(InMemoryCache, _super); | ||
function InMemoryCache(config) { | ||
@@ -658,6 +658,6 @@ if (config === void 0) { config = {}; } | ||
_this.silenceBroadcast = false; | ||
_this.config = __assign({}, defaultConfig, config); | ||
_this.config = __assign$3({}, defaultConfig, config); | ||
if (_this.config.customResolvers) | ||
_this.config.cacheResolvers = _this.config.customResolvers; | ||
_this.addTypename = _this.config.addTypename ? true : false; | ||
_this.addTypename = _this.config.addTypename; | ||
_this.data = _this.config.storeFactory(); | ||
@@ -664,0 +664,0 @@ return _this; |
@@ -54,3 +54,3 @@ var __extends = (this && this.__extends) || (function () { | ||
_this.config.cacheResolvers = _this.config.customResolvers; | ||
_this.addTypename = _this.config.addTypename ? true : false; | ||
_this.addTypename = _this.config.addTypename; | ||
_this.data = _this.config.storeFactory(); | ||
@@ -57,0 +57,0 @@ return _this; |
{ | ||
"name": "apollo-cache-inmemory", | ||
"version": "1.1.5", | ||
"version": "1.1.7", | ||
"description": "Core abstract of Caching layer for Apollo Client", | ||
@@ -42,5 +42,5 @@ "author": "James Baxley <james@meteor.com>", | ||
"dependencies": { | ||
"apollo-cache": "^1.1.0", | ||
"apollo-utilities": "^1.0.4", | ||
"graphql-anywhere": "^4.1.1" | ||
"apollo-cache": "^1.1.2", | ||
"apollo-utilities": "^1.0.6", | ||
"graphql-anywhere": "^4.1.3" | ||
}, | ||
@@ -51,6 +51,6 @@ "peerDependencies": { | ||
"devDependencies": { | ||
"@types/graphql": "0.11.7", | ||
"@types/graphql": "0.12.3", | ||
"@types/jest": "21.1.10", | ||
"@types/lodash": "4.14.92", | ||
"browserify": "15.0.0", | ||
"@types/lodash": "4.14.97", | ||
"browserify": "15.2.0", | ||
"graphql": "0.12.3", | ||
@@ -61,5 +61,5 @@ "graphql-tag": "2.6.1", | ||
"rimraf": "2.6.2", | ||
"rollup": "0.53.3", | ||
"rollup": "0.55.1", | ||
"ts-jest": "20.0.14", | ||
"tslint": "5.8.0", | ||
"tslint": "5.9.1", | ||
"typescript": "2.5.2", | ||
@@ -66,0 +66,0 @@ "uglifyjs": "2.4.11" |
@@ -168,2 +168,34 @@ import { assign, omit } from 'lodash'; | ||
it('runs a basic query with custom directives', () => { | ||
const query = gql` | ||
query { | ||
id | ||
firstName @include(if: true) | ||
lastName @upperCase | ||
birthDate @dateFormat(format: "DD-MM-YYYY") | ||
} | ||
`; | ||
const store = defaultNormalizedCacheFactory({ | ||
ROOT_QUERY: { | ||
id: 'abcd', | ||
firstName: 'James', | ||
'lastName@upperCase': 'BOND', | ||
'birthDate@dateFormat({"format":"DD-MM-YYYY"})': '20-05-1940', | ||
}, | ||
}); | ||
const result = readQueryFromStore({ | ||
store, | ||
query, | ||
}); | ||
expect(result).toEqual({ | ||
id: 'abcd', | ||
firstName: 'James', | ||
lastName: 'BOND', | ||
birthDate: '20-05-1940', | ||
}); | ||
}); | ||
it('runs a basic query with default values for arguments', () => { | ||
@@ -170,0 +202,0 @@ const query = gql` |
@@ -224,2 +224,34 @@ import { cloneDeep, assign, omit } from 'lodash'; | ||
it('properly normalizes a query with custom directives', () => { | ||
const query = gql` | ||
query { | ||
id | ||
firstName @include(if: true) | ||
lastName @upperCase | ||
birthDate @dateFormat(format: "DD-MM-YYYY") | ||
} | ||
`; | ||
const result: any = { | ||
id: 'abcd', | ||
firstName: 'James', | ||
lastName: 'BOND', | ||
birthDate: '20-05-1940', | ||
}; | ||
const normalized = writeQueryToStore({ | ||
result, | ||
query, | ||
}); | ||
expect(normalized.toObject()).toEqual({ | ||
ROOT_QUERY: { | ||
id: 'abcd', | ||
firstName: 'James', | ||
'lastName@upperCase': 'BOND', | ||
'birthDate@dateFormat({"format":"DD-MM-YYYY"})': '20-05-1940', | ||
}, | ||
}); | ||
}); | ||
it('properly normalizes a nested object with an ID', () => { | ||
@@ -226,0 +258,0 @@ const query = gql` |
@@ -57,3 +57,3 @@ import { DocumentNode } from 'graphql'; | ||
this.config.cacheResolvers = (this.config as any).customResolvers; | ||
this.addTypename = this.config.addTypename ? true : false; | ||
this.addTypename = this.config.addTypename; | ||
this.data = this.config.storeFactory(); | ||
@@ -60,0 +60,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
369237
8436
Updatedapollo-cache@^1.1.2
Updatedapollo-utilities@^1.0.6
Updatedgraphql-anywhere@^4.1.3