@apollo/client 3.5.0-rc.3 → 3.5.3

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 (93) hide show
  1. package/README.md +1 -1
  2. package/apollo-client.cjs +69 -53
  3. package/apollo-client.cjs.map +1 -1
  4. package/apollo-client.min.cjs +1 -1
  5. package/cache/core/cache.js +2 -2
  6. package/cache/inmemory/entityStore.js +4 -4
  7. package/cache/inmemory/inMemoryCache.js +3 -3
  8. package/cache/inmemory/object-canon.js +2 -2
  9. package/cache/inmemory/policies.js +1 -1
  10. package/cache/inmemory/reactiveVars.js +2 -2
  11. package/cache/inmemory/readFromStore.js +2 -2
  12. package/cache/inmemory/writeToStore.js +3 -3
  13. package/config/jest/setup.js +1 -1
  14. package/core/ApolloClient.js +1 -1
  15. package/core/LocalState.js +2 -2
  16. package/core/ObservableQuery.js +2 -2
  17. package/core/QueryInfo.js +2 -2
  18. package/core/QueryManager.d.ts.map +1 -1
  19. package/core/QueryManager.js +2 -2
  20. package/core/QueryManager.js.map +1 -1
  21. package/core/core.cjs +1 -1
  22. package/core/core.cjs.map +1 -1
  23. package/core/index.js +2 -2
  24. package/errors/index.js +1 -1
  25. package/invariantErrorCodes.js +1 -1
  26. package/link/batch/batchLink.js +1 -1
  27. package/link/batch/batching.js +1 -1
  28. package/link/batch-http/batchHttpLink.js +1 -1
  29. package/link/context/index.js +1 -1
  30. package/link/core/ApolloLink.js +1 -1
  31. package/link/core/types.d.ts +4 -6
  32. package/link/core/types.d.ts.map +1 -1
  33. package/link/core/types.js.map +1 -1
  34. package/link/error/index.js +1 -1
  35. package/link/http/HttpLink.js +1 -1
  36. package/link/http/createHttpLink.js +2 -2
  37. package/link/http/selectHttpOptionsAndBody.js +2 -2
  38. package/link/persisted-queries/index.js +2 -2
  39. package/link/retry/retryLink.js +1 -1
  40. package/link/schema/index.js +10 -3
  41. package/link/schema/index.js.map +1 -1
  42. package/link/schema/schema.cjs +8 -1
  43. package/link/schema/schema.cjs.map +1 -1
  44. package/link/utils/createOperation.js +1 -1
  45. package/link/ws/index.js +2 -2
  46. package/package.json +13 -13
  47. package/react/components/Mutation.js +1 -1
  48. package/react/components/Query.js +2 -2
  49. package/react/components/Subscription.js +1 -1
  50. package/react/context/ApolloConsumer.js +1 -1
  51. package/react/context/ApolloContext.js +1 -1
  52. package/react/context/ApolloProvider.js +1 -1
  53. package/react/hoc/hoc-utils.js +2 -2
  54. package/react/hoc/mutation-hoc.js +3 -3
  55. package/react/hoc/query-hoc.js +3 -3
  56. package/react/hoc/subscription-hoc.js +3 -3
  57. package/react/hoc/withApollo.js +3 -3
  58. package/react/hooks/hooks.cjs +67 -51
  59. package/react/hooks/hooks.cjs.map +1 -1
  60. package/react/hooks/useApolloClient.js +1 -1
  61. package/react/hooks/useLazyQuery.js +2 -2
  62. package/react/hooks/useMutation.d.ts.map +1 -1
  63. package/react/hooks/useMutation.js +70 -54
  64. package/react/hooks/useMutation.js.map +1 -1
  65. package/react/hooks/useQuery.js +3 -3
  66. package/react/hooks/useReactiveVar.js +1 -1
  67. package/react/hooks/useSubscription.js +2 -2
  68. package/react/ssr/getDataFromTree.js +2 -2
  69. package/testing/core/mocking/mockFetch.js +2 -2
  70. package/testing/core/mocking/mockLink.js +3 -3
  71. package/testing/core/mocking/mockSubscriptionLink.d.ts +1 -3
  72. package/testing/core/mocking/mockSubscriptionLink.d.ts.map +1 -1
  73. package/testing/core/mocking/mockSubscriptionLink.js +1 -1
  74. package/testing/core/mocking/mockWatchQuery.js +1 -1
  75. package/testing/core/observableToPromise.js +1 -1
  76. package/testing/react/MockedProvider.js +2 -2
  77. package/utilities/common/errorHandling.d.ts +1 -1
  78. package/utilities/common/errorHandling.d.ts.map +1 -1
  79. package/utilities/common/errorHandling.js.map +1 -1
  80. package/utilities/common/mergeDeep.js +1 -1
  81. package/utilities/globals/fix-graphql.js +2 -2
  82. package/utilities/globals/index.js +1 -1
  83. package/utilities/graphql/directives.js +1 -1
  84. package/utilities/graphql/fragments.d.ts.map +1 -1
  85. package/utilities/graphql/fragments.js +1 -1
  86. package/utilities/graphql/fragments.js.map +1 -1
  87. package/utilities/graphql/transform.d.ts.map +1 -1
  88. package/utilities/graphql/transform.js +2 -2
  89. package/utilities/graphql/transform.js.map +1 -1
  90. package/utilities/observables/Concast.js +1 -1
  91. package/utilities/observables/Observable.js +2 -2
  92. package/utilities/policies/pagination.js +2 -2
  93. package/version.js +1 -1
package/README.md CHANGED
@@ -31,7 +31,7 @@ Learn how to use Apollo Client with self-paced hands-on training on Odyssey, Apo
31
31
  [Apollo](https://apollographql.com/) builds open-source software and a graph platform to unify GraphQL across your apps and services. We help you ship faster with:
32
32
 
33
33
  * [Apollo Studio](https://www.apollographql.com/studio/develop/) – A free, end-to-end platform for managing your GraphQL lifecycle. Track your GraphQL schemas in a hosted registry to create a source of truth for everything in your graph. Studio provides an IDE (Apollo Explorer) so you can explore data, collaborate on queries, observe usage, and safely make schema changes.
34
- * [Apollo Federation](https://www.apollographql.com/apollo-federation) – The industry-standard open architecture for building a distributed graph. Use Apollo’s open-source gateway to compose a unified graph from multiple subgraphs, determine a query plan, and route requests across your services.
34
+ * [Apollo Federation](https://www.apollographql.com/apollo-federation) – The industry-standard open architecture for building a distributed graph. Use Apollo’s gateway to compose a unified graph from multiple subgraphs, determine a query plan, and route requests across your services.
35
35
  * [Apollo Client](https://www.apollographql.com/apollo-client/) – The most popular GraphQL client for the web. Apollo also builds and maintains [Apollo iOS](https://github.com/apollographql/apollo-ios) and [Apollo Android](https://github.com/apollographql/apollo-android).
36
36
  * [Apollo Server](https://www.apollographql.com/docs/apollo-server/) – A production-ready JavaScript GraphQL server that connects to any microservice, API, or database. Compatible with all popular JavaScript frameworks and deployable in serverless environments.
37
37
 
package/apollo-client.cjs CHANGED
@@ -1291,7 +1291,7 @@ var concat = ApolloLink.concat;
1291
1291
 
1292
1292
  var execute = ApolloLink.execute;
1293
1293
 
1294
- var version = '3.5.0-rc.3';
1294
+ var version = '3.5.3';
1295
1295
 
1296
1296
  var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
1297
1297
  function parseAndCheckHttpResponse(operations) {
@@ -6323,63 +6323,79 @@ function useMutation(mutation, options) {
6323
6323
  result: result,
6324
6324
  mutationId: 0,
6325
6325
  isMounted: true,
6326
+ execute: null,
6327
+ client: client,
6328
+ mutation: mutation,
6329
+ options: options,
6326
6330
  });
6327
- var execute = React.useCallback(function (executeOptions) {
6328
- if (executeOptions === void 0) { executeOptions = {}; }
6329
- var baseOptions = tslib.__assign(tslib.__assign({}, options), { mutation: mutation });
6330
- if (!ref.current.result.loading && !baseOptions.ignoreResults) {
6331
- setResult(ref.current.result = {
6332
- loading: true,
6333
- error: void 0,
6334
- data: void 0,
6335
- called: true,
6336
- client: client,
6337
- });
6338
- }
6339
- var mutationId = ++ref.current.mutationId;
6340
- var clientOptions = mergeOptions(baseOptions, executeOptions);
6341
- return client.mutate(clientOptions).then(function (response) {
6342
- var _a;
6343
- var data = response.data, errors = response.errors;
6344
- var error = errors && errors.length > 0
6345
- ? new ApolloError({ graphQLErrors: errors })
6346
- : void 0;
6347
- if (mutationId === ref.current.mutationId &&
6348
- !baseOptions.ignoreResults) {
6349
- var result_1 = {
6350
- called: true,
6351
- loading: false,
6352
- data: data,
6353
- error: error,
6354
- client: client,
6355
- };
6356
- if (ref.current.isMounted && !equality.equal(ref.current.result, result_1)) {
6357
- setResult(ref.current.result = result_1);
6358
- }
6359
- }
6360
- (_a = baseOptions.onCompleted) === null || _a === void 0 ? void 0 : _a.call(baseOptions, response.data);
6361
- return response;
6362
- }).catch(function (error) {
6363
- if (mutationId === ref.current.mutationId &&
6364
- ref.current.isMounted) {
6365
- var result_2 = {
6366
- loading: false,
6367
- error: error,
6331
+ var execute = React.useMemo(function () {
6332
+ if (ref.current.execute != null &&
6333
+ ref.current.client === client &&
6334
+ equality.equal(options, ref.current.options) &&
6335
+ equality.equal(mutation, ref.current.mutation)) {
6336
+ return ref.current.execute;
6337
+ }
6338
+ ref.current.client = client;
6339
+ ref.current.options = options;
6340
+ ref.current.mutation = mutation;
6341
+ ref.current.execute = function (executeOptions) {
6342
+ if (executeOptions === void 0) { executeOptions = {}; }
6343
+ var baseOptions = tslib.__assign(tslib.__assign({}, options), { mutation: mutation });
6344
+ if (!ref.current.result.loading && !baseOptions.ignoreResults) {
6345
+ setResult(ref.current.result = {
6346
+ loading: true,
6347
+ error: void 0,
6368
6348
  data: void 0,
6369
6349
  called: true,
6370
6350
  client: client,
6371
- };
6372
- if (!equality.equal(ref.current.result, result_2)) {
6373
- setResult(ref.current.result = result_2);
6374
- }
6375
- }
6376
- if (baseOptions.onError) {
6377
- baseOptions.onError(error);
6378
- return { data: void 0, errors: error };
6351
+ });
6379
6352
  }
6380
- throw error;
6381
- });
6382
- }, [client, options, mutation]);
6353
+ var mutationId = ++ref.current.mutationId;
6354
+ var clientOptions = mergeOptions(baseOptions, executeOptions);
6355
+ return client.mutate(clientOptions).then(function (response) {
6356
+ var _a;
6357
+ var data = response.data, errors = response.errors;
6358
+ var error = errors && errors.length > 0
6359
+ ? new ApolloError({ graphQLErrors: errors })
6360
+ : void 0;
6361
+ if (mutationId === ref.current.mutationId &&
6362
+ !baseOptions.ignoreResults) {
6363
+ var result_1 = {
6364
+ called: true,
6365
+ loading: false,
6366
+ data: data,
6367
+ error: error,
6368
+ client: client,
6369
+ };
6370
+ if (ref.current.isMounted && !equality.equal(ref.current.result, result_1)) {
6371
+ setResult(ref.current.result = result_1);
6372
+ }
6373
+ }
6374
+ (_a = baseOptions.onCompleted) === null || _a === void 0 ? void 0 : _a.call(baseOptions, response.data);
6375
+ return response;
6376
+ }).catch(function (error) {
6377
+ if (mutationId === ref.current.mutationId &&
6378
+ ref.current.isMounted) {
6379
+ var result_2 = {
6380
+ loading: false,
6381
+ error: error,
6382
+ data: void 0,
6383
+ called: true,
6384
+ client: client,
6385
+ };
6386
+ if (!equality.equal(ref.current.result, result_2)) {
6387
+ setResult(ref.current.result = result_2);
6388
+ }
6389
+ }
6390
+ if (baseOptions.onError) {
6391
+ baseOptions.onError(error);
6392
+ return { data: void 0, errors: error };
6393
+ }
6394
+ throw error;
6395
+ });
6396
+ };
6397
+ return ref.current.execute;
6398
+ }, [client, mutation, options]);
6383
6399
  var reset = React.useCallback(function () {
6384
6400
  setResult({ called: false, loading: false, client: client });
6385
6401
  }, []);