UNPKG

2.18 kBJavaScriptView Raw
1exports.__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={});