@apollo/client 3.7.1 → 3.7.2

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.
@@ -15,7 +15,7 @@ var utils = require('../link/utils');
15
15
  var tsInvariant = require('ts-invariant');
16
16
  var graphqlTag = require('graphql-tag');
17
17
 
18
- var version = '3.7.1';
18
+ var version = '3.7.2';
19
19
 
20
20
  function isExecutionPatchIncrementalResult(value) {
21
21
  return !!value.incremental;
@@ -1659,7 +1659,6 @@ var QueryManager = (function () {
1659
1659
  };
1660
1660
  QueryManager.prototype.getResultsFromLink = function (queryInfo, cacheWriteBehavior, options) {
1661
1661
  var requestId = queryInfo.lastRequestId = this.generateRequestId();
1662
- options = utilities.cloneDeep(options);
1663
1662
  var linkDocument = this.cache.transformForLink(this.transform(queryInfo.document).document);
1664
1663
  return utilities.asyncMap(this.getObservableFromLink(linkDocument, options.context, options.variables), function (result) {
1665
1664
  var graphQLErrors = utilities.isNonEmptyArray(result.errors)
@@ -1958,7 +1957,7 @@ var ApolloClient = (function () {
1958
1957
  if (connectToDevTools && typeof window === 'object') {
1959
1958
  window.__APOLLO_CLIENT__ = this;
1960
1959
  }
1961
- if (!hasSuggestedDevtools && __DEV__) {
1960
+ if (!hasSuggestedDevtools && connectToDevTools && __DEV__) {
1962
1961
  hasSuggestedDevtools = true;
1963
1962
  if (typeof window !== 'undefined' &&
1964
1963
  window.document &&
package/errors/errors.cjs CHANGED
@@ -32,6 +32,7 @@ var ApolloError = (function (_super) {
32
32
  function ApolloError(_a) {
33
33
  var graphQLErrors = _a.graphQLErrors, clientErrors = _a.clientErrors, networkError = _a.networkError, errorMessage = _a.errorMessage, extraInfo = _a.extraInfo;
34
34
  var _this = _super.call(this, errorMessage) || this;
35
+ _this.name = 'ApolloError';
35
36
  _this.graphQLErrors = graphQLErrors || [];
36
37
  _this.clientErrors = clientErrors || [];
37
38
  _this.networkError = networkError || null;
@@ -1 +1 @@
1
- {"version":3,"file":"errors.cjs","sources":["index.js"],"sourcesContent":["import { __extends } from \"tslib\";\nimport '../utilities/globals';\nimport { isNonEmptyArray } from '../utilities';\nexport function isApolloError(err) {\n return err.hasOwnProperty('graphQLErrors');\n}\nvar generateErrorMessage = function (err) {\n var message = '';\n if (isNonEmptyArray(err.graphQLErrors) || isNonEmptyArray(err.clientErrors)) {\n var errors = (err.graphQLErrors || [])\n .concat(err.clientErrors || []);\n errors.forEach(function (error) {\n var errorMessage = error\n ? error.message\n : 'Error message not found.';\n message += \"\".concat(errorMessage, \"\\n\");\n });\n }\n if (err.networkError) {\n message += \"\".concat(err.networkError.message, \"\\n\");\n }\n message = message.replace(/\\n$/, '');\n return message;\n};\nvar ApolloError = (function (_super) {\n __extends(ApolloError, _super);\n function ApolloError(_a) {\n var graphQLErrors = _a.graphQLErrors, clientErrors = _a.clientErrors, networkError = _a.networkError, errorMessage = _a.errorMessage, extraInfo = _a.extraInfo;\n var _this = _super.call(this, errorMessage) || this;\n _this.graphQLErrors = graphQLErrors || [];\n _this.clientErrors = clientErrors || [];\n _this.networkError = networkError || null;\n _this.message = errorMessage || generateErrorMessage(_this);\n _this.extraInfo = extraInfo;\n _this.__proto__ = ApolloError.prototype;\n return _this;\n }\n return ApolloError;\n}(Error));\nexport { ApolloError };\n//# sourceMappingURL=index.js.map"],"names":["isNonEmptyArray","__extends"],"mappings":";;;;;;;;AAGO,SAAS,aAAa,CAAC,GAAG,EAAE;AACnC,IAAI,OAAO,GAAG,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC;AAC/C,CAAC;AACD,IAAI,oBAAoB,GAAG,UAAU,GAAG,EAAE;AAC1C,IAAI,IAAI,OAAO,GAAG,EAAE,CAAC;AACrB,IAAI,IAAIA,yBAAe,CAAC,GAAG,CAAC,aAAa,CAAC,IAAIA,yBAAe,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE;AACjF,QAAQ,IAAI,MAAM,GAAG,CAAC,GAAG,CAAC,aAAa,IAAI,EAAE;AAC7C,aAAa,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ClD,QAAQ,KAAK,CAAC,OAAO,GAAG,YAAY,IAAI,oBAAoB,CAAC,KAAK,CAAC,CAAC;AACpE,QAAQ,KAAK,CAAC,SAAS,GAAG,SAAS,CAAC;AACpC,QAAQ,KAAK,CAAC,SAAS,GAAG,WAAW,CAAC,SAAS,CAAC;AAChD,QAAQ,OAAO,KAAK,CAAC;AACrB,KAAK;AACL,IAAI,OAAO,WAAW,CAAC;AACvB,CAAC,CAAC,KAAK,CAAC;;;;;"}
1
+ {"version":3,"file":"errors.cjs","sources":["index.js"],"sourcesContent":["import { __extends } from \"tslib\";\nimport '../utilities/globals';\nimport { isNonEmptyArray } from '../utilities';\nexport function isApolloError(err) {\n return err.hasOwnProperty('graphQLErrors');\n}\nvar generateErrorMessage = function (err) {\n var message = '';\n if (isNonEmptyArray(err.graphQLErrors) || isNonEmptyArray(err.clientErrors)) {\n var errors = (err.graphQLErrors || [])\n .concat(err.clientErrors || []);\n errors.forEach(function (error) {\n var errorMessage = error\n ? error.message\n : 'Error message not found.';\n message += \"\".concat(errorMessage, \"\\n\");\n });\n }\n if (err.networkError) {\n message += \"\".concat(err.networkError.message, \"\\n\");\n }\n message = message.replace(/\\n$/, '');\n return message;\n};\nvar ApolloError = (function (_super) {\n __extends(ApolloError, _super);\n function ApolloError(_a) {\n var graphQLErrors = _a.graphQLErrors, clientErrors = _a.clientErrors, networkError = _a.networkError, errorMessage = _a.errorMessage, extraInfo = _a.extraInfo;\n var _this = _super.call(this, errorMessage) || this;\n _this.name = 'ApolloError';\n _this.graphQLErrors = graphQLErrors || [];\n _this.clientErrors = clientErrors || [];\n _this.networkError = networkError || null;\n _this.message = errorMessage || generateErrorMessage(_this);\n _this.extraInfo = extraInfo;\n _this.__proto__ = ApolloError.prototype;\n return _this;\n }\n return ApolloError;\n}(Error));\nexport { ApolloError };\n//# sourceMappingURL=index.js.map"],"names":["isNonEmptyArray","__extends"],"mappings":";;;;;;;;AAGO,SAAS,aAAa,CAAC,GAAG,EAAE;AACnC,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E,CAAC,YAAY,EAAE,SAAS,GAAG,EAAE,CAAC,SAAS,CAAC;AACvK,QAAQ,IAAI,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,IAAI,IAAI,CAAC;AAC5D,QAAQ,KAAK,CAAC,IAAI,GAAG,aAAa,CAAC;AACnC,QAAQ,KAAK,CAAC,aAAa,GAAG,aAAa,IAAI,EAAE,CAAC;AAClD,QAAQ,KAAK,CAAC,YAAY,GAAG,YAAY,IAAI,EAAE,CAAC;AAChD,QAAQ,KAAK,CAAC,YAAY,GAAG,YAAY,IAAI,IAAI,CAAC;AAClD,QAAQ,KAAK,CAAC,OAAO,GAAG,YAAY,IAAI,oBAAoB,CAAC,KAAK,CAAC,CAAC;AACpE,QAAQ,KAAK,CAAC,SAAS,GAAG,SAAS,CAAC;AACpC,QAAQ,KAAK,CAAC,SAAS,GAAG,WAAW,CAAC,SAAS,CAAC;AAChD,QAAQ,OAAO,KAAK,CAAC;AACrB,KAAK;AACL,IAAI,OAAO,WAAW,CAAC;AACvB,CAAC,CAAC,KAAK,CAAC;;;;;"}
@@ -32,6 +32,7 @@ var ApolloError = (function (_super) {
32
32
  function ApolloError(_a) {
33
33
  var graphQLErrors = _a.graphQLErrors, clientErrors = _a.clientErrors, networkError = _a.networkError, errorMessage = _a.errorMessage, extraInfo = _a.extraInfo;
34
34
  var _this = _super.call(this, errorMessage) || this;
35
+ _this.name = 'ApolloError';
35
36
  _this.graphQLErrors = graphQLErrors || [];
36
37
  _this.clientErrors = clientErrors || [];
37
38
  _this.networkError = networkError || null;
package/errors/index.d.ts CHANGED
@@ -6,6 +6,7 @@ export declare function isApolloError(err: Error): err is ApolloError;
6
6
  export declare type GraphQLErrors = ReadonlyArray<GraphQLError>;
7
7
  export declare type NetworkError = Error | ServerParseError | ServerError | null;
8
8
  export declare class ApolloError extends Error {
9
+ name: string;
9
10
  message: string;
10
11
  graphQLErrors: GraphQLErrors;
11
12
  clientErrors: ReadonlyArray<Error>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,wBAAgB,aAAa,CAAC,GAAG,EAAE,KAAK,GAAG,GAAG,IAAI,WAAW,CAE5D;AA6BD,oBAAY,aAAa,GAAG,aAAa,CAAC,YAAY,CAAC,CAAC;AAExD,oBAAY,YAAY,GAAG,KAAK,GAAG,gBAAgB,GAAG,WAAW,GAAG,IAAI,CAAC;AAEzE,qBAAa,WAAY,SAAQ,KAAK;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,aAAa,CAAC;IAC7B,YAAY,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;IACnC,YAAY,EAAE,KAAK,GAAG,gBAAgB,GAAG,WAAW,GAAG,IAAI,CAAC;IAK5D,SAAS,EAAE,GAAG,CAAC;gBAKV,EACV,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,SAAS,GACV,EAAE;QACD,aAAa,CAAC,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;QAC5C,YAAY,CAAC,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;QACpC,YAAY,CAAC,EAAE,KAAK,GAAG,gBAAgB,GAAG,WAAW,GAAG,IAAI,CAAC;QAC7D,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,SAAS,CAAC,EAAE,GAAG,CAAC;KACjB;CAYF"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,wBAAgB,aAAa,CAAC,GAAG,EAAE,KAAK,GAAG,GAAG,IAAI,WAAW,CAE5D;AA6BD,oBAAY,aAAa,GAAG,aAAa,CAAC,YAAY,CAAC,CAAC;AAExD,oBAAY,YAAY,GAAG,KAAK,GAAG,gBAAgB,GAAG,WAAW,GAAG,IAAI,CAAC;AAEzE,qBAAa,WAAY,SAAQ,KAAK;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,aAAa,CAAC;IAC7B,YAAY,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;IACnC,YAAY,EAAE,KAAK,GAAG,gBAAgB,GAAG,WAAW,GAAG,IAAI,CAAC;IAK5D,SAAS,EAAE,GAAG,CAAC;gBAKV,EACV,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,SAAS,GACV,EAAE;QACD,aAAa,CAAC,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;QAC5C,YAAY,CAAC,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;QACpC,YAAY,CAAC,EAAE,KAAK,GAAG,gBAAgB,GAAG,WAAW,GAAG,IAAI,CAAC;QAC7D,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,SAAS,CAAC,EAAE,GAAG,CAAC;KACjB;CAaF"}
package/errors/index.js CHANGED
@@ -27,6 +27,7 @@ var ApolloError = (function (_super) {
27
27
  function ApolloError(_a) {
28
28
  var graphQLErrors = _a.graphQLErrors, clientErrors = _a.clientErrors, networkError = _a.networkError, errorMessage = _a.errorMessage, extraInfo = _a.extraInfo;
29
29
  var _this = _super.call(this, errorMessage) || this;
30
+ _this.name = 'ApolloError';
30
31
  _this.graphQLErrors = graphQLErrors || [];
31
32
  _this.clientErrors = clientErrors || [];
32
33
  _this.networkError = networkError || null;
@@ -1 +1 @@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,YAAY,GAAG,YAAY,IAAI,EAAE,CAAC;QACvC,KAAI,CAAC,YAAY,GAAG,YAAY,IAAI,IAAI,CAAC;QACzC,KAAI,CAAC,OAAO,GAAG,YAAY,IAAI,oBAAoB,CAAC,KAAI,CAAC,CAAC;QAC1D,KAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAI1B,KAAY,CAAC,SAAS,GAAG,WAAW,CAAC,SAAS,CAAC;;IAClD,CAAC;IACH,kBAAC;AAAD,CAAC,AAtCD,CAAiC,KAAK,GAsCrC","sourcesContent":["import '../utilities/globals';\n\nimport { GraphQLError } from 'graphql';\n\nimport { isNonEmptyArray } from '../utilities';\nimport { ServerParseError } from '../link/http';\nimport { ServerError } from '../link/utils';\n\nexport function isApolloError(err: Error): err is ApolloError {\n return err.hasOwnProperty('graphQLErrors');\n}\n\n// Sets the error message on this error according to the\n// the GraphQL and network errors that are present.\n// If the error message has already been set through the\n// constructor or otherwise, this function is a nop.\nconst generateErrorMessage = (err: ApolloError) => {\n let message = '';\n // If we have GraphQL errors present, add that to the error message.\n if (isNonEmptyArray(err.graphQLErrors) || isNonEmptyArray(err.clientErrors)) {\n const errors = ((err.graphQLErrors || []) as readonly Error[])\n .concat(err.clientErrors || []);\n errors.forEach((error: Error) => {\n const errorMessage = error\n ? error.message\n : 'Error message not found.';\n message += `${errorMessage}\\n`;\n });\n }\n\n if (err.networkError) {\n message += `${err.networkError.message}\\n`;\n }\n\n // strip newline from the end of the message\n message = message.replace(/\\n$/, '');\n return message;\n};\n\nexport type GraphQLErrors = ReadonlyArray<GraphQLError>;\n\nexport type NetworkError = Error | ServerParseError | ServerError | null;\n\nexport class ApolloError extends Error {\n public message: string;\n public graphQLErrors: GraphQLErrors;\n public clientErrors: ReadonlyArray<Error>;\n public networkError: Error | ServerParseError | ServerError | null;\n\n // An object that can be used to provide some additional information\n // about an error, e.g. specifying the type of error this is. Used\n // internally within Apollo Client.\n public extraInfo: any;\n\n // Constructs an instance of ApolloError given a GraphQLError\n // or a network error. Note that one of these has to be a valid\n // value or the constructed error will be meaningless.\n constructor({\n graphQLErrors,\n clientErrors,\n networkError,\n errorMessage,\n extraInfo,\n }: {\n graphQLErrors?: ReadonlyArray<GraphQLError>;\n clientErrors?: ReadonlyArray<Error>;\n networkError?: Error | ServerParseError | ServerError | null;\n errorMessage?: string;\n extraInfo?: any;\n }) {\n super(errorMessage);\n this.graphQLErrors = graphQLErrors || [];\n this.clientErrors = clientErrors || [];\n this.networkError = networkError || null;\n this.message = errorMessage || generateErrorMessage(this);\n this.extraInfo = extraInfo;\n\n // We're not using `Object.setPrototypeOf` here as it isn't fully\n // supported on Android (see issue #3236).\n (this as any).__proto__ = ApolloError.prototype;\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":";AAAA,OAAO,sBAAsB,CAAC;AAI9B,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAI/C,MAAM,UAAU,aAAa,CAAC,GAAU;IACtC,OAAO,GAAG,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC;AAC7C,CAAC;AAMD,IAAM,oBAAoB,GAAG,UAAC,GAAgB;IAC5C,IAAI,OAAO,GAAG,EAAE,CAAC;IAEjB,IAAI,eAAe,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,eAAe,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE;QAC3E,IAAM,MAAM,GAAI,CAAC,GAAG,CAAC,aAAa,IAAI,EAAE,CAAsB;aAC3D,MAAM,CAAC,GAAG,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC;QAClC,MAAM,CAAC,OAAO,CAAC,UAAC,KAAY;YAC1B,IAAM,YAAY,GAAG,KAAK;gBACxB,CAAC,CAAC,KAAK,CAAC,OAAO;gBACf,CAAC,CAAC,0BAA0B,CAAC;YAC/B,OAAO,IAAI,UAAG,YAAY,OAAI,CAAC;QACjC,CAAC,CAAC,CAAC;KACJ;IAED,IAAI,GAAG,CAAC,YAAY,EAAE;QACpB,OAAO,IAAI,UAAG,GAAG,CAAC,YAAY,CAAC,OAAO,OAAI,CAAC;KAC5C;IAGD,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACrC,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAMF;IAAiC,+BAAK;IAepC,qBAAY,EAYX;YAXC,aAAa,mBAAA,EACb,YAAY,kBAAA,EACZ,YAAY,kBAAA,EACZ,YAAY,kBAAA,EACZ,SAAS,eAAA;QALX,YAaE,kBAAM,YAAY,CAAC,SAWpB;QAVC,KAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,KAAI,CAAC,aAAa,GAAG,aAAa,IAAI,EAAE,CAAC;QACzC,KAAI,CAAC,YAAY,GAAG,YAAY,IAAI,EAAE,CAAC;QACvC,KAAI,CAAC,YAAY,GAAG,YAAY,IAAI,IAAI,CAAC;QACzC,KAAI,CAAC,OAAO,GAAG,YAAY,IAAI,oBAAoB,CAAC,KAAI,CAAC,CAAC;QAC1D,KAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAI1B,KAAY,CAAC,SAAS,GAAG,WAAW,CAAC,SAAS,CAAC;;IAClD,CAAC;IACH,kBAAC;AAAD,CAAC,AAxCD,CAAiC,KAAK,GAwCrC","sourcesContent":["import '../utilities/globals';\n\nimport { GraphQLError } from 'graphql';\n\nimport { isNonEmptyArray } from '../utilities';\nimport { ServerParseError } from '../link/http';\nimport { ServerError } from '../link/utils';\n\nexport function isApolloError(err: Error): err is ApolloError {\n return err.hasOwnProperty('graphQLErrors');\n}\n\n// Sets the error message on this error according to the\n// the GraphQL and network errors that are present.\n// If the error message has already been set through the\n// constructor or otherwise, this function is a nop.\nconst generateErrorMessage = (err: ApolloError) => {\n let message = '';\n // If we have GraphQL errors present, add that to the error message.\n if (isNonEmptyArray(err.graphQLErrors) || isNonEmptyArray(err.clientErrors)) {\n const errors = ((err.graphQLErrors || []) as readonly Error[])\n .concat(err.clientErrors || []);\n errors.forEach((error: Error) => {\n const errorMessage = error\n ? error.message\n : 'Error message not found.';\n message += `${errorMessage}\\n`;\n });\n }\n\n if (err.networkError) {\n message += `${err.networkError.message}\\n`;\n }\n\n // strip newline from the end of the message\n message = message.replace(/\\n$/, '');\n return message;\n};\n\nexport type GraphQLErrors = ReadonlyArray<GraphQLError>;\n\nexport type NetworkError = Error | ServerParseError | ServerError | null;\n\nexport class ApolloError extends Error {\n public name: string;\n public message: string;\n public graphQLErrors: GraphQLErrors;\n public clientErrors: ReadonlyArray<Error>;\n public networkError: Error | ServerParseError | ServerError | null;\n\n // An object that can be used to provide some additional information\n // about an error, e.g. specifying the type of error this is. Used\n // internally within Apollo Client.\n public extraInfo: any;\n\n // Constructs an instance of ApolloError given a GraphQLError\n // or a network error. Note that one of these has to be a valid\n // value or the constructed error will be meaningless.\n constructor({\n graphQLErrors,\n clientErrors,\n networkError,\n errorMessage,\n extraInfo,\n }: {\n graphQLErrors?: ReadonlyArray<GraphQLError>;\n clientErrors?: ReadonlyArray<Error>;\n networkError?: Error | ServerParseError | ServerError | null;\n errorMessage?: string;\n extraInfo?: any;\n }) {\n super(errorMessage);\n this.name = 'ApolloError';\n this.graphQLErrors = graphQLErrors || [];\n this.clientErrors = clientErrors || [];\n this.networkError = networkError || null;\n this.message = errorMessage || generateErrorMessage(this);\n this.extraInfo = extraInfo;\n\n // We're not using `Object.setPrototypeOf` here as it isn't fully\n // supported on Android (see issue #3236).\n (this as any).__proto__ = ApolloError.prototype;\n }\n}\n"]}
@@ -5,7 +5,7 @@
5
5
  // consult the @apollo/client/invariantErrorCodes.js file specific to
6
6
  // your @apollo/client version. This file is not meant to be imported.
7
7
  {
8
- "@apollo/client version": "3.7.1",
8
+ "@apollo/client version": "3.7.2",
9
9
 
10
10
  1: {
11
11
  file: "@apollo/client/cache/inmemory/entityStore.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apollo/client",
3
- "version": "3.7.1",
3
+ "version": "3.7.2",
4
4
  "description": "A fully-featured caching GraphQL client.",
5
5
  "private": false,
6
6
  "keywords": [
@@ -66,8 +66,8 @@
66
66
  "zen-observable-ts": "^1.2.5"
67
67
  },
68
68
  "devDependencies": {
69
- "@babel/parser": "7.19.4",
70
- "@graphql-tools/schema": "9.0.4",
69
+ "@babel/parser": "7.20.5",
70
+ "@graphql-tools/schema": "9.0.10",
71
71
  "@rollup/plugin-node-resolve": "11.2.1",
72
72
  "@testing-library/react": "13.4.0",
73
73
  "@testing-library/react-12": "npm:@testing-library/react@^12",
@@ -78,14 +78,14 @@
78
78
  "@types/fetch-mock": "7.3.5",
79
79
  "@types/glob": "8.0.0",
80
80
  "@types/hoist-non-react-statics": "3.3.1",
81
- "@types/jest": "29.1.2",
82
- "@types/lodash": "4.14.186",
83
- "@types/node": "16.11.66",
81
+ "@types/jest": "29.2.3",
82
+ "@types/lodash": "4.14.191",
83
+ "@types/node": "16.18.4",
84
84
  "@types/node-fetch": "2.6.2",
85
- "@types/react": "18.0.21",
86
- "@types/react-dom": "18.0.6",
85
+ "@types/react": "18.0.26",
86
+ "@types/react-dom": "18.0.9",
87
87
  "@types/use-sync-external-store": "0.0.3",
88
- "acorn": "8.8.0",
88
+ "acorn": "8.8.1",
89
89
  "blob-polyfill": "7.0.20220408",
90
90
  "bytes": "3.1.2",
91
91
  "cross-fetch": "3.1.5",
@@ -93,8 +93,8 @@
93
93
  "glob": "8.0.3",
94
94
  "graphql": "16.6.0",
95
95
  "graphql-ws": "5.11.2",
96
- "jest": "29.2.0",
97
- "jest-environment-jsdom": "29.2.0",
96
+ "jest": "29.3.1",
97
+ "jest-environment-jsdom": "29.3.1",
98
98
  "jest-junit": "14.0.1",
99
99
  "lodash": "4.17.21",
100
100
  "react": "18.2.0",
@@ -106,9 +106,9 @@
106
106
  "rimraf": "3.0.2",
107
107
  "rollup": "2.79.1",
108
108
  "rollup-plugin-terser": "7.0.2",
109
- "rxjs": "7.5.7",
109
+ "rxjs": "7.6.0",
110
110
  "subscriptions-transport-ws": "0.11.0",
111
- "terser": "5.15.1",
111
+ "terser": "5.16.1",
112
112
  "ts-jest": "29.0.3",
113
113
  "ts-node": "10.9.1",
114
114
  "typedoc": "0.22.18",
@@ -2,5 +2,5 @@ import { DocumentNode } from 'graphql';
2
2
  import { TypedDocumentNode } from '@graphql-typed-document-node/core';
3
3
  import { MutationHookOptions, MutationTuple } from '../types/types';
4
4
  import { ApolloCache, DefaultContext, OperationVariables } from '../../core';
5
- export declare function useMutation<TData = any, TVariables = OperationVariables, TContext = DefaultContext, TCache extends ApolloCache<any> = ApolloCache<any>>(mutation: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: MutationHookOptions<TData, TVariables, TContext>): MutationTuple<TData, TVariables, TContext, TCache>;
5
+ export declare function useMutation<TData = any, TVariables = OperationVariables, TContext = DefaultContext, TCache extends ApolloCache<any> = ApolloCache<any>>(mutation: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: MutationHookOptions<TData, TVariables, TContext, TCache>): MutationTuple<TData, TVariables, TContext, TCache>;
6
6
  //# sourceMappingURL=useMutation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useMutation.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useMutation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAEL,mBAAmB,EAEnB,aAAa,EACd,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,WAAW,EACX,cAAc,EAEd,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAMpB,wBAAgB,WAAW,CACzB,KAAK,GAAG,GAAG,EACX,UAAU,GAAG,kBAAkB,EAC/B,QAAQ,GAAG,cAAc,EACzB,MAAM,SAAS,WAAW,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,EAElD,QAAQ,EAAE,YAAY,GAAG,iBAAiB,CAAC,KAAK,EAAE,UAAU,CAAC,EAC7D,OAAO,CAAC,EAAE,mBAAmB,CAAC,KAAK,EAAE,UAAU,EAAE,QAAQ,CAAC,GACzD,aAAa,CAAC,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC,CAwHpD"}
1
+ {"version":3,"file":"useMutation.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useMutation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAEL,mBAAmB,EAEnB,aAAa,EACd,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,WAAW,EACX,cAAc,EAEd,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAMpB,wBAAgB,WAAW,CACzB,KAAK,GAAG,GAAG,EACX,UAAU,GAAG,kBAAkB,EAC/B,QAAQ,GAAG,cAAc,EACzB,MAAM,SAAS,WAAW,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,EAElD,QAAQ,EAAE,YAAY,GAAG,iBAAiB,CAAC,KAAK,EAAE,UAAU,CAAC,EAC7D,OAAO,CAAC,EAAE,mBAAmB,CAAC,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC,GACjE,aAAa,CAAC,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC,CAwHpD"}
@@ -1 +1 @@
1
- {"version":3,"file":"useMutation.js","sourceRoot":"","sources":["../../../src/react/hooks/useMutation.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAUjE,OAAO,EAGL,YAAY,GAEb,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE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AI,CAAC;QAE7B,OAAO;YACL,GAAG,CAAC,OAAO,CAAC,SAAS,GAAG,KAAK,CAAC;QAChC,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CAAC,OAAO,aAAI,KAAK,OAAA,IAAK,MAAM,EAAG,CAAC;AACzC,CAAC","sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\nimport { DocumentNode } from 'graphql';\nimport { TypedDocumentNode } from '@graphql-typed-document-node/core';\nimport {\n MutationFunctionOptions,\n MutationHookOptions,\n MutationResult,\n MutationTuple,\n} from '../types/types';\n\nimport {\n ApolloCache,\n DefaultContext,\n mergeOptions,\n OperationVariables,\n} from '../../core';\nimport { equal } from '@wry/equality';\nimport { DocumentType, verifyDocumentType } from '../parser';\nimport { ApolloError } from '../../errors';\nimport { useApolloClient } from './useApolloClient';\n\nexport function useMutation<\n TData = any,\n TVariables = OperationVariables,\n TContext = DefaultContext,\n TCache extends ApolloCache<any> = ApolloCache<any>,\n>(\n mutation: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options?: MutationHookOptions<TData, TVariables, TContext>,\n): MutationTuple<TData, TVariables, TContext, TCache> {\n const client = useApolloClient(options?.client);\n verifyDocumentType(mutation, DocumentType.Mutation);\n const [result, setResult] = useState<Omit<MutationResult, 'reset'>>({\n called: false,\n loading: false,\n client,\n });\n\n const ref = useRef({\n result,\n mutationId: 0,\n isMounted: true,\n client,\n mutation,\n options,\n });\n\n // TODO: Trying to assign these in a useEffect or useLayoutEffect breaks\n // higher-order components.\n {\n Object.assign(ref.current, { client, options, mutation });\n }\n\n const execute = useCallback((\n executeOptions: MutationFunctionOptions<\n TData,\n TVariables,\n TContext,\n TCache\n > = {}\n ) => {\n const {client, options, mutation} = ref.current;\n const baseOptions = { ...options, mutation };\n if (!ref.current.result.loading && !baseOptions.ignoreResults && ref.current.isMounted) {\n setResult(ref.current.result = {\n loading: true,\n error: void 0,\n data: void 0,\n called: true,\n client,\n });\n }\n\n const mutationId = ++ref.current.mutationId;\n const clientOptions = mergeOptions(\n baseOptions,\n executeOptions as any,\n );\n\n return client.mutate(clientOptions).then((response) => {\n const { data, errors } = response;\n const error =\n errors && errors.length > 0\n ? new ApolloError({ graphQLErrors: errors })\n : void 0;\n\n if (\n mutationId === ref.current.mutationId &&\n !clientOptions.ignoreResults\n ) {\n const result = {\n called: true,\n loading: false,\n data,\n error,\n client,\n };\n\n if (ref.current.isMounted && !equal(ref.current.result, result)) {\n setResult(ref.current.result = result);\n }\n }\n ref.current.options?.onCompleted?.(response.data!, clientOptions);\n executeOptions.onCompleted?.(response.data!, clientOptions);\n return response;\n }).catch((error) => {\n if (\n mutationId === ref.current.mutationId &&\n ref.current.isMounted\n ) {\n const result = {\n loading: false,\n error,\n data: void 0,\n called: true,\n client,\n };\n\n if (!equal(ref.current.result, result)) {\n setResult(ref.current.result = result);\n }\n }\n\n if (ref.current.options?.onError || clientOptions.onError) {\n ref.current.options?.onError?.(error, clientOptions);\n executeOptions.onError?.(error, clientOptions);\n // TODO(brian): why are we returning this here???\n return { data: void 0, errors: error };\n }\n\n throw error;\n });\n }, []);\n\n const reset = useCallback(() => {\n if (ref.current.isMounted) {\n setResult({ called: false, loading: false, client });\n }\n }, []);\n\n useEffect(() => {\n ref.current.isMounted = true;\n\n return () => {\n ref.current.isMounted = false;\n };\n }, []);\n\n return [execute, { reset, ...result }];\n}\n"]}
1
+ {"version":3,"file":"useMutation.js","sourceRoot":"","sources":["../../../src/react/hooks/useMutation.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAUjE,OAAO,EAGL,YAAY,GAEb,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM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AAC;QAChC,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CAAC,OAAO,aAAI,KAAK,OAAA,IAAK,MAAM,EAAG,CAAC;AACzC,CAAC","sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\nimport { DocumentNode } from 'graphql';\nimport { TypedDocumentNode } from '@graphql-typed-document-node/core';\nimport {\n MutationFunctionOptions,\n MutationHookOptions,\n MutationResult,\n MutationTuple,\n} from '../types/types';\n\nimport {\n ApolloCache,\n DefaultContext,\n mergeOptions,\n OperationVariables,\n} from '../../core';\nimport { equal } from '@wry/equality';\nimport { DocumentType, verifyDocumentType } from '../parser';\nimport { ApolloError } from '../../errors';\nimport { useApolloClient } from './useApolloClient';\n\nexport function useMutation<\n TData = any,\n TVariables = OperationVariables,\n TContext = DefaultContext,\n TCache extends ApolloCache<any> = ApolloCache<any>,\n>(\n mutation: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options?: MutationHookOptions<TData, TVariables, TContext, TCache>,\n): MutationTuple<TData, TVariables, TContext, TCache> {\n const client = useApolloClient(options?.client);\n verifyDocumentType(mutation, DocumentType.Mutation);\n const [result, setResult] = useState<Omit<MutationResult, 'reset'>>({\n called: false,\n loading: false,\n client,\n });\n\n const ref = useRef({\n result,\n mutationId: 0,\n isMounted: true,\n client,\n mutation,\n options,\n });\n\n // TODO: Trying to assign these in a useEffect or useLayoutEffect breaks\n // higher-order components.\n {\n Object.assign(ref.current, { client, options, mutation });\n }\n\n const execute = useCallback((\n executeOptions: MutationFunctionOptions<\n TData,\n TVariables,\n TContext,\n TCache\n > = {}\n ) => {\n const {client, options, mutation} = ref.current;\n const baseOptions = { ...options, mutation };\n if (!ref.current.result.loading && !baseOptions.ignoreResults && ref.current.isMounted) {\n setResult(ref.current.result = {\n loading: true,\n error: void 0,\n data: void 0,\n called: true,\n client,\n });\n }\n\n const mutationId = ++ref.current.mutationId;\n const clientOptions = mergeOptions(\n baseOptions,\n executeOptions as any,\n );\n\n return client.mutate(clientOptions).then((response) => {\n const { data, errors } = response;\n const error =\n errors && errors.length > 0\n ? new ApolloError({ graphQLErrors: errors })\n : void 0;\n\n if (\n mutationId === ref.current.mutationId &&\n !clientOptions.ignoreResults\n ) {\n const result = {\n called: true,\n loading: false,\n data,\n error,\n client,\n };\n\n if (ref.current.isMounted && !equal(ref.current.result, result)) {\n setResult(ref.current.result = result);\n }\n }\n ref.current.options?.onCompleted?.(response.data!, clientOptions);\n executeOptions.onCompleted?.(response.data!, clientOptions);\n return response;\n }).catch((error) => {\n if (\n mutationId === ref.current.mutationId &&\n ref.current.isMounted\n ) {\n const result = {\n loading: false,\n error,\n data: void 0,\n called: true,\n client,\n };\n\n if (!equal(ref.current.result, result)) {\n setResult(ref.current.result = result);\n }\n }\n\n if (ref.current.options?.onError || clientOptions.onError) {\n ref.current.options?.onError?.(error, clientOptions);\n executeOptions.onError?.(error, clientOptions);\n // TODO(brian): why are we returning this here???\n return { data: void 0, errors: error };\n }\n\n throw error;\n });\n }, []);\n\n const reset = useCallback(() => {\n if (ref.current.isMounted) {\n setResult({ called: false, loading: false, client });\n }\n }, []);\n\n useEffect(() => {\n ref.current.isMounted = true;\n\n return () => {\n ref.current.isMounted = false;\n };\n }, []);\n\n return [execute, { reset, ...result }];\n}\n"]}
package/version.js CHANGED
@@ -1,2 +1,2 @@
1
- export var version = '3.7.1';
1
+ export var version = '3.7.2';
2
2
  //# sourceMappingURL=version.js.map