@apollo/client 3.5.0-beta.13 → 3.5.0-beta.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/apollo-client.cjs +216 -160
  2. package/apollo-client.cjs.map +1 -1
  3. package/apollo-client.min.cjs +1 -0
  4. package/cache/cache.cjs +132 -101
  5. package/cache/cache.cjs.map +1 -1
  6. package/cache/core/cache.d.ts +4 -4
  7. package/cache/core/cache.d.ts.map +1 -1
  8. package/cache/core/cache.js +24 -13
  9. package/cache/core/cache.js.map +1 -1
  10. package/cache/core/types/Cache.d.ts +10 -10
  11. package/cache/core/types/Cache.d.ts.map +1 -1
  12. package/cache/core/types/Cache.js.map +1 -1
  13. package/cache/core/types/DataProxy.js.map +1 -1
  14. package/cache/core/types/common.d.ts +8 -5
  15. package/cache/core/types/common.d.ts.map +1 -1
  16. package/cache/core/types/common.js +6 -11
  17. package/cache/core/types/common.js.map +1 -1
  18. package/cache/index.d.ts +3 -3
  19. package/cache/index.d.ts.map +1 -1
  20. package/cache/index.js +2 -2
  21. package/cache/index.js.map +1 -1
  22. package/cache/inmemory/entityStore.d.ts +1 -1
  23. package/cache/inmemory/entityStore.d.ts.map +1 -1
  24. package/cache/inmemory/entityStore.js +3 -3
  25. package/cache/inmemory/entityStore.js.map +1 -1
  26. package/cache/inmemory/helpers.d.ts +10 -1
  27. package/cache/inmemory/helpers.d.ts.map +1 -1
  28. package/cache/inmemory/helpers.js +31 -1
  29. package/cache/inmemory/helpers.js.map +1 -1
  30. package/cache/inmemory/inMemoryCache.d.ts +6 -12
  31. package/cache/inmemory/inMemoryCache.d.ts.map +1 -1
  32. package/cache/inmemory/inMemoryCache.js +13 -17
  33. package/cache/inmemory/inMemoryCache.js.map +1 -1
  34. package/cache/inmemory/policies.d.ts +1 -2
  35. package/cache/inmemory/policies.d.ts.map +1 -1
  36. package/cache/inmemory/policies.js +1 -18
  37. package/cache/inmemory/policies.js.map +1 -1
  38. package/cache/inmemory/readFromStore.d.ts +3 -2
  39. package/cache/inmemory/readFromStore.d.ts.map +1 -1
  40. package/cache/inmemory/readFromStore.js +60 -45
  41. package/cache/inmemory/readFromStore.js.map +1 -1
  42. package/cache/inmemory/types.d.ts +8 -1
  43. package/cache/inmemory/types.d.ts.map +1 -1
  44. package/cache/inmemory/types.js.map +1 -1
  45. package/cache/inmemory/writeToStore.js +1 -1
  46. package/core/ApolloClient.js +2 -2
  47. package/core/ApolloClient.js.map +1 -1
  48. package/core/LocalState.js +1 -1
  49. package/core/ObservableQuery.d.ts +2 -1
  50. package/core/ObservableQuery.d.ts.map +1 -1
  51. package/core/ObservableQuery.js +3 -3
  52. package/core/ObservableQuery.js.map +1 -1
  53. package/core/QueryInfo.d.ts.map +1 -1
  54. package/core/QueryInfo.js +2 -2
  55. package/core/QueryInfo.js.map +1 -1
  56. package/core/QueryManager.d.ts.map +1 -1
  57. package/core/QueryManager.js +10 -9
  58. package/core/QueryManager.js.map +1 -1
  59. package/core/core.cjs +19 -18
  60. package/core/core.cjs.map +1 -1
  61. package/core/watchQueryOptions.js.map +1 -1
  62. package/invariantErrorCodes.js +48 -61
  63. package/link/core/ApolloLink.js +1 -1
  64. package/link/core/core.cjs +1 -1
  65. package/link/core/core.cjs.map +1 -1
  66. package/link/http/checkFetcher.js +1 -1
  67. package/link/http/http.cjs +2 -2
  68. package/link/http/http.cjs.map +1 -1
  69. package/link/http/serializeFetchParameter.js +1 -1
  70. package/link/persisted-queries/index.js +2 -2
  71. package/link/persisted-queries/persisted-queries.cjs +2 -2
  72. package/link/persisted-queries/persisted-queries.cjs.map +1 -1
  73. package/link/utils/utils.cjs +1 -1
  74. package/link/utils/utils.cjs.map +1 -1
  75. package/link/utils/validateOperation.js +1 -1
  76. package/package.json +9 -9
  77. package/react/context/ApolloConsumer.js +1 -1
  78. package/react/context/ApolloContext.d.ts.map +1 -1
  79. package/react/context/ApolloContext.js +11 -5
  80. package/react/context/ApolloContext.js.map +1 -1
  81. package/react/context/ApolloProvider.js +1 -1
  82. package/react/context/context.cjs +12 -6
  83. package/react/context/context.cjs.map +1 -1
  84. package/react/hoc/hoc-utils.js +1 -1
  85. package/react/hoc/hoc.cjs +10 -7
  86. package/react/hoc/hoc.cjs.map +1 -1
  87. package/react/hoc/subscription-hoc.d.ts.map +1 -1
  88. package/react/hoc/subscription-hoc.js +8 -5
  89. package/react/hoc/subscription-hoc.js.map +1 -1
  90. package/react/hoc/withApollo.js +1 -1
  91. package/react/hooks/hooks.cjs +1 -1
  92. package/react/hooks/hooks.cjs.map +1 -1
  93. package/react/hooks/useApolloClient.js +1 -1
  94. package/react/hooks/useQuery.d.ts +1 -1
  95. package/react/hooks/useQuery.d.ts.map +1 -1
  96. package/react/hooks/useQuery.js.map +1 -1
  97. package/react/parser/index.js +5 -5
  98. package/react/parser/index.js.map +1 -1
  99. package/react/parser/parser.cjs +5 -5
  100. package/react/parser/parser.cjs.map +1 -1
  101. package/testing/core/core.cjs +1 -1
  102. package/testing/core/core.cjs.map +1 -1
  103. package/testing/core/mocking/mockFetch.js.map +1 -1
  104. package/testing/core/mocking/mockLink.js +1 -1
  105. package/utilities/common/canUse.d.ts +1 -0
  106. package/utilities/common/canUse.d.ts.map +1 -1
  107. package/utilities/common/canUse.js +2 -0
  108. package/utilities/common/canUse.js.map +1 -1
  109. package/utilities/common/maybeDeepFreeze.d.ts.map +1 -1
  110. package/utilities/common/maybeDeepFreeze.js +14 -3
  111. package/utilities/common/maybeDeepFreeze.js.map +1 -1
  112. package/utilities/common/mergeDeep.d.ts.map +1 -1
  113. package/utilities/common/mergeDeep.js +6 -1
  114. package/utilities/common/mergeDeep.js.map +1 -1
  115. package/utilities/globals/globals.cjs +1 -1
  116. package/utilities/globals/globals.cjs.map +1 -1
  117. package/utilities/globals/index.js +1 -1
  118. package/utilities/graphql/directives.js +4 -4
  119. package/utilities/graphql/fragments.js +3 -3
  120. package/utilities/graphql/getFromAST.js +8 -8
  121. package/utilities/graphql/storeUtils.js +1 -1
  122. package/utilities/observables/subclassing.d.ts.map +1 -1
  123. package/utilities/observables/subclassing.js +2 -1
  124. package/utilities/observables/subclassing.js.map +1 -1
  125. package/utilities/policies/pagination.d.ts +1 -1
  126. package/utilities/policies/pagination.d.ts.map +1 -1
  127. package/utilities/policies/pagination.js +7 -2
  128. package/utilities/policies/pagination.js.map +1 -1
  129. package/utilities/utilities.cjs +51 -27
  130. package/utilities/utilities.cjs.map +1 -1
  131. package/version.js +1 -1
@@ -1,16 +1,16 @@
1
1
  import { invariant, InvariantError } from "../globals/index.js";
2
2
  import { valueToObjectRepresentation } from "./storeUtils.js";
3
3
  export function checkDocument(doc) {
4
- __DEV__ ? invariant(doc && doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql") : invariant(doc && doc.kind === 'Document', 46);
4
+ __DEV__ ? invariant(doc && doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql") : invariant(doc && doc.kind === 'Document', 44);
5
5
  var operations = doc.definitions
6
6
  .filter(function (d) { return d.kind !== 'FragmentDefinition'; })
7
7
  .map(function (definition) {
8
8
  if (definition.kind !== 'OperationDefinition') {
9
- throw __DEV__ ? new InvariantError("Schema type definitions not allowed in queries. Found: \"" + definition.kind + "\"") : new InvariantError(47);
9
+ throw __DEV__ ? new InvariantError("Schema type definitions not allowed in queries. Found: \"" + definition.kind + "\"") : new InvariantError(45);
10
10
  }
11
11
  return definition;
12
12
  });
13
- __DEV__ ? invariant(operations.length <= 1, "Ambiguous GraphQL document: contains " + operations.length + " operations") : invariant(operations.length <= 1, 48);
13
+ __DEV__ ? invariant(operations.length <= 1, "Ambiguous GraphQL document: contains " + operations.length + " operations") : invariant(operations.length <= 1, 46);
14
14
  return doc;
15
15
  }
16
16
  export function getOperationDefinition(doc) {
@@ -29,14 +29,14 @@ export function getFragmentDefinitions(doc) {
29
29
  }
30
30
  export function getQueryDefinition(doc) {
31
31
  var queryDef = getOperationDefinition(doc);
32
- __DEV__ ? invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.') : invariant(queryDef && queryDef.operation === 'query', 49);
32
+ __DEV__ ? invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.') : invariant(queryDef && queryDef.operation === 'query', 47);
33
33
  return queryDef;
34
34
  }
35
35
  export function getFragmentDefinition(doc) {
36
- __DEV__ ? invariant(doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql") : invariant(doc.kind === 'Document', 50);
37
- __DEV__ ? invariant(doc.definitions.length <= 1, 'Fragment must have exactly one definition.') : invariant(doc.definitions.length <= 1, 51);
36
+ __DEV__ ? invariant(doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql") : invariant(doc.kind === 'Document', 48);
37
+ __DEV__ ? invariant(doc.definitions.length <= 1, 'Fragment must have exactly one definition.') : invariant(doc.definitions.length <= 1, 49);
38
38
  var fragmentDef = doc.definitions[0];
39
- __DEV__ ? invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.') : invariant(fragmentDef.kind === 'FragmentDefinition', 52);
39
+ __DEV__ ? invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.') : invariant(fragmentDef.kind === 'FragmentDefinition', 50);
40
40
  return fragmentDef;
41
41
  }
42
42
  export function getMainDefinition(queryDoc) {
@@ -59,7 +59,7 @@ export function getMainDefinition(queryDoc) {
59
59
  if (fragmentDefinition) {
60
60
  return fragmentDefinition;
61
61
  }
62
- throw __DEV__ ? new InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.') : new InvariantError(53);
62
+ throw __DEV__ ? new InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.') : new InvariantError(51);
63
63
  }
64
64
  export function getDefaultValues(definition) {
65
65
  var defaultValues = Object.create(null);
@@ -73,7 +73,7 @@ export function valueToObjectRepresentation(argObj, name, value, variables) {
73
73
  else {
74
74
  throw __DEV__ ? new InvariantError("The inline argument \"" + name.value + "\" of kind \"" + value.kind + "\"" +
75
75
  'is not supported. Use variables instead of inline arguments to ' +
76
- 'overcome this limitation.') : new InvariantError(54);
76
+ 'overcome this limitation.') : new InvariantError(52);
77
77
  }
78
78
  }
79
79
  export function storeKeyNameFromField(field, variables) {
@@ -1 +1 @@
1
- {"version":3,"file":"subclassing.d.ts","sourceRoot":"","sources":["../../../src/utilities/observables/subclassing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAU1C,wBAAgB,qBAAqB,CACnC,CAAC,SAAS,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,UAAU,CAAC,GAAG,CAAC,EACjD,QAAQ,EAAE,CAAC,GAAG,CAAC,CAehB"}
1
+ {"version":3,"file":"subclassing.d.ts","sourceRoot":"","sources":["../../../src/utilities/observables/subclassing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAW1C,wBAAgB,qBAAqB,CACnC,CAAC,SAAS,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,UAAU,CAAC,GAAG,CAAC,EACjD,QAAQ,EAAE,CAAC,GAAG,CAAC,CAehB"}
@@ -1,9 +1,10 @@
1
1
  import { Observable } from "./Observable.js";
2
+ import { canUseSymbol } from "../common/canUse.js";
2
3
  export function fixObservableSubclass(subclass) {
3
4
  function set(key) {
4
5
  Object.defineProperty(subclass, key, { value: Observable });
5
6
  }
6
- if (typeof Symbol === "function" && Symbol.species) {
7
+ if (canUseSymbol && Symbol.species) {
7
8
  set(Symbol.species);
8
9
  }
9
10
  set("@@species");
@@ -1 +1 @@
1
- {"version":3,"file":"subclassing.js","sourceRoot":"","sources":["../../../src/utilities/observables/subclassing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAU1C,MAAM,UAAU,qBAAqB,CAEnC,QAAW;IACX,SAAS,GAAG,CAAC,GAAoB;QAI/B,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;IAC9D,CAAC;IACD,IAAI,OAAO,MAAM,KAAK,UAAU,IAAI,MAAM,CAAC,OAAO,EAAE;QAClD,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;KACrB;IAID,GAAG,CAAC,WAAW,CAAC,CAAC;IACjB,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import { Observable } from \"./Observable\";\n\n// Generic implementations of Observable.prototype methods like map and\n// filter need to know how to create a new Observable from an Observable\n// subclass (like Concast or ObservableQuery). Those methods assume\n// (perhaps unwisely?) that they can call the subtype's constructor with a\n// Subscriber function, even though the subclass constructor might expect\n// different parameters. Defining this static Symbol.species property on\n// the subclass is a hint to generic Observable code to use the default\n// constructor instead of trying to do `new Subclass(observer => ...)`.\nexport function fixObservableSubclass<\n S extends new (...args: any[]) => Observable<any>,\n>(subclass: S): S {\n function set(key: symbol | string) {\n // Object.defineProperty is necessary because the Symbol.species\n // property is a getter by default in modern JS environments, so we\n // can't assign to it with a normal assignment expression.\n Object.defineProperty(subclass, key, { value: Observable });\n }\n if (typeof Symbol === \"function\" && Symbol.species) {\n set(Symbol.species);\n }\n // The \"@@species\" string is used as a fake Symbol.species value in some\n // polyfill systems (including the SymbolSpecies variable used by\n // zen-observable), so we should set it as well, to be safe.\n set(\"@@species\");\n return subclass;\n}\n"]}
1
+ {"version":3,"file":"subclassing.js","sourceRoot":"","sources":["../../../src/utilities/observables/subclassing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAUhD,MAAM,UAAU,qBAAqB,CAEnC,QAAW;IACX,SAAS,GAAG,CAAC,GAAoB;QAI/B,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;IAC9D,CAAC;IACD,IAAI,YAAY,IAAI,MAAM,CAAC,OAAO,EAAE;QAClC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;KACrB;IAID,GAAG,CAAC,WAAW,CAAC,CAAC;IACjB,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import { Observable } from \"./Observable\";\nimport { canUseSymbol } from \"../common/canUse\";\n\n// Generic implementations of Observable.prototype methods like map and\n// filter need to know how to create a new Observable from an Observable\n// subclass (like Concast or ObservableQuery). Those methods assume\n// (perhaps unwisely?) that they can call the subtype's constructor with a\n// Subscriber function, even though the subclass constructor might expect\n// different parameters. Defining this static Symbol.species property on\n// the subclass is a hint to generic Observable code to use the default\n// constructor instead of trying to do `new Subclass(observer => ...)`.\nexport function fixObservableSubclass<\n S extends new (...args: any[]) => Observable<any>,\n>(subclass: S): S {\n function set(key: symbol | string) {\n // Object.defineProperty is necessary because the Symbol.species\n // property is a getter by default in modern JS environments, so we\n // can't assign to it with a normal assignment expression.\n Object.defineProperty(subclass, key, { value: Observable });\n }\n if (canUseSymbol && Symbol.species) {\n set(Symbol.species);\n }\n // The \"@@species\" string is used as a fake Symbol.species value in some\n // polyfill systems (including the SymbolSpecies variable used by\n // zen-observable), so we should set it as well, to be safe.\n set(\"@@species\");\n return subclass;\n}\n"]}
@@ -22,7 +22,7 @@ export declare type TIncomingRelay<TNode> = {
22
22
  edges?: TRelayEdge<TNode>[];
23
23
  pageInfo?: TRelayPageInfo;
24
24
  };
25
- export declare type RelayFieldPolicy<TNode> = FieldPolicy<TExistingRelay<TNode>, TIncomingRelay<TNode>, TIncomingRelay<TNode>>;
25
+ export declare type RelayFieldPolicy<TNode> = FieldPolicy<TExistingRelay<TNode> | null, TIncomingRelay<TNode> | null, TIncomingRelay<TNode> | null>;
26
26
  export declare function relayStylePagination<TNode = Reference>(keyArgs?: KeyArgs): RelayFieldPolicy<TNode>;
27
27
  export {};
28
28
  //# sourceMappingURL=pagination.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../../src/utilities/policies/pagination.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGrD,aAAK,OAAO,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC;AAI3C,wBAAgB,gBAAgB,CAAC,CAAC,GAAG,SAAS,EAC5C,OAAO,GAAE,OAAe,GACvB,WAAW,CAAC,CAAC,EAAE,CAAC,CAUlB;AAMD,wBAAgB,qBAAqB,CAAC,CAAC,GAAG,SAAS,EACjD,OAAO,GAAE,OAAe,GACvB,WAAW,CAAC,CAAC,EAAE,CAAC,CAqBlB;AASD,oBAAY,UAAU,CAAC,KAAK,IAAI;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,KAAK,CAAC;CACb,GAAG,CAAC,SAAS,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAEtC,oBAAY,cAAc,GAAG;IAC3B,eAAe,EAAE,OAAO,CAAC;IACzB,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,oBAAY,cAAc,CAAC,KAAK,IAAI,QAAQ,CAAC;IAC3C,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;IAC3B,QAAQ,EAAE,cAAc,CAAC;CAC1B,CAAC,CAAC;AAEH,oBAAY,cAAc,CAAC,KAAK,IAAI;IAClC,KAAK,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,EA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AAQ,EAAE,cAAc,CAAC;CAC1B,CAAC,CAAC;AAEH,oBAAY,cAAc,CAAC,KAAK,IAAI;IAClC,KAAK,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;IAC5B,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B,CAAC;AAEF,oBAAY,gBAAgB,CAAC,KAAK,IAAI,WAAW,CAC/C,cAAc,CAAC,KAAK,CAAC,GAAG,IAAI,EAC5B,cAAc,CAAC,KAAK,CAAC,GAAG,IAAI,EAC5B,cAAc,CAAC,KAAK,CAAC,GAAG,IAAI,CAC7B,CAAC;AAKF,wBAAgB,oBAAoB,CAAC,KAAK,GAAG,SAAS,EACpD,OAAO,GAAE,OAAe,GACvB,gBAAgB,CAAC,KAAK,CAAC,CA2KzB"}
@@ -37,7 +37,7 @@ export function relayStylePagination(keyArgs) {
37
37
  read: function (existing, _a) {
38
38
  var canRead = _a.canRead, readField = _a.readField;
39
39
  if (!existing)
40
- return;
40
+ return existing;
41
41
  var edges = [];
42
42
  var firstEdgeCursor = "";
43
43
  var lastEdgeCursor = "";
@@ -54,8 +54,13 @@ export function relayStylePagination(keyArgs) {
54
54
  return __assign(__assign({}, getExtras(existing)), { edges: edges, pageInfo: __assign(__assign({}, existing.pageInfo), { startCursor: startCursor || firstEdgeCursor, endCursor: endCursor || lastEdgeCursor }) });
55
55
  },
56
56
  merge: function (existing, incoming, _a) {
57
- if (existing === void 0) { existing = makeEmptyData(); }
58
57
  var args = _a.args, isReference = _a.isReference, readField = _a.readField;
58
+ if (!existing) {
59
+ existing = makeEmptyData();
60
+ }
61
+ if (!incoming) {
62
+ return existing;
63
+ }
59
64
  var incomingEdges = incoming.edges ? incoming.edges.map(function (edge) {
60
65
  if (isReference(edge = __assign({}, edge))) {
61
66
  edge.cursor = readField("cursor", edge);
@@ -1 +1 @@
1
- {"version":3,"file":"pagination.js","sourceRoot":"","sources":["../../../src/utilities/policies/pagination.ts"],"names":[],"mappings":";AAAA,OAAO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AChE;gBACD,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;oBAClB,IAAI,KAAK,CAAC,KAAK,WAAW;wBAAE,QAAQ,CAAC,WAAW,GAAG,WAAW,CAAC;oBAC/D,IAAI,KAAK,CAAC,KAAK,SAAS;wBAAE,QAAQ,CAAC,SAAS,GAAG,SAAS,CAAC;iBAC1D;aACF;YAED,sCACK,SAAS,CAAC,QAAQ,CAAC,GACnB,SAAS,CAAC,QAAQ,CAAC,KACtB,KAAK,OAAA,EACL,QAAQ,UAAA,IACR;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAGD,IAAM,SAAS,GAAG,UAAC,GAAwB,IAAK,OAAA,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,EAAtB,CAAsB,CAAC;AACvE,IAAM,SAAS,GAAG,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;AAExC,SAAS,aAAa;IACpB,OAAO;QACL,KAAK,EAAE,EAAE;QACT,QAAQ,EAAE;YACR,eAAe,EAAE,KAAK;YACtB,WAAW,EAAE,IAAI;YACjB,WAAW,EAAE,EAAE;YACf,SAAS,EAAE,EAAE;SACd;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { __rest } from \"tslib\";\n\nimport { FieldPolicy, Reference } from '../../cache';\nimport { mergeDeep } from '../common/mergeDeep';\n\ntype KeyArgs = FieldPolicy<any>[\"keyArgs\"];\n\n// A very basic pagination field policy that always concatenates new\n// results onto the existing array, without examining options.args.\nexport function concatPagination<T = Reference>(\n keyArgs: KeyArgs = false,\n): FieldPolicy<T[]> {\n return {\n keyArgs,\n merge(existing, incoming) {\n return existing ? [\n ...existing,\n ...incoming,\n ] : incoming;\n },\n };\n}\n\n// A basic field policy that uses options.args.{offset,limit} to splice\n// the incoming data into the existing array. If your arguments are called\n// something different (like args.{start,count}), feel free to copy/paste\n// this implementation and make the appropriate changes.\nexport function offsetLimitPagination<T = Reference>(\n keyArgs: KeyArgs = false,\n): FieldPolicy<T[]> {\n return {\n keyArgs,\n merge(existing, incoming, { args }) {\n const merged = existing ? existing.slice(0) : [];\n if (args) {\n // Assume an offset of 0 if args.offset omitted.\n const { offset = 0 } = args;\n for (let i = 0; i < incoming.length; ++i) {\n merged[offset + i] = incoming[i];\n }\n } else {\n // It's unusual (probably a mistake) for a paginated field not\n // to receive any arguments, so you might prefer to throw an\n // exception here, instead of recovering by appending incoming\n // onto the existing array.\n merged.push.apply(merged, incoming);\n }\n return merged;\n },\n };\n}\n\n// Whether TRelayEdge<TNode> is a normalized Reference or a non-normalized\n// object, it needs a .cursor property where the relayStylePagination\n// merge function can store cursor strings taken from pageInfo. Storing an\n// extra reference.cursor property should be safe, and is easier than\n// attempting to update the cursor field of the normalized StoreObject\n// that the reference refers to, or managing edge wrapper objects\n// (something I attempted in #7023, but abandoned because of #7088).\nexport type TRelayEdge<TNode> = {\n cursor?: string;\n node: TNode;\n} | (Reference & { cursor?: string });\n\nexport type TRelayPageInfo = {\n hasPreviousPage: boolean;\n hasNextPage: boolean;\n startCursor: string;\n endCursor: string;\n};\n\nexport type TExistingRelay<TNode> = Readonly<{\n edges: TRelayEdge<TNode>[];\n pageInfo: TRelayPageInfo;\n}>;\n\nexport type TIncomingRelay<TNode> = {\n edges?: TRelayEdge<TNode>[];\n pageInfo?: TRelayPageInfo;\n};\n\nexport type RelayFieldPolicy<TNode> = FieldPolicy<\n TExistingRelay<TNode>,\n TIncomingRelay<TNode>,\n TIncomingRelay<TNode>\n>;\n\n// As proof of the flexibility of field policies, this function generates\n// one that handles Relay-style pagination, without Apollo Client knowing\n// anything about connections, edges, cursors, or pageInfo objects.\nexport function relayStylePagination<TNode = Reference>(\n keyArgs: KeyArgs = false,\n): RelayFieldPolicy<TNode> {\n return {\n keyArgs,\n\n read(existing, { canRead, readField }) {\n if (!existing) return;\n\n const edges: TRelayEdge<TNode>[] = [];\n let firstEdgeCursor = \"\";\n let lastEdgeCursor = \"\";\n existing.edges.forEach(edge => {\n // Edges themselves could be Reference objects, so it's important\n // to use readField to access the edge.edge.node property.\n if (canRead(readField(\"node\", edge))) {\n edges.push(edge);\n if (edge.cursor) {\n firstEdgeCursor = firstEdgeCursor || edge.cursor || \"\";\n lastEdgeCursor = edge.cursor || lastEdgeCursor;\n }\n }\n });\n\n const {\n startCursor,\n endCursor,\n } = existing.pageInfo || {};\n\n return {\n // Some implementations return additional Connection fields, such\n // as existing.totalCount. These fields are saved by the merge\n // function, so the read function should also preserve them.\n ...getExtras(existing),\n edges,\n pageInfo: {\n ...existing.pageInfo,\n // If existing.pageInfo.{start,end}Cursor are undefined or \"\", default\n // to firstEdgeCursor and/or lastEdgeCursor.\n startCursor: startCursor || firstEdgeCursor,\n endCursor: endCursor || lastEdgeCursor,\n },\n };\n },\n\n merge(existing = makeEmptyData(), incoming, { args, isReference, readField }) {\n const incomingEdges = incoming.edges ? incoming.edges.map(edge => {\n if (isReference(edge = { ...edge })) {\n // In case edge is a Reference, we read out its cursor field and\n // store it as an extra property of the Reference object.\n edge.cursor = readField<string>(\"cursor\", edge);\n }\n return edge;\n }) : [];\n\n if (incoming.pageInfo) {\n const { pageInfo } = incoming;\n const { startCursor, endCursor } = pageInfo;\n const firstEdge = incomingEdges[0];\n const lastEdge = incomingEdges[incomingEdges.length - 1];\n // In case we did not request the cursor field for edges in this\n // query, we can still infer cursors from pageInfo.\n if (firstEdge && startCursor) {\n firstEdge.cursor = startCursor;\n }\n if (lastEdge && endCursor) {\n lastEdge.cursor = endCursor;\n }\n // Cursors can also come from edges, so we default\n // pageInfo.{start,end}Cursor to {first,last}Edge.cursor.\n const firstCursor = firstEdge && firstEdge.cursor;\n if (firstCursor && !startCursor) {\n incoming = mergeDeep(incoming, {\n pageInfo: {\n startCursor: firstCursor,\n },\n });\n }\n const lastCursor = lastEdge && lastEdge.cursor;\n if (lastCursor && !endCursor) {\n incoming = mergeDeep(incoming, {\n pageInfo: {\n endCursor: lastCursor,\n },\n });\n }\n }\n\n let prefix = existing.edges;\n let suffix: typeof prefix = [];\n\n if (args && args.after) {\n // This comparison does not need to use readField(\"cursor\", edge),\n // because we stored the cursor field of any Reference edges as an\n // extra property of the Reference object.\n const index = prefix.findIndex(edge => edge.cursor === args.after);\n if (index >= 0) {\n prefix = prefix.slice(0, index + 1);\n // suffix = []; // already true\n }\n } else if (args && args.before) {\n const index = prefix.findIndex(edge => edge.cursor === args.before);\n suffix = index < 0 ? prefix : prefix.slice(index);\n prefix = [];\n } else if (incoming.edges) {\n // If we have neither args.after nor args.before, the incoming\n // edges cannot be spliced into the existing edges, so they must\n // replace the existing edges. See #6592 for a motivating example.\n prefix = [];\n }\n\n const edges = [\n ...prefix,\n ...incomingEdges,\n ...suffix,\n ];\n\n const pageInfo: TRelayPageInfo = {\n // The ordering of these two ...spreads may be surprising, but it\n // makes sense because we want to combine PageInfo properties with a\n // preference for existing values, *unless* the existing values are\n // overridden by the logic below, which is permitted only when the\n // incoming page falls at the beginning or end of the data.\n ...incoming.pageInfo,\n ...existing.pageInfo,\n };\n\n if (incoming.pageInfo) {\n const {\n hasPreviousPage, hasNextPage,\n startCursor, endCursor,\n ...extras\n } = incoming.pageInfo;\n\n // If incoming.pageInfo had any extra non-standard properties,\n // assume they should take precedence over any existing properties\n // of the same name, regardless of where this page falls with\n // respect to the existing data.\n Object.assign(pageInfo, extras);\n\n // Keep existing.pageInfo.has{Previous,Next}Page unless the\n // placement of the incoming edges means incoming.hasPreviousPage\n // or incoming.hasNextPage should become the new values for those\n // properties in existing.pageInfo. Note that these updates are\n // only permitted when the beginning or end of the incoming page\n // coincides with the beginning or end of the existing data, as\n // determined using prefix.length and suffix.length.\n if (!prefix.length) {\n if (void 0 !== hasPreviousPage) pageInfo.hasPreviousPage = hasPreviousPage;\n if (void 0 !== startCursor) pageInfo.startCursor = startCursor;\n }\n if (!suffix.length) {\n if (void 0 !== hasNextPage) pageInfo.hasNextPage = hasNextPage;\n if (void 0 !== endCursor) pageInfo.endCursor = endCursor;\n }\n }\n\n return {\n ...getExtras(existing),\n ...getExtras(incoming),\n edges,\n pageInfo,\n };\n },\n };\n}\n\n// Returns any unrecognized properties of the given object.\nconst getExtras = (obj: Record<string, any>) => __rest(obj, notExtras);\nconst notExtras = [\"edges\", \"pageInfo\"];\n\nfunction makeEmptyData(): TExistingRelay<any> {\n return {\n edges: [],\n pageInfo: {\n hasPreviousPage: false,\n hasNextPage: true,\n startCursor: \"\",\n endCursor: \"\",\n },\n };\n}\n"]}
1
+ {"version":3,"file":"pagination.js","sourceRoot":"","sources":["../../../src/utilities/policies/pagination.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAMhD,MAAM,UAAU,gBAAgB,CAC9B,OAAwB;IAAxB,wBAAA,EAAA,eAAwB;IAExB,OAAO;QACL,OAAO,SAAA;QACP,KAAK,YAAC,QAAQ,EAAE,QAAQ;YACtB,OAAO,QAAQ,CAAC,CAAC,iCACZ,QAAQ,SACR,QAAQ,QACX,CAAC,CAAC,QAAQ,CAAC;QACf,CAAC;KACF,CAAC;AACJ,CAAC;AAMD,MAAM,UAAU,qBAAqB,CACnC,OAAwB;IAAxB,wBAAA,EAAA,eAAwB;IAExB,OAAO;QACL,OAAO,SAAA;QACP,KAAK,YAAC,QAAQ,EAAE,QAAQ,EAAE,EAAQ;gBAAN,IAAI,UAAA;YAC9B,IAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACjD,IAAI,IAAI,EAAE;gBAEA,IAAA,KAAe,IAAI,OAAT,EAAV,MAAM,mBAAG,CAAC,KAAA,CAAU;gBAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;oBACxC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CA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ache';\nimport { mergeDeep } from '../common/mergeDeep';\n\ntype KeyArgs = FieldPolicy<any>[\"keyArgs\"];\n\n// A very basic pagination field policy that always concatenates new\n// results onto the existing array, without examining options.args.\nexport function concatPagination<T = Reference>(\n keyArgs: KeyArgs = false,\n): FieldPolicy<T[]> {\n return {\n keyArgs,\n merge(existing, incoming) {\n return existing ? [\n ...existing,\n ...incoming,\n ] : incoming;\n },\n };\n}\n\n// A basic field policy that uses options.args.{offset,limit} to splice\n// the incoming data into the existing array. If your arguments are called\n// something different (like args.{start,count}), feel free to copy/paste\n// this implementation and make the appropriate changes.\nexport function offsetLimitPagination<T = Reference>(\n keyArgs: KeyArgs = false,\n): FieldPolicy<T[]> {\n return {\n keyArgs,\n merge(existing, incoming, { args }) {\n const merged = existing ? existing.slice(0) : [];\n if (args) {\n // Assume an offset of 0 if args.offset omitted.\n const { offset = 0 } = args;\n for (let i = 0; i < incoming.length; ++i) {\n merged[offset + i] = incoming[i];\n }\n } else {\n // It's unusual (probably a mistake) for a paginated field not\n // to receive any arguments, so you might prefer to throw an\n // exception here, instead of recovering by appending incoming\n // onto the existing array.\n merged.push.apply(merged, incoming);\n }\n return merged;\n },\n };\n}\n\n// Whether TRelayEdge<TNode> is a normalized Reference or a non-normalized\n// object, it needs a .cursor property where the relayStylePagination\n// merge function can store cursor strings taken from pageInfo. Storing an\n// extra reference.cursor property should be safe, and is easier than\n// attempting to update the cursor field of the normalized StoreObject\n// that the reference refers to, or managing edge wrapper objects\n// (something I attempted in #7023, but abandoned because of #7088).\nexport type TRelayEdge<TNode> = {\n cursor?: string;\n node: TNode;\n} | (Reference & { cursor?: string });\n\nexport type TRelayPageInfo = {\n hasPreviousPage: boolean;\n hasNextPage: boolean;\n startCursor: string;\n endCursor: string;\n};\n\nexport type TExistingRelay<TNode> = Readonly<{\n edges: TRelayEdge<TNode>[];\n pageInfo: TRelayPageInfo;\n}>;\n\nexport type TIncomingRelay<TNode> = {\n edges?: TRelayEdge<TNode>[];\n pageInfo?: TRelayPageInfo;\n};\n\nexport type RelayFieldPolicy<TNode> = FieldPolicy<\n TExistingRelay<TNode> | null,\n TIncomingRelay<TNode> | null,\n TIncomingRelay<TNode> | null\n>;\n\n// As proof of the flexibility of field policies, this function generates\n// one that handles Relay-style pagination, without Apollo Client knowing\n// anything about connections, edges, cursors, or pageInfo objects.\nexport function relayStylePagination<TNode = Reference>(\n keyArgs: KeyArgs = false,\n): RelayFieldPolicy<TNode> {\n return {\n keyArgs,\n\n read(existing, { canRead, readField }) {\n if (!existing) return existing;\n\n const edges: TRelayEdge<TNode>[] = [];\n let firstEdgeCursor = \"\";\n let lastEdgeCursor = \"\";\n existing.edges.forEach(edge => {\n // Edges themselves could be Reference objects, so it's important\n // to use readField to access the edge.edge.node property.\n if (canRead(readField(\"node\", edge))) {\n edges.push(edge);\n if (edge.cursor) {\n firstEdgeCursor = firstEdgeCursor || edge.cursor || \"\";\n lastEdgeCursor = edge.cursor || lastEdgeCursor;\n }\n }\n });\n\n const {\n startCursor,\n endCursor,\n } = existing.pageInfo || {};\n\n return {\n // Some implementations return additional Connection fields, such\n // as existing.totalCount. These fields are saved by the merge\n // function, so the read function should also preserve them.\n ...getExtras(existing),\n edges,\n pageInfo: {\n ...existing.pageInfo,\n // If existing.pageInfo.{start,end}Cursor are undefined or \"\", default\n // to firstEdgeCursor and/or lastEdgeCursor.\n startCursor: startCursor || firstEdgeCursor,\n endCursor: endCursor || lastEdgeCursor,\n },\n };\n },\n\n merge(existing, incoming, { args, isReference, readField }) {\n if (!existing) {\n existing = makeEmptyData();\n }\n\n if (!incoming) {\n return existing;\n }\n\n const incomingEdges = incoming.edges ? incoming.edges.map(edge => {\n if (isReference(edge = { ...edge })) {\n // In case edge is a Reference, we read out its cursor field and\n // store it as an extra property of the Reference object.\n edge.cursor = readField<string>(\"cursor\", edge);\n }\n return edge;\n }) : [];\n\n if (incoming.pageInfo) {\n const { pageInfo } = incoming;\n const { startCursor, endCursor } = pageInfo;\n const firstEdge = incomingEdges[0];\n const lastEdge = incomingEdges[incomingEdges.length - 1];\n // In case we did not request the cursor field for edges in this\n // query, we can still infer cursors from pageInfo.\n if (firstEdge && startCursor) {\n firstEdge.cursor = startCursor;\n }\n if (lastEdge && endCursor) {\n lastEdge.cursor = endCursor;\n }\n // Cursors can also come from edges, so we default\n // pageInfo.{start,end}Cursor to {first,last}Edge.cursor.\n const firstCursor = firstEdge && firstEdge.cursor;\n if (firstCursor && !startCursor) {\n incoming = mergeDeep(incoming, {\n pageInfo: {\n startCursor: firstCursor,\n },\n });\n }\n const lastCursor = lastEdge && lastEdge.cursor;\n if (lastCursor && !endCursor) {\n incoming = mergeDeep(incoming, {\n pageInfo: {\n endCursor: lastCursor,\n },\n });\n }\n }\n\n let prefix = existing.edges;\n let suffix: typeof prefix = [];\n\n if (args && args.after) {\n // This comparison does not need to use readField(\"cursor\", edge),\n // because we stored the cursor field of any Reference edges as an\n // extra property of the Reference object.\n const index = prefix.findIndex(edge => edge.cursor === args.after);\n if (index >= 0) {\n prefix = prefix.slice(0, index + 1);\n // suffix = []; // already true\n }\n } else if (args && args.before) {\n const index = prefix.findIndex(edge => edge.cursor === args.before);\n suffix = index < 0 ? prefix : prefix.slice(index);\n prefix = [];\n } else if (incoming.edges) {\n // If we have neither args.after nor args.before, the incoming\n // edges cannot be spliced into the existing edges, so they must\n // replace the existing edges. See #6592 for a motivating example.\n prefix = [];\n }\n\n const edges = [\n ...prefix,\n ...incomingEdges,\n ...suffix,\n ];\n\n const pageInfo: TRelayPageInfo = {\n // The ordering of these two ...spreads may be surprising, but it\n // makes sense because we want to combine PageInfo properties with a\n // preference for existing values, *unless* the existing values are\n // overridden by the logic below, which is permitted only when the\n // incoming page falls at the beginning or end of the data.\n ...incoming.pageInfo,\n ...existing.pageInfo,\n };\n\n if (incoming.pageInfo) {\n const {\n hasPreviousPage, hasNextPage,\n startCursor, endCursor,\n ...extras\n } = incoming.pageInfo;\n\n // If incoming.pageInfo had any extra non-standard properties,\n // assume they should take precedence over any existing properties\n // of the same name, regardless of where this page falls with\n // respect to the existing data.\n Object.assign(pageInfo, extras);\n\n // Keep existing.pageInfo.has{Previous,Next}Page unless the\n // placement of the incoming edges means incoming.hasPreviousPage\n // or incoming.hasNextPage should become the new values for those\n // properties in existing.pageInfo. Note that these updates are\n // only permitted when the beginning or end of the incoming page\n // coincides with the beginning or end of the existing data, as\n // determined using prefix.length and suffix.length.\n if (!prefix.length) {\n if (void 0 !== hasPreviousPage) pageInfo.hasPreviousPage = hasPreviousPage;\n if (void 0 !== startCursor) pageInfo.startCursor = startCursor;\n }\n if (!suffix.length) {\n if (void 0 !== hasNextPage) pageInfo.hasNextPage = hasNextPage;\n if (void 0 !== endCursor) pageInfo.endCursor = endCursor;\n }\n }\n\n return {\n ...getExtras(existing),\n ...getExtras(incoming),\n edges,\n pageInfo,\n };\n },\n };\n}\n\n// Returns any unrecognized properties of the given object.\nconst getExtras = (obj: Record<string, any>) => __rest(obj, notExtras);\nconst notExtras = [\"edges\", \"pageInfo\"];\n\nfunction makeEmptyData(): TExistingRelay<any> {\n return {\n edges: [],\n pageInfo: {\n hasPreviousPage: false,\n hasNextPage: true,\n startCursor: \"\",\n endCursor: \"\",\n },\n };\n}\n"]}
@@ -18,7 +18,7 @@ function shouldInclude(_a, variables) {
18
18
  var evaledValue = false;
19
19
  if (ifArgument.value.kind === 'Variable') {
20
20
  evaledValue = variables && variables[ifArgument.value.name.value];
21
- __DEV__ ? globals.invariant(evaledValue !== void 0, "Invalid variable referenced in @" + directive.name.value + " directive.") : globals.invariant(evaledValue !== void 0, 39);
21
+ __DEV__ ? globals.invariant(evaledValue !== void 0, "Invalid variable referenced in @" + directive.name.value + " directive.") : globals.invariant(evaledValue !== void 0, 37);
22
22
  }
23
23
  else {
24
24
  evaledValue = ifArgument.value.value;
@@ -55,13 +55,13 @@ function getInclusionDirectives(directives) {
55
55
  return;
56
56
  var directiveArguments = directive.arguments;
57
57
  var directiveName = directive.name.value;
58
- __DEV__ ? globals.invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @" + directiveName + " directive.") : globals.invariant(directiveArguments && directiveArguments.length === 1, 40);
58
+ __DEV__ ? globals.invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @" + directiveName + " directive.") : globals.invariant(directiveArguments && directiveArguments.length === 1, 38);
59
59
  var ifArgument = directiveArguments[0];
60
- __DEV__ ? globals.invariant(ifArgument.name && ifArgument.name.value === 'if', "Invalid argument for the @" + directiveName + " directive.") : globals.invariant(ifArgument.name && ifArgument.name.value === 'if', 41);
60
+ __DEV__ ? globals.invariant(ifArgument.name && ifArgument.name.value === 'if', "Invalid argument for the @" + directiveName + " directive.") : globals.invariant(ifArgument.name && ifArgument.name.value === 'if', 39);
61
61
  var ifValue = ifArgument.value;
62
62
  __DEV__ ? globals.invariant(ifValue &&
63
63
  (ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), "Argument for the @" + directiveName + " directive must be a variable or a boolean value.") : globals.invariant(ifValue &&
64
- (ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 42);
64
+ (ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 40);
65
65
  result.push({ directive: directive, ifArgument: ifArgument });
66
66
  });
67
67
  }
@@ -74,14 +74,14 @@ function getFragmentQueryDocument(document, fragmentName) {
74
74
  document.definitions.forEach(function (definition) {
75
75
  if (definition.kind === 'OperationDefinition') {
76
76
  throw __DEV__ ? new globals.InvariantError("Found a " + definition.operation + " operation" + (definition.name ? " named '" + definition.name.value + "'" : '') + ". " +
77
- 'No operations are allowed when using a fragment as a query. Only fragments are allowed.') : new globals.InvariantError(43);
77
+ 'No operations are allowed when using a fragment as a query. Only fragments are allowed.') : new globals.InvariantError(41);
78
78
  }
79
79
  if (definition.kind === 'FragmentDefinition') {
80
80
  fragments.push(definition);
81
81
  }
82
82
  });
83
83
  if (typeof actualFragmentName === 'undefined') {
84
- __DEV__ ? globals.invariant(fragments.length === 1, "Found " + fragments.length + " fragments. `fragmentName` must be provided when there is not exactly 1 fragment.") : globals.invariant(fragments.length === 1, 44);
84
+ __DEV__ ? globals.invariant(fragments.length === 1, "Found " + fragments.length + " fragments. `fragmentName` must be provided when there is not exactly 1 fragment.") : globals.invariant(fragments.length === 1, 42);
85
85
  actualFragmentName = fragments[0].name.value;
86
86
  }
87
87
  var query = tslib.__assign(tslib.__assign({}, document), { definitions: tslib.__spreadArray([
@@ -118,7 +118,7 @@ function getFragmentFromSelection(selection, fragmentMap) {
118
118
  return selection;
119
119
  case 'FragmentSpread': {
120
120
  var fragment = fragmentMap && fragmentMap[selection.name.value];
121
- __DEV__ ? globals.invariant(fragment, "No fragment named " + selection.name.value + ".") : globals.invariant(fragment, 45);
121
+ __DEV__ ? globals.invariant(fragment, "No fragment named " + selection.name.value + ".") : globals.invariant(fragment, 43);
122
122
  return fragment;
123
123
  }
124
124
  default:
@@ -202,7 +202,7 @@ function valueToObjectRepresentation(argObj, name, value, variables) {
202
202
  else {
203
203
  throw __DEV__ ? new globals.InvariantError("The inline argument \"" + name.value + "\" of kind \"" + value.kind + "\"" +
204
204
  'is not supported. Use variables instead of inline arguments to ' +
205
- 'overcome this limitation.') : new globals.InvariantError(54);
205
+ 'overcome this limitation.') : new globals.InvariantError(52);
206
206
  }
207
207
  }
208
208
  function storeKeyNameFromField(field, variables) {
@@ -336,16 +336,16 @@ function isInlineFragment(selection) {
336
336
  }
337
337
 
338
338
  function checkDocument(doc) {
339
- __DEV__ ? globals.invariant(doc && doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql") : globals.invariant(doc && doc.kind === 'Document', 46);
339
+ __DEV__ ? globals.invariant(doc && doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql") : globals.invariant(doc && doc.kind === 'Document', 44);
340
340
  var operations = doc.definitions
341
341
  .filter(function (d) { return d.kind !== 'FragmentDefinition'; })
342
342
  .map(function (definition) {
343
343
  if (definition.kind !== 'OperationDefinition') {
344
- throw __DEV__ ? new globals.InvariantError("Schema type definitions not allowed in queries. Found: \"" + definition.kind + "\"") : new globals.InvariantError(47);
344
+ throw __DEV__ ? new globals.InvariantError("Schema type definitions not allowed in queries. Found: \"" + definition.kind + "\"") : new globals.InvariantError(45);
345
345
  }
346
346
  return definition;
347
347
  });
348
- __DEV__ ? globals.invariant(operations.length <= 1, "Ambiguous GraphQL document: contains " + operations.length + " operations") : globals.invariant(operations.length <= 1, 48);
348
+ __DEV__ ? globals.invariant(operations.length <= 1, "Ambiguous GraphQL document: contains " + operations.length + " operations") : globals.invariant(operations.length <= 1, 46);
349
349
  return doc;
350
350
  }
351
351
  function getOperationDefinition(doc) {
@@ -364,14 +364,14 @@ function getFragmentDefinitions(doc) {
364
364
  }
365
365
  function getQueryDefinition(doc) {
366
366
  var queryDef = getOperationDefinition(doc);
367
- __DEV__ ? globals.invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.') : globals.invariant(queryDef && queryDef.operation === 'query', 49);
367
+ __DEV__ ? globals.invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.') : globals.invariant(queryDef && queryDef.operation === 'query', 47);
368
368
  return queryDef;
369
369
  }
370
370
  function getFragmentDefinition(doc) {
371
- __DEV__ ? globals.invariant(doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql") : globals.invariant(doc.kind === 'Document', 50);
372
- __DEV__ ? globals.invariant(doc.definitions.length <= 1, 'Fragment must have exactly one definition.') : globals.invariant(doc.definitions.length <= 1, 51);
371
+ __DEV__ ? globals.invariant(doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql") : globals.invariant(doc.kind === 'Document', 48);
372
+ __DEV__ ? globals.invariant(doc.definitions.length <= 1, 'Fragment must have exactly one definition.') : globals.invariant(doc.definitions.length <= 1, 49);
373
373
  var fragmentDef = doc.definitions[0];
374
- __DEV__ ? globals.invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.') : globals.invariant(fragmentDef.kind === 'FragmentDefinition', 52);
374
+ __DEV__ ? globals.invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.') : globals.invariant(fragmentDef.kind === 'FragmentDefinition', 50);
375
375
  return fragmentDef;
376
376
  }
377
377
  function getMainDefinition(queryDoc) {
@@ -394,7 +394,7 @@ function getMainDefinition(queryDoc) {
394
394
  if (fragmentDefinition) {
395
395
  return fragmentDefinition;
396
396
  }
397
- throw __DEV__ ? new globals.InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.') : new globals.InvariantError(53);
397
+ throw __DEV__ ? new globals.InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.') : new globals.InvariantError(51);
398
398
  }
399
399
  function getDefaultValues(definition) {
400
400
  var defaultValues = Object.create(null);
@@ -733,7 +733,12 @@ var DeepMerger = (function () {
733
733
  return source;
734
734
  };
735
735
  DeepMerger.prototype.shallowCopyForMerge = function (value) {
736
- if (isNonNullObject(value) && !this.pastCopies.has(value)) {
736
+ if (isNonNullObject(value)) {
737
+ if (this.pastCopies.has(value)) {
738
+ if (!Object.isFrozen(value))
739
+ return value;
740
+ this.pastCopies.delete(value);
741
+ }
737
742
  if (Array.isArray(value)) {
738
743
  value = value.slice(0);
739
744
  }
@@ -783,7 +788,7 @@ function relayStylePagination(keyArgs) {
783
788
  read: function (existing, _a) {
784
789
  var canRead = _a.canRead, readField = _a.readField;
785
790
  if (!existing)
786
- return;
791
+ return existing;
787
792
  var edges = [];
788
793
  var firstEdgeCursor = "";
789
794
  var lastEdgeCursor = "";
@@ -800,8 +805,13 @@ function relayStylePagination(keyArgs) {
800
805
  return tslib.__assign(tslib.__assign({}, getExtras(existing)), { edges: edges, pageInfo: tslib.__assign(tslib.__assign({}, existing.pageInfo), { startCursor: startCursor || firstEdgeCursor, endCursor: endCursor || lastEdgeCursor }) });
801
806
  },
802
807
  merge: function (existing, incoming, _a) {
803
- if (existing === void 0) { existing = makeEmptyData(); }
804
808
  var args = _a.args, isReference = _a.isReference, readField = _a.readField;
809
+ if (!existing) {
810
+ existing = makeEmptyData();
811
+ }
812
+ if (!incoming) {
813
+ return existing;
814
+ }
805
815
  var incomingEdges = incoming.edges ? incoming.edges.map(function (edge) {
806
816
  if (isReference(edge = tslib.__assign({}, edge))) {
807
817
  edge.cursor = readField("cursor", edge);
@@ -924,9 +934,7 @@ function cloneDeepHelper(val, seen) {
924
934
  function deepFreeze(value) {
925
935
  var workSet = new Set([value]);
926
936
  workSet.forEach(function (obj) {
927
- if (isNonNullObject(obj)) {
928
- if (!Object.isFrozen(obj))
929
- Object.freeze(obj);
937
+ if (isNonNullObject(obj) && shallowFreeze(obj) === obj) {
930
938
  Object.getOwnPropertyNames(obj).forEach(function (name) {
931
939
  if (isNonNullObject(obj[name]))
932
940
  workSet.add(obj[name]);
@@ -935,6 +943,19 @@ function deepFreeze(value) {
935
943
  });
936
944
  return value;
937
945
  }
946
+ function shallowFreeze(obj) {
947
+ if (__DEV__ && !Object.isFrozen(obj)) {
948
+ try {
949
+ Object.freeze(obj);
950
+ }
951
+ catch (e) {
952
+ if (e instanceof TypeError)
953
+ return null;
954
+ throw e;
955
+ }
956
+ }
957
+ return obj;
958
+ }
938
959
  function maybeDeepFreeze(obj) {
939
960
  if (__DEV__) {
940
961
  deepFreeze(obj);
@@ -996,11 +1017,17 @@ function asyncMap(observable, mapFn, catchFn) {
996
1017
  });
997
1018
  }
998
1019
 
1020
+ var canUseWeakMap = typeof WeakMap === 'function' && !(typeof navigator === 'object' &&
1021
+ navigator.product === 'ReactNative');
1022
+ var canUseWeakSet = typeof WeakSet === 'function';
1023
+ var canUseSymbol = typeof Symbol === 'function' &&
1024
+ typeof Symbol.for === 'function';
1025
+
999
1026
  function fixObservableSubclass(subclass) {
1000
1027
  function set(key) {
1001
1028
  Object.defineProperty(subclass, key, { value: zenObservableTs.Observable });
1002
1029
  }
1003
- if (typeof Symbol === "function" && Symbol.species) {
1030
+ if (canUseSymbol && Symbol.species) {
1004
1031
  set(Symbol.species);
1005
1032
  }
1006
1033
  set("@@species");
@@ -1146,10 +1173,6 @@ function graphQLResultHasError(result) {
1146
1173
  return (result.errors && result.errors.length > 0) || false;
1147
1174
  }
1148
1175
 
1149
- var canUseWeakMap = typeof WeakMap === 'function' && !(typeof navigator === 'object' &&
1150
- navigator.product === 'ReactNative');
1151
- var canUseWeakSet = typeof WeakSet === 'function';
1152
-
1153
1176
  function compact() {
1154
1177
  var objects = [];
1155
1178
  for (var _i = 0; _i < arguments.length; _i++) {
@@ -1192,6 +1215,7 @@ exports.addTypenameToDocument = addTypenameToDocument;
1192
1215
  exports.argumentsObjectFromField = argumentsObjectFromField;
1193
1216
  exports.asyncMap = asyncMap;
1194
1217
  exports.buildQueryFromSelectionSet = buildQueryFromSelectionSet;
1218
+ exports.canUseSymbol = canUseSymbol;
1195
1219
  exports.canUseWeakMap = canUseWeakMap;
1196
1220
  exports.canUseWeakSet = canUseWeakSet;
1197
1221
  exports.checkDocument = checkDocument;