apollo-cache-inmemory
Advanced tools
Comparing version 0.1.0-1 to 0.2.0-alpha.2
@@ -12,2 +12,3 @@ import { DocumentNode } from 'graphql'; | ||
constructor(initialStore?: NormalizedCache, config?: ApolloReducerConfig); | ||
transformDocument(document: DocumentNode): DocumentNode; | ||
getData(): NormalizedCache; | ||
@@ -14,0 +15,0 @@ getOptimisticData(): NormalizedCache; |
@@ -56,2 +56,7 @@ "use strict"; | ||
} | ||
InMemoryCache.prototype.transformDocument = function (document) { | ||
if (this.addTypename) | ||
return apollo_utilities_1.addTypenameToDocument(document); | ||
return document; | ||
}; | ||
InMemoryCache.prototype.getData = function () { | ||
@@ -75,3 +80,3 @@ return this.data; | ||
store: query.optimistic ? this.getOptimisticData() : this.data, | ||
query: query.query, | ||
query: this.transformDocument(query.query), | ||
variables: query.variables, | ||
@@ -90,3 +95,3 @@ returnPartialData: query.returnPartialData, | ||
store: query.optimistic ? this.getOptimisticData() : this.data, | ||
query: query.query, | ||
query: this.transformDocument(query.query), | ||
variables: query.variables, | ||
@@ -102,5 +107,2 @@ rootId: query.rootId, | ||
var query = options.query; | ||
if (this.addTypename) { | ||
query = apollo_utilities_1.addTypenameToDocument(query); | ||
} | ||
return this.read({ | ||
@@ -115,7 +117,4 @@ query: query, | ||
var document = apollo_utilities_1.getFragmentQueryDocument(options.fragment, options.fragmentName); | ||
if (this.addTypename) { | ||
document = apollo_utilities_1.addTypenameToDocument(document); | ||
} | ||
return this.read({ | ||
query: document, | ||
query: this.transformDocument(document), | ||
variables: options.variables, | ||
@@ -132,9 +131,6 @@ rootId: options.id, | ||
var query = options.query; | ||
if (this.addTypename) { | ||
query = apollo_utilities_1.addTypenameToDocument(query); | ||
} | ||
this.writeResult({ | ||
dataId: 'ROOT_QUERY', | ||
result: options.data, | ||
document: query, | ||
document: this.transformDocument(query), | ||
variables: options.variables, | ||
@@ -145,9 +141,6 @@ }); | ||
var document = apollo_utilities_1.getFragmentQueryDocument(options.fragment, options.fragmentName); | ||
if (this.addTypename) { | ||
document = apollo_utilities_1.addTypenameToDocument(document); | ||
} | ||
this.writeResult({ | ||
dataId: options.id, | ||
result: options.data, | ||
document: document, | ||
document: this.transformDocument(document), | ||
variables: options.variables, | ||
@@ -154,0 +147,0 @@ }); |
{ | ||
"name": "apollo-cache-inmemory", | ||
"version": "0.1.0-1", | ||
"description": "Inmemory caching layer for Apollo Client", | ||
"version": "0.2.0-alpha.2", | ||
"description": "Core abstract of Caching layer for Apollo Client", | ||
"author": "James Baxley <james@meteor.com>", | ||
@@ -23,51 +23,43 @@ "contributors": [ | ||
"scripts": { | ||
"pretest": "npm run build", | ||
"test": "npm run test-only --", | ||
"posttest": "npm run lint", | ||
"test-only": "mocha --reporter spec --full-trace dist/tests/tests.js", | ||
"test-watch": "mocha --reporter spec --full-trace dist/tests/tests.js --watch", | ||
"coverage": "istanbul cover ./node_modules/.bin/_mocha -- --reporter dot --full-trace dist/tests/tests.js", | ||
"postcoverage": "remap-istanbul --input coverage/coverage.json --type lcovonly --output coverage/lcov.info", | ||
"lint": "tslint --type-check -p tsconfig.json src/*.ts && tslint --type-check -p tsconfig.json tests/*.ts", | ||
"prebuild": "npm run clean:dist", | ||
"coverage": "jest --coverage", | ||
"test": "jest", | ||
"lint": "tslint --type-check -p tsconfig.json src/*.ts", | ||
"prebuild": "npm run clean", | ||
"build": "tsc -p .", | ||
"postbuild": "cp -R ./dist/src/. ./lib", | ||
"watch": "tsc -w -p .", | ||
"clean": "npm run clean:dist && npm run clean:coverage", | ||
"clean:dist": "rimraf dist/* && rimraf lib/*", | ||
"clean:coverage": "rimraf coverage/*", | ||
"prepublishOnly": "npm run clean && npm run build", | ||
"compile:browser": "browserify ./dist/src/index.js --i apollo-cache-core --i apollo-utilities -o=./dist/index.js && npm run minify:browser", | ||
"minify:browser": "uglifyjs -c -m -o ./dist/index.min.js -- ./dist/index.js", | ||
"filesize": "npm run compile:browser" | ||
"clean": "rimraf coverage/* && rimraf lib/*", | ||
"prepublishOnly": "npm run build", | ||
"build:browser": | ||
"browserify ./lib/index.js --i apollo-cache-core --i apollo-utilities -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-utilities": "*", | ||
"apollo-cache-core": "*", | ||
"graphql-anywhere": "4.0.0-0" | ||
"apollo-cache-core": "^0.2.0-alpha.2", | ||
"apollo-utilities": "^0.2.0-alpha.2", | ||
"graphql-anywhere": "^4.0.0-alpha.2" | ||
}, | ||
"devDependencies": { | ||
"@types/chai": "^4.0.0", | ||
"@types/chai-as-promised": "0.0.31", | ||
"@types/graphql": "~0.9.0", | ||
"@types/jest": "^20.0.7", | ||
"@types/lodash": "^4.14.72", | ||
"@types/mocha": "^2.2.31", | ||
"@types/sinon": "^2.3.2", | ||
"browserify": "^14.4.0", | ||
"chai": "^4.0.2", | ||
"chai-as-promised": "^7.0.0", | ||
"fetch-mock": "^5.11.0", | ||
"graphql": "^0.10.3", | ||
"graphql-tag": "^2.4.2", | ||
"istanbul": "^0.4.4", | ||
"jest": "^20.0.4", | ||
"lodash": "^4.17.4", | ||
"mocha": "^3.2.0", | ||
"remap-istanbul": "^0.9.0", | ||
"rimraf": "^2.5.4", | ||
"sinon": "^2.3.4", | ||
"source-map-support": "^0.4.5", | ||
"ts-jest": "^20.0.10", | ||
"tslint": "^5.0.0", | ||
"typescript": "^2.2.1", | ||
"uglifyjs": "^2.4.11" | ||
}, | ||
"jest": { | ||
"transform": { | ||
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js" | ||
}, | ||
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$", | ||
"moduleFileExtensions": ["ts", "tsx", "js", "json"] | ||
} | ||
} |
@@ -63,2 +63,7 @@ import { DocumentNode } from 'graphql'; | ||
public transformDocument(document: DocumentNode): DocumentNode { | ||
if (this.addTypename) return addTypenameToDocument(document); | ||
return document; | ||
} | ||
public getData(): NormalizedCache { | ||
@@ -93,3 +98,3 @@ return this.data; | ||
store: query.optimistic ? this.getOptimisticData() : this.data, | ||
query: query.query, | ||
query: this.transformDocument(query.query), | ||
variables: query.variables, | ||
@@ -116,3 +121,3 @@ returnPartialData: query.returnPartialData, | ||
store: query.optimistic ? this.getOptimisticData() : this.data, | ||
query: query.query, | ||
query: this.transformDocument(query.query), | ||
variables: query.variables, | ||
@@ -131,6 +136,2 @@ rootId: query.rootId, | ||
let query = options.query; | ||
if (this.addTypename) { | ||
query = addTypenameToDocument(query); | ||
} | ||
return this.read({ | ||
@@ -151,8 +152,5 @@ query, | ||
); | ||
if (this.addTypename) { | ||
document = addTypenameToDocument(document); | ||
} | ||
return this.read({ | ||
query: document, | ||
query: this.transformDocument(document), | ||
variables: options.variables, | ||
@@ -177,10 +175,6 @@ rootId: options.id, | ||
let query = options.query; | ||
if (this.addTypename) { | ||
query = addTypenameToDocument(query); | ||
} | ||
this.writeResult({ | ||
dataId: 'ROOT_QUERY', | ||
result: options.data, | ||
document: query, | ||
document: this.transformDocument(query), | ||
variables: options.variables, | ||
@@ -195,5 +189,2 @@ }); | ||
); | ||
if (this.addTypename) { | ||
document = addTypenameToDocument(document); | ||
} | ||
@@ -203,3 +194,3 @@ this.writeResult({ | ||
result: options.data, | ||
document, | ||
document: this.transformDocument(document), | ||
variables: options.variables, | ||
@@ -206,0 +197,0 @@ }); |
@@ -10,4 +10,4 @@ { | ||
"declaration": true, | ||
"rootDir": ".", | ||
"outDir": "dist", | ||
"rootDir": "./src", | ||
"outDir": "lib", | ||
"noImplicitAny": true, | ||
@@ -18,3 +18,4 @@ "noUnusedParameters": false, | ||
}, | ||
"include": ["src/**/*.ts", "tests/**/*.ts"] | ||
"include": ["src/**/*.ts"], | ||
"exclude": ["src/**/__tests__/*.ts"] | ||
} |
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
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 2 instances in 1 package
13
1
219787
37
6809
1
+ Addedapollo-cache-core@0.2.0-alpha.11(transitive)
+ Addedapollo-utilities@0.2.0-rc.3(transitive)
+ Addedgraphql-anywhere@4.2.8(transitive)
- Removedapollo-cache-core@0.1.0(transitive)
- Removedgraphql-anywhere@4.0.0-0(transitive)