This commit is contained in:
72
node_modules/apollo-cache/CHANGELOG.md
generated
vendored
Normal file
72
node_modules/apollo-cache/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
# CHANGELOG
|
||||
|
||||
----
|
||||
|
||||
**NOTE:** This changelog is no longer maintained. Changes are now tracked in
|
||||
the top level [`CHANGELOG.md`](https://github.com/apollographql/apollo-client/blob/master/CHANGELOG.md).
|
||||
|
||||
----
|
||||
|
||||
### 1.1.12
|
||||
|
||||
- No changes.
|
||||
|
||||
### 1.1.11
|
||||
|
||||
- No changes.
|
||||
|
||||
### 1.1.10
|
||||
|
||||
- Added optional generics to cache manipulation methods (typescript).
|
||||
[PR #3541](https://github.com/apollographql/apollo-client/pull/3541)
|
||||
|
||||
### 1.1.9
|
||||
|
||||
- No public facing functionality changes.
|
||||
- Various internal code cleanup, tooling and dependency changes.
|
||||
|
||||
### 1.1.8
|
||||
|
||||
- Not documented
|
||||
|
||||
### 1.1.7
|
||||
|
||||
- Not documented
|
||||
|
||||
### 1.1.6
|
||||
|
||||
- Improve code coverage
|
||||
- Map coverage to original source
|
||||
|
||||
### 1.1.3
|
||||
|
||||
- Dependency updates
|
||||
|
||||
### 1.1.2
|
||||
|
||||
- Dependency updates
|
||||
|
||||
### 1.1.1
|
||||
|
||||
- Dependency updates
|
||||
|
||||
### 1.1.0
|
||||
|
||||
- Add cache.writeData to base cache type & DataProxy
|
||||
[PR #2818](https://github.com/apollographql/apollo-client/pull/2818)
|
||||
|
||||
### 1.0.3
|
||||
|
||||
- Dependency updates
|
||||
|
||||
### 1.0.2
|
||||
|
||||
- Package dependency updates
|
||||
|
||||
### 1.0.1
|
||||
|
||||
- Improved rollup builds
|
||||
|
||||
### 1.0.0
|
||||
|
||||
- Initial solid cache API
|
||||
22
node_modules/apollo-cache/LICENSE
generated
vendored
Normal file
22
node_modules/apollo-cache/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2018 Meteor Development Group, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
3
node_modules/apollo-cache/jest.config.js
generated
vendored
Normal file
3
node_modules/apollo-cache/jest.config.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
...require('../../config/jest.config.settings'),
|
||||
};
|
||||
194
node_modules/apollo-cache/lib/bundle.cjs.js
generated
vendored
Normal file
194
node_modules/apollo-cache/lib/bundle.cjs.js
generated
vendored
Normal file
@@ -0,0 +1,194 @@
|
||||
exports.__esModule = true;
|
||||
exports.Cache = exports.ApolloCache = void 0;
|
||||
|
||||
var _apolloUtilities = require("apollo-utilities");
|
||||
|
||||
function queryFromPojo(obj) {
|
||||
var op = {
|
||||
kind: 'OperationDefinition',
|
||||
operation: 'query',
|
||||
name: {
|
||||
kind: 'Name',
|
||||
value: 'GeneratedClientQuery'
|
||||
},
|
||||
selectionSet: selectionSetFromObj(obj)
|
||||
};
|
||||
var out = {
|
||||
kind: 'Document',
|
||||
definitions: [op]
|
||||
};
|
||||
return out;
|
||||
}
|
||||
|
||||
function fragmentFromPojo(obj, typename) {
|
||||
var frag = {
|
||||
kind: 'FragmentDefinition',
|
||||
typeCondition: {
|
||||
kind: 'NamedType',
|
||||
name: {
|
||||
kind: 'Name',
|
||||
value: typename || '__FakeType'
|
||||
}
|
||||
},
|
||||
name: {
|
||||
kind: 'Name',
|
||||
value: 'GeneratedClientQuery'
|
||||
},
|
||||
selectionSet: selectionSetFromObj(obj)
|
||||
};
|
||||
var out = {
|
||||
kind: 'Document',
|
||||
definitions: [frag]
|
||||
};
|
||||
return out;
|
||||
}
|
||||
|
||||
function selectionSetFromObj(obj) {
|
||||
if (typeof obj === 'number' || typeof obj === 'boolean' || typeof obj === 'string' || typeof obj === 'undefined' || obj === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (Array.isArray(obj)) {
|
||||
return selectionSetFromObj(obj[0]);
|
||||
}
|
||||
|
||||
var selections = [];
|
||||
Object.keys(obj).forEach(function (key) {
|
||||
var nestedSelSet = selectionSetFromObj(obj[key]);
|
||||
var field = {
|
||||
kind: 'Field',
|
||||
name: {
|
||||
kind: 'Name',
|
||||
value: key
|
||||
},
|
||||
selectionSet: nestedSelSet || undefined
|
||||
};
|
||||
selections.push(field);
|
||||
});
|
||||
var selectionSet = {
|
||||
kind: 'SelectionSet',
|
||||
selections: selections
|
||||
};
|
||||
return selectionSet;
|
||||
}
|
||||
|
||||
var justTypenameQuery = {
|
||||
kind: 'Document',
|
||||
definitions: [{
|
||||
kind: 'OperationDefinition',
|
||||
operation: 'query',
|
||||
name: null,
|
||||
variableDefinitions: null,
|
||||
directives: [],
|
||||
selectionSet: {
|
||||
kind: 'SelectionSet',
|
||||
selections: [{
|
||||
kind: 'Field',
|
||||
alias: null,
|
||||
name: {
|
||||
kind: 'Name',
|
||||
value: '__typename'
|
||||
},
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null
|
||||
}]
|
||||
}
|
||||
}]
|
||||
};
|
||||
|
||||
var ApolloCache = function () {
|
||||
function ApolloCache() {}
|
||||
|
||||
ApolloCache.prototype.transformDocument = function (document) {
|
||||
return document;
|
||||
};
|
||||
|
||||
ApolloCache.prototype.transformForLink = function (document) {
|
||||
return document;
|
||||
};
|
||||
|
||||
ApolloCache.prototype.readQuery = function (options, optimistic) {
|
||||
if (optimistic === void 0) {
|
||||
optimistic = false;
|
||||
}
|
||||
|
||||
return this.read({
|
||||
query: options.query,
|
||||
variables: options.variables,
|
||||
optimistic: optimistic
|
||||
});
|
||||
};
|
||||
|
||||
ApolloCache.prototype.readFragment = function (options, optimistic) {
|
||||
if (optimistic === void 0) {
|
||||
optimistic = false;
|
||||
}
|
||||
|
||||
return this.read({
|
||||
query: (0, _apolloUtilities.getFragmentQueryDocument)(options.fragment, options.fragmentName),
|
||||
variables: options.variables,
|
||||
rootId: options.id,
|
||||
optimistic: optimistic
|
||||
});
|
||||
};
|
||||
|
||||
ApolloCache.prototype.writeQuery = function (options) {
|
||||
this.write({
|
||||
dataId: 'ROOT_QUERY',
|
||||
result: options.data,
|
||||
query: options.query,
|
||||
variables: options.variables
|
||||
});
|
||||
};
|
||||
|
||||
ApolloCache.prototype.writeFragment = function (options) {
|
||||
this.write({
|
||||
dataId: options.id,
|
||||
result: options.data,
|
||||
variables: options.variables,
|
||||
query: (0, _apolloUtilities.getFragmentQueryDocument)(options.fragment, options.fragmentName)
|
||||
});
|
||||
};
|
||||
|
||||
ApolloCache.prototype.writeData = function (_a) {
|
||||
var id = _a.id,
|
||||
data = _a.data;
|
||||
|
||||
if (typeof id !== 'undefined') {
|
||||
var typenameResult = null;
|
||||
|
||||
try {
|
||||
typenameResult = this.read({
|
||||
rootId: id,
|
||||
optimistic: false,
|
||||
query: justTypenameQuery
|
||||
});
|
||||
} catch (e) {}
|
||||
|
||||
var __typename = typenameResult && typenameResult.__typename || '__ClientData';
|
||||
|
||||
var dataToWrite = Object.assign({
|
||||
__typename: __typename
|
||||
}, data);
|
||||
this.writeFragment({
|
||||
id: id,
|
||||
fragment: fragmentFromPojo(dataToWrite, __typename),
|
||||
data: dataToWrite
|
||||
});
|
||||
} else {
|
||||
this.writeQuery({
|
||||
query: queryFromPojo(data),
|
||||
data: data
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return ApolloCache;
|
||||
}();
|
||||
|
||||
exports.ApolloCache = ApolloCache;
|
||||
var Cache;
|
||||
exports.Cache = Cache;
|
||||
|
||||
(function (Cache) {})(Cache || (exports.Cache = Cache = {}));
|
||||
1
node_modules/apollo-cache/lib/bundle.cjs.js.map
generated
vendored
Normal file
1
node_modules/apollo-cache/lib/bundle.cjs.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/apollo-cache/lib/bundle.cjs.min.js
generated
vendored
Normal file
1
node_modules/apollo-cache/lib/bundle.cjs.min.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
exports.__esModule=!0,exports.Cache=exports.ApolloCache=void 0;var e=require("apollo-utilities");function t(e){return{kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GeneratedClientQuery"},selectionSet:i(e)}]}}function i(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e||null==e)return null;if(Array.isArray(e))return i(e[0]);var t=[];return Object.keys(e).forEach(function(n){var r={kind:"Field",name:{kind:"Name",value:n},selectionSet:i(e[n])||void 0};t.push(r)}),{kind:"SelectionSet",selections:t}}var n,r={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:null,variableDefinitions:null,directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",alias:null,name:{kind:"Name",value:"__typename"},arguments:[],directives:[],selectionSet:null}]}}]},a=function(){function n(){}return n.prototype.transformDocument=function(e){return e},n.prototype.transformForLink=function(e){return e},n.prototype.readQuery=function(e,t){return void 0===t&&(t=!1),this.read({query:e.query,variables:e.variables,optimistic:t})},n.prototype.readFragment=function(t,i){return void 0===i&&(i=!1),this.read({query:(0,e.getFragmentQueryDocument)(t.fragment,t.fragmentName),variables:t.variables,rootId:t.id,optimistic:i})},n.prototype.writeQuery=function(e){this.write({dataId:"ROOT_QUERY",result:e.data,query:e.query,variables:e.variables})},n.prototype.writeFragment=function(t){this.write({dataId:t.id,result:t.data,variables:t.variables,query:(0,e.getFragmentQueryDocument)(t.fragment,t.fragmentName)})},n.prototype.writeData=function(e){var n,a,o=e.id,u=e.data;if(void 0!==o){var l=null;try{l=this.read({rootId:o,optimistic:!1,query:r})}catch(e){}var s=l&&l.__typename||"__ClientData",d=Object.assign({__typename:s},u);this.writeFragment({id:o,fragment:(n=d,a=s,{kind:"Document",definitions:[{kind:"FragmentDefinition",typeCondition:{kind:"NamedType",name:{kind:"Name",value:a||"__FakeType"}},name:{kind:"Name",value:"GeneratedClientQuery"},selectionSet:i(n)}]}),data:d})}else this.writeQuery({query:t(u),data:u})},n}();exports.ApolloCache=a,exports.Cache=n,n||(exports.Cache=n={});
|
||||
175
node_modules/apollo-cache/lib/bundle.esm.js
generated
vendored
Normal file
175
node_modules/apollo-cache/lib/bundle.esm.js
generated
vendored
Normal file
@@ -0,0 +1,175 @@
|
||||
import { getFragmentQueryDocument } from 'apollo-utilities';
|
||||
|
||||
function queryFromPojo(obj) {
|
||||
var op = {
|
||||
kind: 'OperationDefinition',
|
||||
operation: 'query',
|
||||
name: {
|
||||
kind: 'Name',
|
||||
value: 'GeneratedClientQuery',
|
||||
},
|
||||
selectionSet: selectionSetFromObj(obj),
|
||||
};
|
||||
var out = {
|
||||
kind: 'Document',
|
||||
definitions: [op],
|
||||
};
|
||||
return out;
|
||||
}
|
||||
function fragmentFromPojo(obj, typename) {
|
||||
var frag = {
|
||||
kind: 'FragmentDefinition',
|
||||
typeCondition: {
|
||||
kind: 'NamedType',
|
||||
name: {
|
||||
kind: 'Name',
|
||||
value: typename || '__FakeType',
|
||||
},
|
||||
},
|
||||
name: {
|
||||
kind: 'Name',
|
||||
value: 'GeneratedClientQuery',
|
||||
},
|
||||
selectionSet: selectionSetFromObj(obj),
|
||||
};
|
||||
var out = {
|
||||
kind: 'Document',
|
||||
definitions: [frag],
|
||||
};
|
||||
return out;
|
||||
}
|
||||
function selectionSetFromObj(obj) {
|
||||
if (typeof obj === 'number' ||
|
||||
typeof obj === 'boolean' ||
|
||||
typeof obj === 'string' ||
|
||||
typeof obj === 'undefined' ||
|
||||
obj === null) {
|
||||
return null;
|
||||
}
|
||||
if (Array.isArray(obj)) {
|
||||
return selectionSetFromObj(obj[0]);
|
||||
}
|
||||
var selections = [];
|
||||
Object.keys(obj).forEach(function (key) {
|
||||
var nestedSelSet = selectionSetFromObj(obj[key]);
|
||||
var field = {
|
||||
kind: 'Field',
|
||||
name: {
|
||||
kind: 'Name',
|
||||
value: key,
|
||||
},
|
||||
selectionSet: nestedSelSet || undefined,
|
||||
};
|
||||
selections.push(field);
|
||||
});
|
||||
var selectionSet = {
|
||||
kind: 'SelectionSet',
|
||||
selections: selections,
|
||||
};
|
||||
return selectionSet;
|
||||
}
|
||||
var justTypenameQuery = {
|
||||
kind: 'Document',
|
||||
definitions: [
|
||||
{
|
||||
kind: 'OperationDefinition',
|
||||
operation: 'query',
|
||||
name: null,
|
||||
variableDefinitions: null,
|
||||
directives: [],
|
||||
selectionSet: {
|
||||
kind: 'SelectionSet',
|
||||
selections: [
|
||||
{
|
||||
kind: 'Field',
|
||||
alias: null,
|
||||
name: {
|
||||
kind: 'Name',
|
||||
value: '__typename',
|
||||
},
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
var ApolloCache = (function () {
|
||||
function ApolloCache() {
|
||||
}
|
||||
ApolloCache.prototype.transformDocument = function (document) {
|
||||
return document;
|
||||
};
|
||||
ApolloCache.prototype.transformForLink = function (document) {
|
||||
return document;
|
||||
};
|
||||
ApolloCache.prototype.readQuery = function (options, optimistic) {
|
||||
if (optimistic === void 0) { optimistic = false; }
|
||||
return this.read({
|
||||
query: options.query,
|
||||
variables: options.variables,
|
||||
optimistic: optimistic,
|
||||
});
|
||||
};
|
||||
ApolloCache.prototype.readFragment = function (options, optimistic) {
|
||||
if (optimistic === void 0) { optimistic = false; }
|
||||
return this.read({
|
||||
query: getFragmentQueryDocument(options.fragment, options.fragmentName),
|
||||
variables: options.variables,
|
||||
rootId: options.id,
|
||||
optimistic: optimistic,
|
||||
});
|
||||
};
|
||||
ApolloCache.prototype.writeQuery = function (options) {
|
||||
this.write({
|
||||
dataId: 'ROOT_QUERY',
|
||||
result: options.data,
|
||||
query: options.query,
|
||||
variables: options.variables,
|
||||
});
|
||||
};
|
||||
ApolloCache.prototype.writeFragment = function (options) {
|
||||
this.write({
|
||||
dataId: options.id,
|
||||
result: options.data,
|
||||
variables: options.variables,
|
||||
query: getFragmentQueryDocument(options.fragment, options.fragmentName),
|
||||
});
|
||||
};
|
||||
ApolloCache.prototype.writeData = function (_a) {
|
||||
var id = _a.id, data = _a.data;
|
||||
if (typeof id !== 'undefined') {
|
||||
var typenameResult = null;
|
||||
try {
|
||||
typenameResult = this.read({
|
||||
rootId: id,
|
||||
optimistic: false,
|
||||
query: justTypenameQuery,
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
var __typename = (typenameResult && typenameResult.__typename) || '__ClientData';
|
||||
var dataToWrite = Object.assign({ __typename: __typename }, data);
|
||||
this.writeFragment({
|
||||
id: id,
|
||||
fragment: fragmentFromPojo(dataToWrite, __typename),
|
||||
data: dataToWrite,
|
||||
});
|
||||
}
|
||||
else {
|
||||
this.writeQuery({ query: queryFromPojo(data), data: data });
|
||||
}
|
||||
};
|
||||
return ApolloCache;
|
||||
}());
|
||||
|
||||
var Cache;
|
||||
(function (Cache) {
|
||||
})(Cache || (Cache = {}));
|
||||
|
||||
export { ApolloCache, Cache };
|
||||
//# sourceMappingURL=bundle.esm.js.map
|
||||
1
node_modules/apollo-cache/lib/bundle.esm.js.map
generated
vendored
Normal file
1
node_modules/apollo-cache/lib/bundle.esm.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
208
node_modules/apollo-cache/lib/bundle.umd.js
generated
vendored
Normal file
208
node_modules/apollo-cache/lib/bundle.umd.js
generated
vendored
Normal file
@@ -0,0 +1,208 @@
|
||||
(function (global, factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define(["exports", "apollo-utilities"], factory);
|
||||
} else if (typeof exports !== "undefined") {
|
||||
factory(exports, require("apollo-utilities"));
|
||||
} else {
|
||||
var mod = {
|
||||
exports: {}
|
||||
};
|
||||
factory(mod.exports, global.apolloUtilities);
|
||||
global.unknown = mod.exports;
|
||||
}
|
||||
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _apolloUtilities) {
|
||||
|
||||
_exports.__esModule = true;
|
||||
_exports.Cache = _exports.ApolloCache = void 0;
|
||||
|
||||
function queryFromPojo(obj) {
|
||||
var op = {
|
||||
kind: 'OperationDefinition',
|
||||
operation: 'query',
|
||||
name: {
|
||||
kind: 'Name',
|
||||
value: 'GeneratedClientQuery'
|
||||
},
|
||||
selectionSet: selectionSetFromObj(obj)
|
||||
};
|
||||
var out = {
|
||||
kind: 'Document',
|
||||
definitions: [op]
|
||||
};
|
||||
return out;
|
||||
}
|
||||
|
||||
function fragmentFromPojo(obj, typename) {
|
||||
var frag = {
|
||||
kind: 'FragmentDefinition',
|
||||
typeCondition: {
|
||||
kind: 'NamedType',
|
||||
name: {
|
||||
kind: 'Name',
|
||||
value: typename || '__FakeType'
|
||||
}
|
||||
},
|
||||
name: {
|
||||
kind: 'Name',
|
||||
value: 'GeneratedClientQuery'
|
||||
},
|
||||
selectionSet: selectionSetFromObj(obj)
|
||||
};
|
||||
var out = {
|
||||
kind: 'Document',
|
||||
definitions: [frag]
|
||||
};
|
||||
return out;
|
||||
}
|
||||
|
||||
function selectionSetFromObj(obj) {
|
||||
if (typeof obj === 'number' || typeof obj === 'boolean' || typeof obj === 'string' || typeof obj === 'undefined' || obj === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (Array.isArray(obj)) {
|
||||
return selectionSetFromObj(obj[0]);
|
||||
}
|
||||
|
||||
var selections = [];
|
||||
Object.keys(obj).forEach(function (key) {
|
||||
var nestedSelSet = selectionSetFromObj(obj[key]);
|
||||
var field = {
|
||||
kind: 'Field',
|
||||
name: {
|
||||
kind: 'Name',
|
||||
value: key
|
||||
},
|
||||
selectionSet: nestedSelSet || undefined
|
||||
};
|
||||
selections.push(field);
|
||||
});
|
||||
var selectionSet = {
|
||||
kind: 'SelectionSet',
|
||||
selections: selections
|
||||
};
|
||||
return selectionSet;
|
||||
}
|
||||
|
||||
var justTypenameQuery = {
|
||||
kind: 'Document',
|
||||
definitions: [{
|
||||
kind: 'OperationDefinition',
|
||||
operation: 'query',
|
||||
name: null,
|
||||
variableDefinitions: null,
|
||||
directives: [],
|
||||
selectionSet: {
|
||||
kind: 'SelectionSet',
|
||||
selections: [{
|
||||
kind: 'Field',
|
||||
alias: null,
|
||||
name: {
|
||||
kind: 'Name',
|
||||
value: '__typename'
|
||||
},
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null
|
||||
}]
|
||||
}
|
||||
}]
|
||||
};
|
||||
|
||||
var ApolloCache = function () {
|
||||
function ApolloCache() {}
|
||||
|
||||
ApolloCache.prototype.transformDocument = function (document) {
|
||||
return document;
|
||||
};
|
||||
|
||||
ApolloCache.prototype.transformForLink = function (document) {
|
||||
return document;
|
||||
};
|
||||
|
||||
ApolloCache.prototype.readQuery = function (options, optimistic) {
|
||||
if (optimistic === void 0) {
|
||||
optimistic = false;
|
||||
}
|
||||
|
||||
return this.read({
|
||||
query: options.query,
|
||||
variables: options.variables,
|
||||
optimistic: optimistic
|
||||
});
|
||||
};
|
||||
|
||||
ApolloCache.prototype.readFragment = function (options, optimistic) {
|
||||
if (optimistic === void 0) {
|
||||
optimistic = false;
|
||||
}
|
||||
|
||||
return this.read({
|
||||
query: (0, _apolloUtilities.getFragmentQueryDocument)(options.fragment, options.fragmentName),
|
||||
variables: options.variables,
|
||||
rootId: options.id,
|
||||
optimistic: optimistic
|
||||
});
|
||||
};
|
||||
|
||||
ApolloCache.prototype.writeQuery = function (options) {
|
||||
this.write({
|
||||
dataId: 'ROOT_QUERY',
|
||||
result: options.data,
|
||||
query: options.query,
|
||||
variables: options.variables
|
||||
});
|
||||
};
|
||||
|
||||
ApolloCache.prototype.writeFragment = function (options) {
|
||||
this.write({
|
||||
dataId: options.id,
|
||||
result: options.data,
|
||||
variables: options.variables,
|
||||
query: (0, _apolloUtilities.getFragmentQueryDocument)(options.fragment, options.fragmentName)
|
||||
});
|
||||
};
|
||||
|
||||
ApolloCache.prototype.writeData = function (_a) {
|
||||
var id = _a.id,
|
||||
data = _a.data;
|
||||
|
||||
if (typeof id !== 'undefined') {
|
||||
var typenameResult = null;
|
||||
|
||||
try {
|
||||
typenameResult = this.read({
|
||||
rootId: id,
|
||||
optimistic: false,
|
||||
query: justTypenameQuery
|
||||
});
|
||||
} catch (e) {}
|
||||
|
||||
var __typename = typenameResult && typenameResult.__typename || '__ClientData';
|
||||
|
||||
var dataToWrite = Object.assign({
|
||||
__typename: __typename
|
||||
}, data);
|
||||
this.writeFragment({
|
||||
id: id,
|
||||
fragment: fragmentFromPojo(dataToWrite, __typename),
|
||||
data: dataToWrite
|
||||
});
|
||||
} else {
|
||||
this.writeQuery({
|
||||
query: queryFromPojo(data),
|
||||
data: data
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return ApolloCache;
|
||||
}();
|
||||
|
||||
_exports.ApolloCache = ApolloCache;
|
||||
var Cache;
|
||||
_exports.Cache = Cache;
|
||||
|
||||
(function (Cache) {})(Cache || (_exports.Cache = Cache = {}));
|
||||
|
||||
});
|
||||
1
node_modules/apollo-cache/lib/bundle.umd.js.map
generated
vendored
Normal file
1
node_modules/apollo-cache/lib/bundle.umd.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
24
node_modules/apollo-cache/lib/cache.d.ts
generated
vendored
Normal file
24
node_modules/apollo-cache/lib/cache.d.ts
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import { DocumentNode } from 'graphql';
|
||||
import { DataProxy, Cache } from './types';
|
||||
export declare type Transaction<T> = (c: ApolloCache<T>) => void;
|
||||
export declare abstract class ApolloCache<TSerialized> implements DataProxy {
|
||||
abstract read<T, TVariables = any>(query: Cache.ReadOptions<TVariables>): T | null;
|
||||
abstract write<TResult = any, TVariables = any>(write: Cache.WriteOptions<TResult, TVariables>): void;
|
||||
abstract diff<T>(query: Cache.DiffOptions): Cache.DiffResult<T>;
|
||||
abstract watch(watch: Cache.WatchOptions): () => void;
|
||||
abstract evict<TVariables = any>(query: Cache.EvictOptions<TVariables>): Cache.EvictionResult;
|
||||
abstract reset(): Promise<void>;
|
||||
abstract restore(serializedState: TSerialized): ApolloCache<TSerialized>;
|
||||
abstract extract(optimistic?: boolean): TSerialized;
|
||||
abstract removeOptimistic(id: string): void;
|
||||
abstract performTransaction(transaction: Transaction<TSerialized>): void;
|
||||
abstract recordOptimisticTransaction(transaction: Transaction<TSerialized>, id: string): void;
|
||||
transformDocument(document: DocumentNode): DocumentNode;
|
||||
transformForLink(document: DocumentNode): DocumentNode;
|
||||
readQuery<QueryType, TVariables = any>(options: DataProxy.Query<TVariables>, optimistic?: boolean): QueryType | null;
|
||||
readFragment<FragmentType, TVariables = any>(options: DataProxy.Fragment<TVariables>, optimistic?: boolean): FragmentType | null;
|
||||
writeQuery<TData = any, TVariables = any>(options: Cache.WriteQueryOptions<TData, TVariables>): void;
|
||||
writeFragment<TData = any, TVariables = any>(options: Cache.WriteFragmentOptions<TData, TVariables>): void;
|
||||
writeData<TData = any>({ id, data, }: Cache.WriteDataOptions<TData>): void;
|
||||
}
|
||||
//# sourceMappingURL=cache.d.ts.map
|
||||
1
node_modules/apollo-cache/lib/cache.d.ts.map
generated
vendored
Normal file
1
node_modules/apollo-cache/lib/cache.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["src/cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGvC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAG3C,oBAAY,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;AAEzD,8BAAsB,WAAW,CAAC,WAAW,CAAE,YAAW,SAAS;aAGjD,IAAI,CAAC,CAAC,EAAE,UAAU,GAAG,GAAG,EACtC,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,UAAU,CAAC,GACnC,CAAC,GAAG,IAAI;aACK,KAAK,CAAC,OAAO,GAAG,GAAG,EAAE,UAAU,GAAG,GAAG,EACnD,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,UAAU,CAAC,GAC7C,IAAI;aACS,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;aACtD,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,YAAY,GAAG,MAAM,IAAI;aAC5C,KAAK,CAAC,UAAU,GAAG,GAAG,EACpC,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,UAAU,CAAC,GACpC,KAAK,CAAC,cAAc;aACP,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;aAUtB,OAAO,CACrB,eAAe,EAAE,WAAW,GAC3B,WAAW,CAAC,WAAW,CAAC;aAKX,OAAO,CAAC,UAAU,CAAC,EAAE,OAAO,GAAG,WAAW;aAG1C,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;aAGlC,kBAAkB,CAChC,WAAW,EAAE,WAAW,CAAC,WAAW,CAAC,GACpC,IAAI;aACS,2BAA2B,CACzC,WAAW,EAAE,WAAW,CAAC,WAAW,CAAC,EACrC,EAAE,EAAE,MAAM,GACT,IAAI;IAGA,iBAAiB,CAAC,QAAQ,EAAE,YAAY,GAAG,YAAY;IAIvD,gBAAgB,CAAC,QAAQ,EAAE,YAAY,GAAG,YAAY;IAUtD,SAAS,CAAC,SAAS,EAAE,UAAU,GAAG,GAAG,EAC1C,OAAO,EAAE,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,EACpC,UAAU,GAAE,OAAe,GAC1B,SAAS,GAAG,IAAI;IAQZ,YAAY,CAAC,YAAY,EAAE,UAAU,GAAG,GAAG,EAChD,OAAO,EAAE,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,EACvC,UAAU,GAAE,OAAe,GAC1B,YAAY,GAAG,IAAI;IASf,UAAU,CAAC,KAAK,GAAG,GAAG,EAAE,UAAU,GAAG,GAAG,EAC7C,OAAO,EAAE,KAAK,CAAC,iBAAiB,CAAC,KAAK,EAAE,UAAU,CAAC,GAClD,IAAI;IASA,aAAa,CAAC,KAAK,GAAG,GAAG,EAAE,UAAU,GAAG,GAAG,EAChD,OAAO,EAAE,KAAK,CAAC,oBAAoB,CAAC,KAAK,EAAE,UAAU,CAAC,GACrD,IAAI;IASA,SAAS,CAAC,KAAK,GAAG,GAAG,EAAE,EAC5B,EAAE,EACF,IAAI,GACL,EAAE,KAAK,CAAC,gBAAgB,CAAC,KAAK,CAAC,GAAG,IAAI;CAiCxC"}
|
||||
75
node_modules/apollo-cache/lib/cache.js
generated
vendored
Normal file
75
node_modules/apollo-cache/lib/cache.js
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var apollo_utilities_1 = require("apollo-utilities");
|
||||
var utils_1 = require("./utils");
|
||||
var ApolloCache = (function () {
|
||||
function ApolloCache() {
|
||||
}
|
||||
ApolloCache.prototype.transformDocument = function (document) {
|
||||
return document;
|
||||
};
|
||||
ApolloCache.prototype.transformForLink = function (document) {
|
||||
return document;
|
||||
};
|
||||
ApolloCache.prototype.readQuery = function (options, optimistic) {
|
||||
if (optimistic === void 0) { optimistic = false; }
|
||||
return this.read({
|
||||
query: options.query,
|
||||
variables: options.variables,
|
||||
optimistic: optimistic,
|
||||
});
|
||||
};
|
||||
ApolloCache.prototype.readFragment = function (options, optimistic) {
|
||||
if (optimistic === void 0) { optimistic = false; }
|
||||
return this.read({
|
||||
query: apollo_utilities_1.getFragmentQueryDocument(options.fragment, options.fragmentName),
|
||||
variables: options.variables,
|
||||
rootId: options.id,
|
||||
optimistic: optimistic,
|
||||
});
|
||||
};
|
||||
ApolloCache.prototype.writeQuery = function (options) {
|
||||
this.write({
|
||||
dataId: 'ROOT_QUERY',
|
||||
result: options.data,
|
||||
query: options.query,
|
||||
variables: options.variables,
|
||||
});
|
||||
};
|
||||
ApolloCache.prototype.writeFragment = function (options) {
|
||||
this.write({
|
||||
dataId: options.id,
|
||||
result: options.data,
|
||||
variables: options.variables,
|
||||
query: apollo_utilities_1.getFragmentQueryDocument(options.fragment, options.fragmentName),
|
||||
});
|
||||
};
|
||||
ApolloCache.prototype.writeData = function (_a) {
|
||||
var id = _a.id, data = _a.data;
|
||||
if (typeof id !== 'undefined') {
|
||||
var typenameResult = null;
|
||||
try {
|
||||
typenameResult = this.read({
|
||||
rootId: id,
|
||||
optimistic: false,
|
||||
query: utils_1.justTypenameQuery,
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
var __typename = (typenameResult && typenameResult.__typename) || '__ClientData';
|
||||
var dataToWrite = Object.assign({ __typename: __typename }, data);
|
||||
this.writeFragment({
|
||||
id: id,
|
||||
fragment: utils_1.fragmentFromPojo(dataToWrite, __typename),
|
||||
data: dataToWrite,
|
||||
});
|
||||
}
|
||||
else {
|
||||
this.writeQuery({ query: utils_1.queryFromPojo(data), data: data });
|
||||
}
|
||||
};
|
||||
return ApolloCache;
|
||||
}());
|
||||
exports.ApolloCache = ApolloCache;
|
||||
//# sourceMappingURL=cache.js.map
|
||||
1
node_modules/apollo-cache/lib/cache.js.map
generated
vendored
Normal file
1
node_modules/apollo-cache/lib/cache.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":";;AACA,qDAA4D;AAG5D,iCAA6E;AAI7E;IAAA;IA6IA,CAAC;IA/FQ,uCAAiB,GAAxB,UAAyB,QAAsB;QAC7C,OAAO,QAAQ,CAAC;IAClB,CAAC;IAEM,sCAAgB,GAAvB,UAAwB,QAAsB;QAC5C,OAAO,QAAQ,CAAC;IAClB,CAAC;IAQM,+BAAS,GAAhB,UACE,OAAoC,EACpC,UAA2B;QAA3B,2BAAA,EAAA,kBAA2B;QAE3B,OAAO,IAAI,CAAC,IAAI,CAAC;YACf,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,UAAU,YAAA;SACX,CAAC,CAAC;IACL,CAAC;IAEM,kCAAY,GAAnB,UACE,OAAuC,EACvC,UAA2B;QAA3B,2BAAA,EAAA,kBAA2B;QAE3B,OAAO,IAAI,CAAC,IAAI,CAAC;YACf,KAAK,EAAE,2CAAwB,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,YAAY,CAAC;YACvE,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,MAAM,EAAE,OAAO,CAAC,EAAE;YAClB,UAAU,YAAA;SACX,CAAC,CAAC;IACL,CAAC;IAEM,gCAAU,GAAjB,UACE,OAAmD;QAEnD,IAAI,CAAC,KAAK,CAAC;YACT,MAAM,EAAE,YAAY;YACpB,MAAM,EAAE,OAAO,CAAC,IAAI;YACpB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,SAAS,EAAE,OAAO,CAAC,SAAS;SAC7B,CAAC,CAAC;IACL,CAAC;IAEM,mCAAa,GAApB,UACE,OAAsD;QAEtD,IAAI,CAAC,KAAK,CAAC;YACT,MAAM,EAAE,OAAO,CAAC,EAAE;YAClB,MAAM,EAAE,OAAO,CAAC,IAAI;YACpB,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,KAAK,EAAE,2CAAwB,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,YAAY,CAAC;SACxE,CAAC,CAAC;IACL,CAAC;IAEM,+BAAS,GAAhB,UAA8B,EAGE;YAF9B,UAAE,EACF,cAAI;QAEJ,IAAI,OAAO,EAAE,KAAK,WAAW,EAAE;YAC7B,IAAI,cAAc,GAAG,IAAI,CAAC;YAK1B,IAAI;gBACF,cAAc,GAAG,IAAI,CAAC,IAAI,CAAM;oBAC9B,MAAM,EAAE,EAAE;oBACV,UAAU,EAAE,KAAK;oBACjB,KAAK,EAAE,yBAAiB;iBACzB,CAAC,CAAC;aACJ;YAAC,OAAO,CAAC,EAAE;aAEX;YAGD,IAAM,UAAU,GACd,CAAC,cAAc,IAAI,cAAc,CAAC,UAAU,CAAC,IAAI,cAAc,CAAC;YAGlE,IAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,UAAU,YAAA,EAAE,EAAE,IAAI,CAAC,CAAC;YAExD,IAAI,CAAC,aAAa,CAAC;gBACjB,EAAE,IAAA;gBACF,QAAQ,EAAE,wBAAgB,CAAC,WAAW,EAAE,UAAU,CAAC;gBACnD,IAAI,EAAE,WAAW;aAClB,CAAC,CAAC;SACJ;aAAM;YACL,IAAI,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,qBAAa,CAAC,IAAI,CAAC,EAAE,IAAI,MAAA,EAAE,CAAC,CAAC;SACvD;IACH,CAAC;IACH,kBAAC;AAAD,CAAC,AA7ID,IA6IC;AA7IqB,kCAAW"}
|
||||
3
node_modules/apollo-cache/lib/index.d.ts
generated
vendored
Normal file
3
node_modules/apollo-cache/lib/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export * from './cache';
|
||||
export * from './types';
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
node_modules/apollo-cache/lib/index.d.ts.map
generated
vendored
Normal file
1
node_modules/apollo-cache/lib/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
|
||||
6
node_modules/apollo-cache/lib/index.js
generated
vendored
Normal file
6
node_modules/apollo-cache/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
tslib_1.__exportStar(require("./cache"), exports);
|
||||
tslib_1.__exportStar(require("./types"), exports);
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/apollo-cache/lib/index.js.map
generated
vendored
Normal file
1
node_modules/apollo-cache/lib/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,kDAAwB;AACxB,kDAAwB"}
|
||||
31
node_modules/apollo-cache/lib/types/Cache.d.ts
generated
vendored
Normal file
31
node_modules/apollo-cache/lib/types/Cache.d.ts
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
import { DataProxy } from './DataProxy';
|
||||
export declare namespace Cache {
|
||||
type WatchCallback = (newData: any) => void;
|
||||
interface EvictionResult {
|
||||
success: Boolean;
|
||||
}
|
||||
interface ReadOptions<TVariables = any> extends DataProxy.Query<TVariables> {
|
||||
rootId?: string;
|
||||
previousResult?: any;
|
||||
optimistic: boolean;
|
||||
}
|
||||
interface WriteOptions<TResult = any, TVariables = any> extends DataProxy.Query<TVariables> {
|
||||
dataId: string;
|
||||
result: TResult;
|
||||
}
|
||||
interface DiffOptions extends ReadOptions {
|
||||
returnPartialData?: boolean;
|
||||
}
|
||||
interface WatchOptions extends ReadOptions {
|
||||
callback: WatchCallback;
|
||||
}
|
||||
interface EvictOptions<TVariables = any> extends DataProxy.Query<TVariables> {
|
||||
rootId?: string;
|
||||
}
|
||||
export import DiffResult = DataProxy.DiffResult;
|
||||
export import WriteQueryOptions = DataProxy.WriteQueryOptions;
|
||||
export import WriteFragmentOptions = DataProxy.WriteFragmentOptions;
|
||||
export import WriteDataOptions = DataProxy.WriteDataOptions;
|
||||
export import Fragment = DataProxy.Fragment;
|
||||
}
|
||||
//# sourceMappingURL=Cache.d.ts.map
|
||||
1
node_modules/apollo-cache/lib/types/Cache.d.ts.map
generated
vendored
Normal file
1
node_modules/apollo-cache/lib/types/Cache.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Cache.d.ts","sourceRoot":"","sources":["../src/types/Cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,yBAAiB,KAAK,CAAC;IACrB,KAAY,aAAa,GAAG,CAAC,OAAO,EAAE,GAAG,KAAK,IAAI,CAAC;IACnD,UAAiB,cAAc;QAC7B,OAAO,EAAE,OAAO,CAAC;KAClB;IAED,UAAiB,WAAW,CAAC,UAAU,GAAG,GAAG,CAC3C,SAAQ,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC;QACnC,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,cAAc,CAAC,EAAE,GAAG,CAAC;QACrB,UAAU,EAAE,OAAO,CAAC;KACrB;IAED,UAAiB,YAAY,CAAC,OAAO,GAAG,GAAG,EAAE,UAAU,GAAG,GAAG,CAC3D,SAAQ,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC;QACnC,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,OAAO,CAAC;KACjB;IAED,UAAiB,WAAY,SAAQ,WAAW;QAC9C,iBAAiB,CAAC,EAAE,OAAO,CAAC;KAC7B;IAED,UAAiB,YAAa,SAAQ,WAAW;QAC/C,QAAQ,EAAE,aAAa,CAAC;KACzB;IAED,UAAiB,YAAY,CAAC,UAAU,GAAG,GAAG,CAC5C,SAAQ,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC;QACnC,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;IAED,MAAM,QAAQ,UAAU,GAAG,SAAS,CAAC,UAAU,CAAC;IAChD,MAAM,QAAQ,iBAAiB,GAAG,SAAS,CAAC,iBAAiB,CAAC;IAC9D,MAAM,QAAQ,oBAAoB,GAAG,SAAS,CAAC,oBAAoB,CAAC;IACpE,MAAM,QAAQ,gBAAgB,GAAG,SAAS,CAAC,gBAAgB,CAAC;IAC5D,MAAM,QAAQ,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC;CAC7C"}
|
||||
6
node_modules/apollo-cache/lib/types/Cache.js
generated
vendored
Normal file
6
node_modules/apollo-cache/lib/types/Cache.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var Cache;
|
||||
(function (Cache) {
|
||||
})(Cache = exports.Cache || (exports.Cache = {}));
|
||||
//# sourceMappingURL=Cache.js.map
|
||||
1
node_modules/apollo-cache/lib/types/Cache.js.map
generated
vendored
Normal file
1
node_modules/apollo-cache/lib/types/Cache.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Cache.js","sourceRoot":"","sources":["../../src/types/Cache.ts"],"names":[],"mappings":";;AAEA,IAAiB,KAAK,CAqCrB;AArCD,WAAiB,KAAK;AAqCtB,CAAC,EArCgB,KAAK,GAAL,aAAK,KAAL,aAAK,QAqCrB"}
|
||||
35
node_modules/apollo-cache/lib/types/DataProxy.d.ts
generated
vendored
Normal file
35
node_modules/apollo-cache/lib/types/DataProxy.d.ts
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
import { DocumentNode } from 'graphql';
|
||||
export declare namespace DataProxy {
|
||||
interface Query<TVariables> {
|
||||
query: DocumentNode;
|
||||
variables?: TVariables;
|
||||
}
|
||||
interface Fragment<TVariables> {
|
||||
id: string;
|
||||
fragment: DocumentNode;
|
||||
fragmentName?: string;
|
||||
variables?: TVariables;
|
||||
}
|
||||
interface WriteQueryOptions<TData, TVariables> extends Query<TVariables> {
|
||||
data: TData;
|
||||
}
|
||||
interface WriteFragmentOptions<TData, TVariables> extends Fragment<TVariables> {
|
||||
data: TData;
|
||||
}
|
||||
interface WriteDataOptions<TData> {
|
||||
data: TData;
|
||||
id?: string;
|
||||
}
|
||||
type DiffResult<T> = {
|
||||
result?: T;
|
||||
complete?: boolean;
|
||||
};
|
||||
}
|
||||
export interface DataProxy {
|
||||
readQuery<QueryType, TVariables = any>(options: DataProxy.Query<TVariables>, optimistic?: boolean): QueryType | null;
|
||||
readFragment<FragmentType, TVariables = any>(options: DataProxy.Fragment<TVariables>, optimistic?: boolean): FragmentType | null;
|
||||
writeQuery<TData = any, TVariables = any>(options: DataProxy.WriteQueryOptions<TData, TVariables>): void;
|
||||
writeFragment<TData = any, TVariables = any>(options: DataProxy.WriteFragmentOptions<TData, TVariables>): void;
|
||||
writeData<TData = any>(options: DataProxy.WriteDataOptions<TData>): void;
|
||||
}
|
||||
//# sourceMappingURL=DataProxy.d.ts.map
|
||||
1
node_modules/apollo-cache/lib/types/DataProxy.d.ts.map
generated
vendored
Normal file
1
node_modules/apollo-cache/lib/types/DataProxy.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"DataProxy.d.ts","sourceRoot":"","sources":["../src/types/DataProxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,yBAAiB,SAAS,CAAC;IACzB,UAAiB,KAAK,CAAC,UAAU;QAM/B,KAAK,EAAE,YAAY,CAAC;QAKpB,SAAS,CAAC,EAAE,UAAU,CAAC;KACxB;IAED,UAAiB,QAAQ,CAAC,UAAU;QAMlC,EAAE,EAAE,MAAM,CAAC;QAQX,QAAQ,EAAE,YAAY,CAAC;QAOvB,YAAY,CAAC,EAAE,MAAM,CAAC;QAKtB,SAAS,CAAC,EAAE,UAAU,CAAC;KACxB;IAED,UAAiB,iBAAiB,CAAC,KAAK,EAAE,UAAU,CAClD,SAAQ,KAAK,CAAC,UAAU,CAAC;QAIzB,IAAI,EAAE,KAAK,CAAC;KACb;IAED,UAAiB,oBAAoB,CAAC,KAAK,EAAE,UAAU,CACrD,SAAQ,QAAQ,CAAC,UAAU,CAAC;QAI5B,IAAI,EAAE,KAAK,CAAC;KACb;IAED,UAAiB,gBAAgB,CAAC,KAAK;QAMrC,IAAI,EAAE,KAAK,CAAC;QACZ,EAAE,CAAC,EAAE,MAAM,CAAC;KACb;IAED,KAAY,UAAU,CAAC,CAAC,IAAI;QAC1B,MAAM,CAAC,EAAE,CAAC,CAAC;QACX,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB,CAAC;CACH;AAQD,MAAM,WAAW,SAAS;IAIxB,SAAS,CAAC,SAAS,EAAE,UAAU,GAAG,GAAG,EACnC,OAAO,EAAE,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,EACpC,UAAU,CAAC,EAAE,OAAO,GACnB,SAAS,GAAG,IAAI,CAAC;IAOpB,YAAY,CAAC,YAAY,EAAE,UAAU,GAAG,GAAG,EACzC,OAAO,EAAE,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,EACvC,UAAU,CAAC,EAAE,OAAO,GACnB,YAAY,GAAG,IAAI,CAAC;IAKvB,UAAU,CAAC,KAAK,GAAG,GAAG,EAAE,UAAU,GAAG,GAAG,EACtC,OAAO,EAAE,SAAS,CAAC,iBAAiB,CAAC,KAAK,EAAE,UAAU,CAAC,GACtD,IAAI,CAAC;IAOR,aAAa,CAAC,KAAK,GAAG,GAAG,EAAE,UAAU,GAAG,GAAG,EACzC,OAAO,EAAE,SAAS,CAAC,oBAAoB,CAAC,KAAK,EAAE,UAAU,CAAC,GACzD,IAAI,CAAC;IAQR,SAAS,CAAC,KAAK,GAAG,GAAG,EAAE,OAAO,EAAE,SAAS,CAAC,gBAAgB,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;CAC1E"}
|
||||
3
node_modules/apollo-cache/lib/types/DataProxy.js
generated
vendored
Normal file
3
node_modules/apollo-cache/lib/types/DataProxy.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=DataProxy.js.map
|
||||
1
node_modules/apollo-cache/lib/types/DataProxy.js.map
generated
vendored
Normal file
1
node_modules/apollo-cache/lib/types/DataProxy.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"DataProxy.js","sourceRoot":"","sources":["../../src/types/DataProxy.ts"],"names":[],"mappings":""}
|
||||
3
node_modules/apollo-cache/lib/types/index.d.ts
generated
vendored
Normal file
3
node_modules/apollo-cache/lib/types/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export * from './DataProxy';
|
||||
export * from './Cache';
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
node_modules/apollo-cache/lib/types/index.d.ts.map
generated
vendored
Normal file
1
node_modules/apollo-cache/lib/types/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC"}
|
||||
5
node_modules/apollo-cache/lib/types/index.js
generated
vendored
Normal file
5
node_modules/apollo-cache/lib/types/index.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
tslib_1.__exportStar(require("./Cache"), exports);
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/apollo-cache/lib/types/index.js.map
generated
vendored
Normal file
1
node_modules/apollo-cache/lib/types/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;AACA,kDAAwB"}
|
||||
5
node_modules/apollo-cache/lib/utils.d.ts
generated
vendored
Normal file
5
node_modules/apollo-cache/lib/utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { DocumentNode } from 'graphql';
|
||||
export declare function queryFromPojo(obj: any): DocumentNode;
|
||||
export declare function fragmentFromPojo(obj: any, typename?: string): DocumentNode;
|
||||
export declare const justTypenameQuery: DocumentNode;
|
||||
//# sourceMappingURL=utils.d.ts.map
|
||||
1
node_modules/apollo-cache/lib/utils.d.ts.map
generated
vendored
Normal file
1
node_modules/apollo-cache/lib/utils.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAKb,MAAM,SAAS,CAAC;AAEjB,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,YAAY,CAiBpD;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,YAAY,CAuB1E;AA6CD,eAAO,MAAM,iBAAiB,EAAE,YA2B/B,CAAC"}
|
||||
101
node_modules/apollo-cache/lib/utils.js
generated
vendored
Normal file
101
node_modules/apollo-cache/lib/utils.js
generated
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function queryFromPojo(obj) {
|
||||
var op = {
|
||||
kind: 'OperationDefinition',
|
||||
operation: 'query',
|
||||
name: {
|
||||
kind: 'Name',
|
||||
value: 'GeneratedClientQuery',
|
||||
},
|
||||
selectionSet: selectionSetFromObj(obj),
|
||||
};
|
||||
var out = {
|
||||
kind: 'Document',
|
||||
definitions: [op],
|
||||
};
|
||||
return out;
|
||||
}
|
||||
exports.queryFromPojo = queryFromPojo;
|
||||
function fragmentFromPojo(obj, typename) {
|
||||
var frag = {
|
||||
kind: 'FragmentDefinition',
|
||||
typeCondition: {
|
||||
kind: 'NamedType',
|
||||
name: {
|
||||
kind: 'Name',
|
||||
value: typename || '__FakeType',
|
||||
},
|
||||
},
|
||||
name: {
|
||||
kind: 'Name',
|
||||
value: 'GeneratedClientQuery',
|
||||
},
|
||||
selectionSet: selectionSetFromObj(obj),
|
||||
};
|
||||
var out = {
|
||||
kind: 'Document',
|
||||
definitions: [frag],
|
||||
};
|
||||
return out;
|
||||
}
|
||||
exports.fragmentFromPojo = fragmentFromPojo;
|
||||
function selectionSetFromObj(obj) {
|
||||
if (typeof obj === 'number' ||
|
||||
typeof obj === 'boolean' ||
|
||||
typeof obj === 'string' ||
|
||||
typeof obj === 'undefined' ||
|
||||
obj === null) {
|
||||
return null;
|
||||
}
|
||||
if (Array.isArray(obj)) {
|
||||
return selectionSetFromObj(obj[0]);
|
||||
}
|
||||
var selections = [];
|
||||
Object.keys(obj).forEach(function (key) {
|
||||
var nestedSelSet = selectionSetFromObj(obj[key]);
|
||||
var field = {
|
||||
kind: 'Field',
|
||||
name: {
|
||||
kind: 'Name',
|
||||
value: key,
|
||||
},
|
||||
selectionSet: nestedSelSet || undefined,
|
||||
};
|
||||
selections.push(field);
|
||||
});
|
||||
var selectionSet = {
|
||||
kind: 'SelectionSet',
|
||||
selections: selections,
|
||||
};
|
||||
return selectionSet;
|
||||
}
|
||||
exports.justTypenameQuery = {
|
||||
kind: 'Document',
|
||||
definitions: [
|
||||
{
|
||||
kind: 'OperationDefinition',
|
||||
operation: 'query',
|
||||
name: null,
|
||||
variableDefinitions: null,
|
||||
directives: [],
|
||||
selectionSet: {
|
||||
kind: 'SelectionSet',
|
||||
selections: [
|
||||
{
|
||||
kind: 'Field',
|
||||
alias: null,
|
||||
name: {
|
||||
kind: 'Name',
|
||||
value: '__typename',
|
||||
},
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
//# sourceMappingURL=utils.js.map
|
||||
1
node_modules/apollo-cache/lib/utils.js.map
generated
vendored
Normal file
1
node_modules/apollo-cache/lib/utils.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;AAQA,SAAgB,aAAa,CAAC,GAAQ;IACpC,IAAM,EAAE,GAA4B;QAClC,IAAI,EAAE,qBAAqB;QAC3B,SAAS,EAAE,OAAO;QAClB,IAAI,EAAE;YACJ,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE,sBAAsB;SAC9B;QACD,YAAY,EAAE,mBAAmB,CAAC,GAAG,CAAC;KACvC,CAAC;IAEF,IAAM,GAAG,GAAiB;QACxB,IAAI,EAAE,UAAU;QAChB,WAAW,EAAE,CAAC,EAAE,CAAC;KAClB,CAAC;IAEF,OAAO,GAAG,CAAC;AACb,CAAC;AAjBD,sCAiBC;AAED,SAAgB,gBAAgB,CAAC,GAAQ,EAAE,QAAiB;IAC1D,IAAM,IAAI,GAA2B;QACnC,IAAI,EAAE,oBAAoB;QAC1B,aAAa,EAAE;YACb,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE;gBACJ,IAAI,EAAE,MAAM;gBACZ,KAAK,EAAE,QAAQ,IAAI,YAAY;aAChC;SACF;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE,sBAAsB;SAC9B;QACD,YAAY,EAAE,mBAAmB,CAAC,GAAG,CAAC;KACvC,CAAC;IAEF,IAAM,GAAG,GAAiB;QACxB,IAAI,EAAE,UAAU;QAChB,WAAW,EAAE,CAAC,IAAI,CAAC;KACpB,CAAC;IAEF,OAAO,GAAG,CAAC;AACb,CAAC;AAvBD,4CAuBC;AAED,SAAS,mBAAmB,CAAC,GAAQ;IACnC,IACE,OAAO,GAAG,KAAK,QAAQ;QACvB,OAAO,GAAG,KAAK,SAAS;QACxB,OAAO,GAAG,KAAK,QAAQ;QACvB,OAAO,GAAG,KAAK,WAAW;QAC1B,GAAG,KAAK,IAAI,EACZ;QAEA,OAAO,IAAI,CAAC;KACb;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QAEtB,OAAO,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;KACpC;IAGD,IAAM,UAAU,GAAgB,EAAE,CAAC;IAEnC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,UAAA,GAAG;QAC1B,IAAM,YAAY,GAAqB,mBAAmB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QAErE,IAAM,KAAK,GAAc;YACvB,IAAI,EAAE,OAAO;YACb,IAAI,EAAE;gBACJ,IAAI,EAAE,MAAM;gBACZ,KAAK,EAAE,GAAG;aACX;YACD,YAAY,EAAE,YAAY,IAAI,SAAS;SACxC,CAAC;QAEF,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC,CAAC,CAAC;IAEH,IAAM,YAAY,GAAqB;QACrC,IAAI,EAAE,cAAc;QACpB,UAAU,YAAA;KACX,CAAC;IAEF,OAAO,YAAY,CAAC;AACtB,CAAC;AAEY,QAAA,iBAAiB,GAAiB;IAC7C,IAAI,EAAE,UAAU;IAChB,WAAW,EAAE;QACX;YACE,IAAI,EAAE,qBAAqB;YAC3B,SAAS,EAAE,OAAO;YAClB,IAAI,EAAE,IAAI;YACV,mBAAmB,EAAE,IAAI;YACzB,UAAU,EAAE,EAAE;YACd,YAAY,EAAE;gBACZ,IAAI,EAAE,cAAc;gBACpB,UAAU,EAAE;oBACV;wBACE,IAAI,EAAE,OAAO;wBACb,KAAK,EAAE,IAAI;wBACX,IAAI,EAAE;4BACJ,IAAI,EAAE,MAAM;4BACZ,KAAK,EAAE,YAAY;yBACpB;wBACD,SAAS,EAAE,EAAE;wBACb,UAAU,EAAE,EAAE;wBACd,YAAY,EAAE,IAAI;qBACnB;iBACF;aACF;SACF;KACF;CACF,CAAC"}
|
||||
46
node_modules/apollo-cache/package.json
generated
vendored
Normal file
46
node_modules/apollo-cache/package.json
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"name": "apollo-cache",
|
||||
"version": "1.3.5",
|
||||
"description": "Core abstract of Caching layer for Apollo Client",
|
||||
"author": "James Baxley <james@meteor.com>",
|
||||
"contributors": [
|
||||
"James Baxley <james@meteor.com>",
|
||||
"Jonas Helfer <jonas@helfer.email>",
|
||||
"Sashko Stubailo <sashko@stubailo.com>",
|
||||
"James Burgess <jamesmillerburgess@gmail.com>"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "./lib/bundle.cjs.js",
|
||||
"module": "./lib/bundle.esm.js",
|
||||
"typings": "./lib/index.d.ts",
|
||||
"sideEffects": false,
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/apollographql/apollo-client.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/apollographql/apollo-client/issues"
|
||||
},
|
||||
"homepage": "https://github.com/apollographql/apollo-client#readme",
|
||||
"scripts": {
|
||||
"prepare": "npm run lint && npm run build",
|
||||
"coverage": "jest --coverage",
|
||||
"test": "tsc -p tsconfig.json --noEmit && jest",
|
||||
"lint": "tslint -c \"../../config/tslint.json\" -p tsconfig.json src/*.ts && tslint -c \"../../config/tslint.json\" -p tsconfig.json tests/*.ts",
|
||||
"prebuild": "npm run clean",
|
||||
"build": "tsc -b .",
|
||||
"postbuild": "npm run bundle",
|
||||
"bundle": "npx rollup -c rollup.config.js",
|
||||
"watch": "../../node_modules/tsc-watch/index.js --onSuccess \"npm run postbuild\"",
|
||||
"clean": "rm -rf coverage/* lib/*",
|
||||
"prepublishOnly": "npm run clean && npm run build"
|
||||
},
|
||||
"dependencies": {
|
||||
"apollo-utilities": "^1.3.4",
|
||||
"tslib": "^1.10.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"graphql": "^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0"
|
||||
},
|
||||
"gitHead": "d22394c419ff7d678afb5e7d4cd1df16ed803ead"
|
||||
}
|
||||
63
node_modules/apollo-cache/src/__tests__/__snapshots__/utils.ts.snap
generated
vendored
Normal file
63
node_modules/apollo-cache/src/__tests__/__snapshots__/utils.ts.snap
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[
|
||||
`writing data with no query converts a JavaScript object to a query correctly arrays 1`
|
||||
] = `
|
||||
"query GeneratedClientQuery {
|
||||
number
|
||||
bool
|
||||
nested {
|
||||
bool2
|
||||
undef
|
||||
nullField
|
||||
str
|
||||
}
|
||||
}
|
||||
"
|
||||
`;
|
||||
|
||||
exports[
|
||||
`writing data with no query converts a JavaScript object to a query correctly basic 1`
|
||||
] = `
|
||||
"query GeneratedClientQuery {
|
||||
number
|
||||
bool
|
||||
bool2
|
||||
undef
|
||||
nullField
|
||||
str
|
||||
}
|
||||
"
|
||||
`;
|
||||
|
||||
exports[
|
||||
`writing data with no query converts a JavaScript object to a query correctly fragments 1`
|
||||
] = `
|
||||
"fragment GeneratedClientQuery on __FakeType {
|
||||
number
|
||||
bool
|
||||
nested {
|
||||
bool2
|
||||
undef
|
||||
nullField
|
||||
str
|
||||
}
|
||||
}
|
||||
"
|
||||
`;
|
||||
|
||||
exports[
|
||||
`writing data with no query converts a JavaScript object to a query correctly nested 1`
|
||||
] = `
|
||||
"query GeneratedClientQuery {
|
||||
number
|
||||
bool
|
||||
nested {
|
||||
bool2
|
||||
undef
|
||||
nullField
|
||||
str
|
||||
}
|
||||
}
|
||||
"
|
||||
`;
|
||||
149
node_modules/apollo-cache/src/__tests__/cache.ts
generated
vendored
Normal file
149
node_modules/apollo-cache/src/__tests__/cache.ts
generated
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
import { ApolloCache as Cache } from '../cache';
|
||||
|
||||
class TestCache extends Cache {}
|
||||
|
||||
describe('abstract cache', () => {
|
||||
describe('transformDocument', () => {
|
||||
it('returns the document', () => {
|
||||
const test = new TestCache();
|
||||
expect(test.transformDocument('a')).toBe('a');
|
||||
});
|
||||
});
|
||||
|
||||
describe('transformForLink', () => {
|
||||
it('returns the document', () => {
|
||||
const test = new TestCache();
|
||||
expect(test.transformForLink('a')).toBe('a');
|
||||
});
|
||||
});
|
||||
|
||||
describe('readQuery', () => {
|
||||
it('runs the read method', () => {
|
||||
const test = new TestCache();
|
||||
test.read = jest.fn();
|
||||
|
||||
test.readQuery({});
|
||||
expect(test.read).toBeCalled();
|
||||
});
|
||||
|
||||
it('defaults optimistic to false', () => {
|
||||
const test = new TestCache();
|
||||
test.read = ({ optimistic }) => optimistic;
|
||||
|
||||
expect(test.readQuery({})).toBe(false);
|
||||
expect(test.readQuery({}, true)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('readFragment', () => {
|
||||
it('runs the read method', () => {
|
||||
const test = new TestCache();
|
||||
test.read = jest.fn();
|
||||
const fragment = {
|
||||
id: 'frag',
|
||||
fragment: gql`
|
||||
fragment a on b {
|
||||
name
|
||||
}
|
||||
`,
|
||||
};
|
||||
|
||||
test.readFragment(fragment);
|
||||
expect(test.read).toBeCalled();
|
||||
});
|
||||
|
||||
it('defaults optimistic to false', () => {
|
||||
const test = new TestCache();
|
||||
test.read = ({ optimistic }) => optimistic;
|
||||
const fragment = {
|
||||
id: 'frag',
|
||||
fragment: gql`
|
||||
fragment a on b {
|
||||
name
|
||||
}
|
||||
`,
|
||||
};
|
||||
|
||||
expect(test.readFragment(fragment)).toBe(false);
|
||||
expect(test.readFragment(fragment, true)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('writeQuery', () => {
|
||||
it('runs the write method', () => {
|
||||
const test = new TestCache();
|
||||
test.write = jest.fn();
|
||||
|
||||
test.writeQuery({});
|
||||
expect(test.write).toBeCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('writeFragment', () => {
|
||||
it('runs the write method', () => {
|
||||
const test = new TestCache();
|
||||
test.write = jest.fn();
|
||||
const fragment = {
|
||||
id: 'frag',
|
||||
fragment: gql`
|
||||
fragment a on b {
|
||||
name
|
||||
}
|
||||
`,
|
||||
};
|
||||
|
||||
test.writeFragment(fragment);
|
||||
expect(test.write).toBeCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('writeData', () => {
|
||||
it('either writes a fragment or a query', () => {
|
||||
const test = new TestCache();
|
||||
test.read = jest.fn();
|
||||
test.writeFragment = jest.fn();
|
||||
test.writeQuery = jest.fn();
|
||||
|
||||
test.writeData({});
|
||||
expect(test.writeQuery).toBeCalled();
|
||||
|
||||
test.writeData({ id: 1 });
|
||||
expect(test.read).toBeCalled();
|
||||
expect(test.writeFragment).toBeCalled();
|
||||
|
||||
// Edge case for falsey id
|
||||
test.writeData({ id: 0 });
|
||||
expect(test.read).toHaveBeenCalledTimes(2);
|
||||
expect(test.writeFragment).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it('suppresses read errors', () => {
|
||||
const test = new TestCache();
|
||||
test.read = () => {
|
||||
throw new Error();
|
||||
};
|
||||
test.writeFragment = jest.fn();
|
||||
|
||||
expect(() => test.writeData({ id: 1 })).not.toThrow();
|
||||
expect(test.writeFragment).toBeCalled();
|
||||
});
|
||||
|
||||
it('reads __typename from typenameResult or defaults to __ClientData', () => {
|
||||
const test = new TestCache();
|
||||
test.read = () => ({ __typename: 'a' });
|
||||
let res;
|
||||
test.writeFragment = obj =>
|
||||
(res = obj.fragment.definitions[0].typeCondition.name.value);
|
||||
|
||||
test.writeData({ id: 1 });
|
||||
expect(res).toBe('a');
|
||||
|
||||
test.read = () => ({});
|
||||
|
||||
test.writeData({ id: 1 });
|
||||
expect(res).toBe('__ClientData');
|
||||
});
|
||||
});
|
||||
});
|
||||
76
node_modules/apollo-cache/src/__tests__/utils.ts
generated
vendored
Normal file
76
node_modules/apollo-cache/src/__tests__/utils.ts
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
import { print } from 'graphql/language/printer';
|
||||
import { queryFromPojo, fragmentFromPojo } from '../utils';
|
||||
|
||||
describe('writing data with no query', () => {
|
||||
describe('converts a JavaScript object to a query correctly', () => {
|
||||
it('basic', () => {
|
||||
expect(
|
||||
print(
|
||||
queryFromPojo({
|
||||
number: 5,
|
||||
bool: true,
|
||||
bool2: false,
|
||||
undef: undefined,
|
||||
nullField: null,
|
||||
str: 'string',
|
||||
}),
|
||||
),
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('nested', () => {
|
||||
expect(
|
||||
print(
|
||||
queryFromPojo({
|
||||
number: 5,
|
||||
bool: true,
|
||||
nested: {
|
||||
bool2: false,
|
||||
undef: undefined,
|
||||
nullField: null,
|
||||
str: 'string',
|
||||
},
|
||||
}),
|
||||
),
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('arrays', () => {
|
||||
expect(
|
||||
print(
|
||||
queryFromPojo({
|
||||
number: [5],
|
||||
bool: [[true]],
|
||||
nested: [
|
||||
{
|
||||
bool2: false,
|
||||
undef: undefined,
|
||||
nullField: null,
|
||||
str: 'string',
|
||||
},
|
||||
],
|
||||
}),
|
||||
),
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('fragments', () => {
|
||||
expect(
|
||||
print(
|
||||
fragmentFromPojo({
|
||||
number: [5],
|
||||
bool: [[true]],
|
||||
nested: [
|
||||
{
|
||||
bool2: false,
|
||||
undef: undefined,
|
||||
nullField: null,
|
||||
str: 'string',
|
||||
},
|
||||
],
|
||||
}),
|
||||
),
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
});
|
||||
150
node_modules/apollo-cache/src/cache.ts
generated
vendored
Normal file
150
node_modules/apollo-cache/src/cache.ts
generated
vendored
Normal file
@@ -0,0 +1,150 @@
|
||||
import { DocumentNode } from 'graphql';
|
||||
import { getFragmentQueryDocument } from 'apollo-utilities';
|
||||
|
||||
import { DataProxy, Cache } from './types';
|
||||
import { justTypenameQuery, queryFromPojo, fragmentFromPojo } from './utils';
|
||||
|
||||
export type Transaction<T> = (c: ApolloCache<T>) => void;
|
||||
|
||||
export abstract class ApolloCache<TSerialized> implements DataProxy {
|
||||
// required to implement
|
||||
// core API
|
||||
public abstract read<T, TVariables = any>(
|
||||
query: Cache.ReadOptions<TVariables>,
|
||||
): T | null;
|
||||
public abstract write<TResult = any, TVariables = any>(
|
||||
write: Cache.WriteOptions<TResult, TVariables>,
|
||||
): void;
|
||||
public abstract diff<T>(query: Cache.DiffOptions): Cache.DiffResult<T>;
|
||||
public abstract watch(watch: Cache.WatchOptions): () => void;
|
||||
public abstract evict<TVariables = any>(
|
||||
query: Cache.EvictOptions<TVariables>,
|
||||
): Cache.EvictionResult;
|
||||
public abstract reset(): Promise<void>;
|
||||
|
||||
// intializer / offline / ssr API
|
||||
/**
|
||||
* Replaces existing state in the cache (if any) with the values expressed by
|
||||
* `serializedState`.
|
||||
*
|
||||
* Called when hydrating a cache (server side rendering, or offline storage),
|
||||
* and also (potentially) during hot reloads.
|
||||
*/
|
||||
public abstract restore(
|
||||
serializedState: TSerialized,
|
||||
): ApolloCache<TSerialized>;
|
||||
|
||||
/**
|
||||
* Exposes the cache's complete state, in a serializable format for later restoration.
|
||||
*/
|
||||
public abstract extract(optimistic?: boolean): TSerialized;
|
||||
|
||||
// optimistic API
|
||||
public abstract removeOptimistic(id: string): void;
|
||||
|
||||
// transactional API
|
||||
public abstract performTransaction(
|
||||
transaction: Transaction<TSerialized>,
|
||||
): void;
|
||||
public abstract recordOptimisticTransaction(
|
||||
transaction: Transaction<TSerialized>,
|
||||
id: string,
|
||||
): void;
|
||||
|
||||
// optional API
|
||||
public transformDocument(document: DocumentNode): DocumentNode {
|
||||
return document;
|
||||
}
|
||||
// experimental
|
||||
public transformForLink(document: DocumentNode): DocumentNode {
|
||||
return document;
|
||||
}
|
||||
|
||||
// DataProxy API
|
||||
/**
|
||||
*
|
||||
* @param options
|
||||
* @param optimistic
|
||||
*/
|
||||
public readQuery<QueryType, TVariables = any>(
|
||||
options: DataProxy.Query<TVariables>,
|
||||
optimistic: boolean = false,
|
||||
): QueryType | null {
|
||||
return this.read({
|
||||
query: options.query,
|
||||
variables: options.variables,
|
||||
optimistic,
|
||||
});
|
||||
}
|
||||
|
||||
public readFragment<FragmentType, TVariables = any>(
|
||||
options: DataProxy.Fragment<TVariables>,
|
||||
optimistic: boolean = false,
|
||||
): FragmentType | null {
|
||||
return this.read({
|
||||
query: getFragmentQueryDocument(options.fragment, options.fragmentName),
|
||||
variables: options.variables,
|
||||
rootId: options.id,
|
||||
optimistic,
|
||||
});
|
||||
}
|
||||
|
||||
public writeQuery<TData = any, TVariables = any>(
|
||||
options: Cache.WriteQueryOptions<TData, TVariables>,
|
||||
): void {
|
||||
this.write({
|
||||
dataId: 'ROOT_QUERY',
|
||||
result: options.data,
|
||||
query: options.query,
|
||||
variables: options.variables,
|
||||
});
|
||||
}
|
||||
|
||||
public writeFragment<TData = any, TVariables = any>(
|
||||
options: Cache.WriteFragmentOptions<TData, TVariables>,
|
||||
): void {
|
||||
this.write({
|
||||
dataId: options.id,
|
||||
result: options.data,
|
||||
variables: options.variables,
|
||||
query: getFragmentQueryDocument(options.fragment, options.fragmentName),
|
||||
});
|
||||
}
|
||||
|
||||
public writeData<TData = any>({
|
||||
id,
|
||||
data,
|
||||
}: Cache.WriteDataOptions<TData>): void {
|
||||
if (typeof id !== 'undefined') {
|
||||
let typenameResult = null;
|
||||
// Since we can't use fragments without having a typename in the store,
|
||||
// we need to make sure we have one.
|
||||
// To avoid overwriting an existing typename, we need to read it out first
|
||||
// and generate a fake one if none exists.
|
||||
try {
|
||||
typenameResult = this.read<any>({
|
||||
rootId: id,
|
||||
optimistic: false,
|
||||
query: justTypenameQuery,
|
||||
});
|
||||
} catch (e) {
|
||||
// Do nothing, since an error just means no typename exists
|
||||
}
|
||||
|
||||
// tslint:disable-next-line
|
||||
const __typename =
|
||||
(typenameResult && typenameResult.__typename) || '__ClientData';
|
||||
|
||||
// Add a type here to satisfy the inmemory cache
|
||||
const dataToWrite = Object.assign({ __typename }, data);
|
||||
|
||||
this.writeFragment({
|
||||
id,
|
||||
fragment: fragmentFromPojo(dataToWrite, __typename),
|
||||
data: dataToWrite,
|
||||
});
|
||||
} else {
|
||||
this.writeQuery({ query: queryFromPojo(data), data });
|
||||
}
|
||||
}
|
||||
}
|
||||
2
node_modules/apollo-cache/src/index.ts
generated
vendored
Normal file
2
node_modules/apollo-cache/src/index.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './cache';
|
||||
export * from './types';
|
||||
40
node_modules/apollo-cache/src/types/Cache.ts
generated
vendored
Normal file
40
node_modules/apollo-cache/src/types/Cache.ts
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
import { DataProxy } from './DataProxy';
|
||||
|
||||
export namespace Cache {
|
||||
export type WatchCallback = (newData: any) => void;
|
||||
export interface EvictionResult {
|
||||
success: Boolean;
|
||||
}
|
||||
|
||||
export interface ReadOptions<TVariables = any>
|
||||
extends DataProxy.Query<TVariables> {
|
||||
rootId?: string;
|
||||
previousResult?: any;
|
||||
optimistic: boolean;
|
||||
}
|
||||
|
||||
export interface WriteOptions<TResult = any, TVariables = any>
|
||||
extends DataProxy.Query<TVariables> {
|
||||
dataId: string;
|
||||
result: TResult;
|
||||
}
|
||||
|
||||
export interface DiffOptions extends ReadOptions {
|
||||
returnPartialData?: boolean;
|
||||
}
|
||||
|
||||
export interface WatchOptions extends ReadOptions {
|
||||
callback: WatchCallback;
|
||||
}
|
||||
|
||||
export interface EvictOptions<TVariables = any>
|
||||
extends DataProxy.Query<TVariables> {
|
||||
rootId?: string;
|
||||
}
|
||||
|
||||
export import DiffResult = DataProxy.DiffResult;
|
||||
export import WriteQueryOptions = DataProxy.WriteQueryOptions;
|
||||
export import WriteFragmentOptions = DataProxy.WriteFragmentOptions;
|
||||
export import WriteDataOptions = DataProxy.WriteDataOptions;
|
||||
export import Fragment = DataProxy.Fragment;
|
||||
}
|
||||
127
node_modules/apollo-cache/src/types/DataProxy.ts
generated
vendored
Normal file
127
node_modules/apollo-cache/src/types/DataProxy.ts
generated
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
import { DocumentNode } from 'graphql'; // eslint-disable-line import/no-extraneous-dependencies, import/no-unresolved
|
||||
|
||||
export namespace DataProxy {
|
||||
export interface Query<TVariables> {
|
||||
/**
|
||||
* The GraphQL query shape to be used constructed using the `gql` template
|
||||
* string tag from `graphql-tag`. The query will be used to determine the
|
||||
* shape of the data to be read.
|
||||
*/
|
||||
query: DocumentNode;
|
||||
|
||||
/**
|
||||
* Any variables that the GraphQL query may depend on.
|
||||
*/
|
||||
variables?: TVariables;
|
||||
}
|
||||
|
||||
export interface Fragment<TVariables> {
|
||||
/**
|
||||
* The root id to be used. This id should take the same form as the
|
||||
* value returned by your `dataIdFromObject` function. If a value with your
|
||||
* id does not exist in the store, `null` will be returned.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* A GraphQL document created using the `gql` template string tag from
|
||||
* `graphql-tag` with one or more fragments which will be used to determine
|
||||
* the shape of data to read. If you provide more than one fragment in this
|
||||
* document then you must also specify `fragmentName` to select a single.
|
||||
*/
|
||||
fragment: DocumentNode;
|
||||
|
||||
/**
|
||||
* The name of the fragment in your GraphQL document to be used. If you do
|
||||
* not provide a `fragmentName` and there is only one fragment in your
|
||||
* `fragment` document then that fragment will be used.
|
||||
*/
|
||||
fragmentName?: string;
|
||||
|
||||
/**
|
||||
* Any variables that your GraphQL fragments depend on.
|
||||
*/
|
||||
variables?: TVariables;
|
||||
}
|
||||
|
||||
export interface WriteQueryOptions<TData, TVariables>
|
||||
extends Query<TVariables> {
|
||||
/**
|
||||
* The data you will be writing to the store.
|
||||
*/
|
||||
data: TData;
|
||||
}
|
||||
|
||||
export interface WriteFragmentOptions<TData, TVariables>
|
||||
extends Fragment<TVariables> {
|
||||
/**
|
||||
* The data you will be writing to the store.
|
||||
*/
|
||||
data: TData;
|
||||
}
|
||||
|
||||
export interface WriteDataOptions<TData> {
|
||||
/**
|
||||
* The data you will be writing to the store.
|
||||
* It also takes an optional id property.
|
||||
* The id is used to write a fragment to an existing object in the store.
|
||||
*/
|
||||
data: TData;
|
||||
id?: string;
|
||||
}
|
||||
|
||||
export type DiffResult<T> = {
|
||||
result?: T;
|
||||
complete?: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* A proxy to the normalized data living in our store. This interface allows a
|
||||
* user to read and write denormalized data which feels natural to the user
|
||||
* whilst in the background this data is being converted into the normalized
|
||||
* store format.
|
||||
*/
|
||||
export interface DataProxy {
|
||||
/**
|
||||
* Reads a GraphQL query from the root query id.
|
||||
*/
|
||||
readQuery<QueryType, TVariables = any>(
|
||||
options: DataProxy.Query<TVariables>,
|
||||
optimistic?: boolean,
|
||||
): QueryType | null;
|
||||
|
||||
/**
|
||||
* Reads a GraphQL fragment from any arbitrary id. If there is more than
|
||||
* one fragment in the provided document then a `fragmentName` must be
|
||||
* provided to select the correct fragment.
|
||||
*/
|
||||
readFragment<FragmentType, TVariables = any>(
|
||||
options: DataProxy.Fragment<TVariables>,
|
||||
optimistic?: boolean,
|
||||
): FragmentType | null;
|
||||
|
||||
/**
|
||||
* Writes a GraphQL query to the root query id.
|
||||
*/
|
||||
writeQuery<TData = any, TVariables = any>(
|
||||
options: DataProxy.WriteQueryOptions<TData, TVariables>,
|
||||
): void;
|
||||
|
||||
/**
|
||||
* Writes a GraphQL fragment to any arbitrary id. If there is more than
|
||||
* one fragment in the provided document then a `fragmentName` must be
|
||||
* provided to select the correct fragment.
|
||||
*/
|
||||
writeFragment<TData = any, TVariables = any>(
|
||||
options: DataProxy.WriteFragmentOptions<TData, TVariables>,
|
||||
): void;
|
||||
|
||||
/**
|
||||
* Sugar for writeQuery & writeFragment.
|
||||
* Writes data to the store without passing in a query.
|
||||
* If you supply an id, the data will be written as a fragment to an existing object.
|
||||
* Otherwise, the data is written to the root of the store.
|
||||
*/
|
||||
writeData<TData = any>(options: DataProxy.WriteDataOptions<TData>): void;
|
||||
}
|
||||
2
node_modules/apollo-cache/src/types/index.ts
generated
vendored
Normal file
2
node_modules/apollo-cache/src/types/index.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './DataProxy';
|
||||
export * from './Cache';
|
||||
123
node_modules/apollo-cache/src/utils.ts
generated
vendored
Normal file
123
node_modules/apollo-cache/src/utils.ts
generated
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
import {
|
||||
DocumentNode,
|
||||
OperationDefinitionNode,
|
||||
SelectionSetNode,
|
||||
FieldNode,
|
||||
FragmentDefinitionNode,
|
||||
} from 'graphql';
|
||||
|
||||
export function queryFromPojo(obj: any): DocumentNode {
|
||||
const op: OperationDefinitionNode = {
|
||||
kind: 'OperationDefinition',
|
||||
operation: 'query',
|
||||
name: {
|
||||
kind: 'Name',
|
||||
value: 'GeneratedClientQuery',
|
||||
},
|
||||
selectionSet: selectionSetFromObj(obj),
|
||||
};
|
||||
|
||||
const out: DocumentNode = {
|
||||
kind: 'Document',
|
||||
definitions: [op],
|
||||
};
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
export function fragmentFromPojo(obj: any, typename?: string): DocumentNode {
|
||||
const frag: FragmentDefinitionNode = {
|
||||
kind: 'FragmentDefinition',
|
||||
typeCondition: {
|
||||
kind: 'NamedType',
|
||||
name: {
|
||||
kind: 'Name',
|
||||
value: typename || '__FakeType',
|
||||
},
|
||||
},
|
||||
name: {
|
||||
kind: 'Name',
|
||||
value: 'GeneratedClientQuery',
|
||||
},
|
||||
selectionSet: selectionSetFromObj(obj),
|
||||
};
|
||||
|
||||
const out: DocumentNode = {
|
||||
kind: 'Document',
|
||||
definitions: [frag],
|
||||
};
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
function selectionSetFromObj(obj: any): SelectionSetNode {
|
||||
if (
|
||||
typeof obj === 'number' ||
|
||||
typeof obj === 'boolean' ||
|
||||
typeof obj === 'string' ||
|
||||
typeof obj === 'undefined' ||
|
||||
obj === null
|
||||
) {
|
||||
// No selection set here
|
||||
return null;
|
||||
}
|
||||
|
||||
if (Array.isArray(obj)) {
|
||||
// GraphQL queries don't include arrays
|
||||
return selectionSetFromObj(obj[0]);
|
||||
}
|
||||
|
||||
// Now we know it's an object
|
||||
const selections: FieldNode[] = [];
|
||||
|
||||
Object.keys(obj).forEach(key => {
|
||||
const nestedSelSet: SelectionSetNode = selectionSetFromObj(obj[key]);
|
||||
|
||||
const field: FieldNode = {
|
||||
kind: 'Field',
|
||||
name: {
|
||||
kind: 'Name',
|
||||
value: key,
|
||||
},
|
||||
selectionSet: nestedSelSet || undefined,
|
||||
};
|
||||
|
||||
selections.push(field);
|
||||
});
|
||||
|
||||
const selectionSet: SelectionSetNode = {
|
||||
kind: 'SelectionSet',
|
||||
selections,
|
||||
};
|
||||
|
||||
return selectionSet;
|
||||
}
|
||||
|
||||
export const justTypenameQuery: DocumentNode = {
|
||||
kind: 'Document',
|
||||
definitions: [
|
||||
{
|
||||
kind: 'OperationDefinition',
|
||||
operation: 'query',
|
||||
name: null,
|
||||
variableDefinitions: null,
|
||||
directives: [],
|
||||
selectionSet: {
|
||||
kind: 'SelectionSet',
|
||||
selections: [
|
||||
{
|
||||
kind: 'Field',
|
||||
alias: null,
|
||||
name: {
|
||||
kind: 'Name',
|
||||
value: '__typename',
|
||||
},
|
||||
arguments: [],
|
||||
directives: [],
|
||||
selectionSet: null,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
Reference in New Issue
Block a user