@apollo/client 3.9.7 → 3.10.0-alpha.1

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 (41) hide show
  1. package/.changeset/flat-singers-kiss.md +5 -0
  2. package/.changeset/pre.json +11 -0
  3. package/.changeset/tasty-pillows-ring.md +5 -0
  4. package/CHANGELOG.md +12 -0
  5. package/apollo-client.cjs +46 -10
  6. package/apollo-client.cjs.map +1 -1
  7. package/apollo-client.min.cjs +1 -1
  8. package/cache/cache.cjs +27 -0
  9. package/cache/cache.cjs.map +1 -1
  10. package/cache/cache.cjs.native.js +27 -0
  11. package/cache/core/cache.d.ts +83 -1
  12. package/cache/core/cache.js +30 -1
  13. package/cache/core/cache.js.map +1 -1
  14. package/core/ApolloClient.d.ts +26 -8
  15. package/core/ApolloClient.js +26 -7
  16. package/core/ApolloClient.js.map +1 -1
  17. package/core/core.cjs +4 -1
  18. package/core/core.cjs.map +1 -1
  19. package/core/core.cjs.native.js +4 -1
  20. package/core/watchQueryOptions.d.ts +3 -3
  21. package/dev/dev.cjs +1 -1
  22. package/dev/dev.cjs.map +1 -1
  23. package/dev/dev.cjs.native.js +1 -1
  24. package/package.json +17 -17
  25. package/react/hooks/hooks.cjs +26 -17
  26. package/react/hooks/hooks.cjs.map +1 -1
  27. package/react/hooks/hooks.cjs.native.js +26 -17
  28. package/react/hooks/useFragment.d.ts +1 -1
  29. package/react/hooks/useFragment.js +22 -14
  30. package/react/hooks/useFragment.js.map +1 -1
  31. package/react/internal/cache/QueryReference.d.ts +2 -2
  32. package/react/internal/cache/QueryReference.js.map +1 -1
  33. package/react/query-preloader/createQueryPreloader.d.ts +6 -6
  34. package/react/query-preloader/createQueryPreloader.js.map +1 -1
  35. package/react/types/types.d.ts +3 -3
  36. package/react/types/types.documentation.d.ts +4 -4
  37. package/react/types/types.documentation.js.map +1 -1
  38. package/utilities/globals/globals.cjs +1 -1
  39. package/utilities/globals/globals.cjs.map +1 -1
  40. package/utilities/globals/globals.cjs.native.js +1 -1
  41. package/version.js +1 -1
package/cache/cache.cjs CHANGED
@@ -96,6 +96,33 @@ var ApolloCache = (function () {
96
96
  if (optimistic === void 0) { optimistic = !!options.optimistic; }
97
97
  return this.read(tslib.__assign(tslib.__assign({}, options), { rootId: options.id || "ROOT_QUERY", optimistic: optimistic }));
98
98
  };
99
+ ApolloCache.prototype.watchFragment = function (options) {
100
+ var _this = this;
101
+ var fragment = options.fragment, fragmentName = options.fragmentName, from = options.from, _a = options.optimistic, optimistic = _a === void 0 ? true : _a;
102
+ var diffOptions = {
103
+ returnPartialData: true,
104
+ id: typeof from === "string" ? from : this.identify(from),
105
+ query: this.getFragmentDoc(fragment, fragmentName),
106
+ optimistic: optimistic,
107
+ };
108
+ var latestDiff;
109
+ return new utilities.Observable(function (observer) {
110
+ return _this.watch(tslib.__assign(tslib.__assign({}, diffOptions), { immediate: true, query: _this.getFragmentDoc(fragment, fragmentName), callback: function (diff) {
111
+ if (equality.equal(diff, latestDiff)) {
112
+ return;
113
+ }
114
+ var result = {
115
+ data: diff.result,
116
+ complete: !!diff.complete,
117
+ };
118
+ if (diff.missing) {
119
+ result.missing = utilities.mergeDeepArray(diff.missing.map(function (error) { return error.missing; }));
120
+ }
121
+ latestDiff = diff;
122
+ observer.next(result);
123
+ } }));
124
+ });
125
+ };
99
126
  ApolloCache.prototype.readFragment = function (options, optimistic) {
100
127
  if (optimistic === void 0) { optimistic = !!options.optimistic; }
101
128
  return this.read(tslib.__assign(tslib.__assign({}, options), { query: this.getFragmentDoc(options.fragment, options.fragmentName), rootId: options.id, optimistic: optimistic }));