@apollo/client 3.5.5 → 3.5.6

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.
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.5';
1294
+ var version = '3.5.6';
1295
1295
 
1296
1296
  var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
1297
1297
  function parseAndCheckHttpResponse(operations) {
@@ -6146,7 +6146,7 @@ function useQuery(query, options) {
6146
6146
  }
6147
6147
  }
6148
6148
  }
6149
- Object.assign(ref.current, { client: client, query: query, options: options });
6149
+ Object.assign(ref.current, { client: client, query: query });
6150
6150
  }, [obsQuery, client, query, options]);
6151
6151
  React.useEffect(function () {
6152
6152
  if (context.renderPromises) {
@@ -6216,6 +6216,7 @@ function useQuery(query, options) {
6216
6216
  result.loading) {
6217
6217
  obsQuery.setOptions(createWatchQueryOptions(query, options)).catch(function () { });
6218
6218
  }
6219
+ Object.assign(ref.current, { options: options });
6219
6220
  }
6220
6221
  if ((context.renderPromises || client.disableNetworkFetches) &&
6221
6222
  (options === null || options === void 0 ? void 0 : options.ssr) === false) {
@@ -6245,7 +6246,7 @@ function useQuery(query, options) {
6245
6246
  stopPolling: obsQuery.stopPolling.bind(obsQuery),
6246
6247
  subscribeToMore: obsQuery.subscribeToMore.bind(obsQuery),
6247
6248
  }); }, [obsQuery]);
6248
- return tslib.__assign(tslib.__assign(tslib.__assign({}, obsQueryFields), { variables: obsQuery.variables, client: client, called: true, previousData: ref.current.previousData }), result);
6249
+ return tslib.__assign(tslib.__assign(tslib.__assign({}, obsQueryFields), { variables: createWatchQueryOptions(query, options).variables, client: client, called: true, previousData: ref.current.previousData }), result);
6249
6250
  }
6250
6251
  function createWatchQueryOptions(query, options) {
6251
6252
  var _a;
@@ -6262,6 +6263,9 @@ function createWatchQueryOptions(query, options) {
6262
6263
  else if (!watchQueryOptions.fetchPolicy) {
6263
6264
  watchQueryOptions.fetchPolicy = 'cache-first';
6264
6265
  }
6266
+ if (!watchQueryOptions.variables) {
6267
+ watchQueryOptions.variables = {};
6268
+ }
6265
6269
  return tslib.__assign({ query: query }, watchQueryOptions);
6266
6270
  }
6267
6271
 
@@ -6333,82 +6337,73 @@ function useMutation(mutation, options) {
6333
6337
  result: result,
6334
6338
  mutationId: 0,
6335
6339
  isMounted: true,
6336
- execute: null,
6337
6340
  client: client,
6338
6341
  mutation: mutation,
6339
6342
  options: options,
6340
6343
  });
6341
- var execute = React.useMemo(function () {
6342
- if (ref.current.execute != null &&
6343
- ref.current.client === client &&
6344
- equality.equal(options, ref.current.options) &&
6345
- equality.equal(mutation, ref.current.mutation)) {
6346
- return ref.current.execute;
6347
- }
6348
- ref.current.client = client;
6349
- ref.current.options = options;
6350
- ref.current.mutation = mutation;
6351
- ref.current.execute = function (executeOptions) {
6352
- if (executeOptions === void 0) { executeOptions = {}; }
6353
- var baseOptions = tslib.__assign(tslib.__assign({}, options), { mutation: mutation });
6354
- if (!ref.current.result.loading && !baseOptions.ignoreResults) {
6355
- setResult(ref.current.result = {
6356
- loading: true,
6357
- error: void 0,
6358
- data: void 0,
6344
+ {
6345
+ Object.assign(ref.current, { client: client, options: options, mutation: mutation });
6346
+ }
6347
+ var execute = React.useCallback(function (executeOptions) {
6348
+ if (executeOptions === void 0) { executeOptions = {}; }
6349
+ var _a = ref.current, client = _a.client, options = _a.options, mutation = _a.mutation;
6350
+ var baseOptions = tslib.__assign(tslib.__assign({}, options), { mutation: mutation });
6351
+ if (!ref.current.result.loading && !baseOptions.ignoreResults) {
6352
+ setResult(ref.current.result = {
6353
+ loading: true,
6354
+ error: void 0,
6355
+ data: void 0,
6356
+ called: true,
6357
+ client: client,
6358
+ });
6359
+ }
6360
+ var mutationId = ++ref.current.mutationId;
6361
+ var clientOptions = mergeOptions(baseOptions, executeOptions);
6362
+ return client.mutate(clientOptions).then(function (response) {
6363
+ var _a, _b;
6364
+ var data = response.data, errors = response.errors;
6365
+ var error = errors && errors.length > 0
6366
+ ? new ApolloError({ graphQLErrors: errors })
6367
+ : void 0;
6368
+ if (mutationId === ref.current.mutationId &&
6369
+ !clientOptions.ignoreResults) {
6370
+ var result_1 = {
6359
6371
  called: true,
6372
+ loading: false,
6373
+ data: data,
6374
+ error: error,
6360
6375
  client: client,
6361
- });
6362
- }
6363
- var mutationId = ++ref.current.mutationId;
6364
- var clientOptions = mergeOptions(baseOptions, executeOptions);
6365
- return client.mutate(clientOptions).then(function (response) {
6366
- var _a, _b;
6367
- var data = response.data, errors = response.errors;
6368
- var error = errors && errors.length > 0
6369
- ? new ApolloError({ graphQLErrors: errors })
6370
- : void 0;
6371
- if (mutationId === ref.current.mutationId &&
6372
- !clientOptions.ignoreResults) {
6373
- var result_1 = {
6374
- called: true,
6375
- loading: false,
6376
- data: data,
6377
- error: error,
6378
- client: client,
6379
- };
6380
- if (ref.current.isMounted && !equality.equal(ref.current.result, result_1)) {
6381
- setResult(ref.current.result = result_1);
6382
- }
6383
- }
6384
- (_a = baseOptions.onCompleted) === null || _a === void 0 ? void 0 : _a.call(baseOptions, response.data);
6385
- (_b = executeOptions.onCompleted) === null || _b === void 0 ? void 0 : _b.call(executeOptions, response.data);
6386
- return response;
6387
- }).catch(function (error) {
6388
- var _a, _b;
6389
- if (mutationId === ref.current.mutationId &&
6390
- ref.current.isMounted) {
6391
- var result_2 = {
6392
- loading: false,
6393
- error: error,
6394
- data: void 0,
6395
- called: true,
6396
- client: client,
6397
- };
6398
- if (!equality.equal(ref.current.result, result_2)) {
6399
- setResult(ref.current.result = result_2);
6400
- }
6376
+ };
6377
+ if (ref.current.isMounted && !equality.equal(ref.current.result, result_1)) {
6378
+ setResult(ref.current.result = result_1);
6401
6379
  }
6402
- if (baseOptions.onError || clientOptions.onError) {
6403
- (_a = baseOptions.onError) === null || _a === void 0 ? void 0 : _a.call(baseOptions, error);
6404
- (_b = executeOptions.onError) === null || _b === void 0 ? void 0 : _b.call(executeOptions, error);
6405
- return { data: void 0, errors: error };
6380
+ }
6381
+ (_a = baseOptions.onCompleted) === null || _a === void 0 ? void 0 : _a.call(baseOptions, response.data);
6382
+ (_b = executeOptions.onCompleted) === null || _b === void 0 ? void 0 : _b.call(executeOptions, response.data);
6383
+ return response;
6384
+ }).catch(function (error) {
6385
+ var _a, _b;
6386
+ if (mutationId === ref.current.mutationId &&
6387
+ ref.current.isMounted) {
6388
+ var result_2 = {
6389
+ loading: false,
6390
+ error: error,
6391
+ data: void 0,
6392
+ called: true,
6393
+ client: client,
6394
+ };
6395
+ if (!equality.equal(ref.current.result, result_2)) {
6396
+ setResult(ref.current.result = result_2);
6406
6397
  }
6407
- throw error;
6408
- });
6409
- };
6410
- return ref.current.execute;
6411
- }, [client, mutation, options]);
6398
+ }
6399
+ if (baseOptions.onError || clientOptions.onError) {
6400
+ (_a = baseOptions.onError) === null || _a === void 0 ? void 0 : _a.call(baseOptions, error);
6401
+ (_b = executeOptions.onError) === null || _b === void 0 ? void 0 : _b.call(executeOptions, error);
6402
+ return { data: void 0, errors: error };
6403
+ }
6404
+ throw error;
6405
+ });
6406
+ }, []);
6412
6407
  var reset = React.useCallback(function () {
6413
6408
  setResult({ called: false, loading: false, client: client });
6414
6409
  }, []);