@apollo/client 4.0.5 → 4.0.7

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.
@@ -71,7 +71,8 @@ export class GraphQLWsLink extends ApolloLink {
71
71
  }
72
72
  request(operation) {
73
73
  return new Observable((observer) => {
74
- return this.client.subscribe({ ...operation, query: print(operation.query) }, {
74
+ const { query, variables, operationName, extensions } = operation;
75
+ return this.client.subscribe({ variables, operationName, extensions, query: print(query) }, {
75
76
  next: observer.next.bind(observer),
76
77
  complete: observer.complete.bind(observer),
77
78
  error: (err) => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/link/subscriptions/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,0CAA0C;AAC1C,EAAE;AACF,+EAA+E;AAC/E,0CAA0C;AAC1C,EAAE;AACF,2CAA2C;AAC3C,EAAE;AACF,wBAAwB;AACxB,EAAE;AACF,yCAAyC;AACzC,EAAE;AACF,+EAA+E;AAC/E,gFAAgF;AAChF,+EAA+E;AAC/E,4EAA4E;AAC5E,wEAAwE;AACxE,2DAA2D;AAC3D,EAAE;AACF,6EAA6E;AAC7E,sDAAsD;AACtD,EAAE;AACF,6EAA6E;AAC7E,2EAA2E;AAC3E,8EAA8E;AAC9E,yEAAyE;AACzE,gFAAgF;AAChF,4EAA4E;AAC5E,gBAAgB;AAIhB,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAEpE,yEAAyE;AACzE,SAAS,gBAAgB,CAAC,GAAY;IACpC,OAAO,eAAe,CAAC,GAAG,CAAC,IAAI,MAAM,IAAI,GAAG,IAAI,QAAQ,IAAI,GAAG,CAAC;AAClE,CAAC;AAED,yEAAyE;AACzE,SAAS,gBAAgB,CAAC,GAAY;IACpC,OAAO,eAAe,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,MAAM,EAAE,UAAU,KAAK,SAAS,CAAC,MAAM,CAAC;AAC7E,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,OAAO,aAAc,SAAQ,UAAU;IACf;IAA5B,YAA4B,MAAc;QACxC,KAAK,EAAE,CAAC;QADkB,WAAM,GAAN,MAAM,CAAQ;IAE1C,CAAC;IAEM,OAAO,CACZ,SAA+B;QAE/B,OAAO,IAAI,UAAU,CAAC,CAAC,QAAQ,EAAE,EAAE;YACjC,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAC1B,EAAE,GAAG,SAAS,EAAE,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,EAC/C;gBACE,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;gBAClC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC;gBAC1C,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE;oBACb,IAAI,GAAG,YAAY,KAAK,EAAE,CAAC;wBACzB,OAAO,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;oBAC7B,CAAC;oBACD,MAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;oBACxC,IAAI,SAAS,IAAI,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAC;wBACvC,OAAO,QAAQ,CAAC,KAAK;wBACnB,2CAA2C;wBAC3C,IAAI,KAAK,CACP,gBAAgB,SAAS,CAAC,CAAC,CAAC,eAAe,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,GACxD,SAAS,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EACjC,EAAE,CACH,CACF,CAAC;oBACJ,CAAC;oBAED,OAAO,QAAQ,CAAC,KAAK,CACnB,IAAI,qBAAqB,CAAC;wBACxB,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;qBACzC,CAAC,CACH,CAAC;gBACJ,CAAC;gBACD,+FAA+F;aAChD,CAClD,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["// This file is adapted from the graphql-ws npm package:\n// https://github.com/enisdenjo/graphql-ws\n//\n// Most of the file comes from that package's README; some other parts (such as\n// isLikeCloseEvent) come from its source.\n//\n// Here's the license of the original code:\n//\n// The MIT License (MIT)\n//\n// Copyright (c) 2020-2021 Denis Badurina\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\nimport type { FormattedExecutionResult } from \"graphql\";\nimport type { Client, Sink } from \"graphql-ws\";\nimport { Observable } from \"rxjs\";\n\nimport { CombinedGraphQLErrors } from \"@apollo/client/errors\";\nimport { ApolloLink } from \"@apollo/client/link\";\nimport { print } from \"@apollo/client/utilities\";\nimport { isNonNullObject } from \"@apollo/client/utilities/internal\";\n\n// https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close_event\nfunction isLikeCloseEvent(val: unknown): val is CloseEvent {\n return isNonNullObject(val) && \"code\" in val && \"reason\" in val;\n}\n\n// https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/error_event\nfunction isLikeErrorEvent(err: unknown): err is Event {\n return isNonNullObject(err) && err.target?.readyState === WebSocket.CLOSED;\n}\n\n/**\n * The `GraphQLWsLink` is a terminating link sends GraphQL operations over a\n * WebSocket connection using the [`graphql-ws`](https://www.npmjs.com/package/graphql-ws) library. It's used most\n * commonly with GraphQL [subscriptions](https://apollographql.com/docs/react/data/subscriptions/),\n *\n * > [!NOTE]\n * > This link works with the `graphql-ws` library. If your server uses\n * > the deprecated `subscriptions-transport-ws` library, use the deprecated\n * > [`WebSocketLink`](https://apollographql.com/docs/react/api/link/apollo-link-ws) link instead.\n *\n * @example\n *\n * ```ts\n * import { GraphQLWsLink } from \"@apollo/client/link/subscriptions\";\n * import { createClient } from \"graphql-ws\";\n *\n * const link = new GraphQLWsLink(\n * createClient({\n * url: \"ws://localhost:3000/subscriptions\",\n * })\n * );\n * ```\n */\nexport class GraphQLWsLink extends ApolloLink {\n constructor(public readonly client: Client) {\n super();\n }\n\n public request(\n operation: ApolloLink.Operation\n ): Observable<ApolloLink.Result> {\n return new Observable((observer) => {\n return this.client.subscribe<ApolloLink.Result>(\n { ...operation, query: print(operation.query) },\n {\n next: observer.next.bind(observer),\n complete: observer.complete.bind(observer),\n error: (err) => {\n if (err instanceof Error) {\n return observer.error(err);\n }\n const likeClose = isLikeCloseEvent(err);\n if (likeClose || isLikeErrorEvent(err)) {\n return observer.error(\n // reason will be available on clean closes\n new Error(\n `Socket closed${likeClose ? ` with event ${err.code}` : \"\"}${\n likeClose ? ` ${err.reason}` : \"\"\n }`\n )\n );\n }\n\n return observer.error(\n new CombinedGraphQLErrors({\n errors: Array.isArray(err) ? err : [err],\n })\n );\n },\n // casting around a wrong type in graphql-ws, which incorrectly expects `Sink<ExecutionResult>`\n } satisfies Sink<FormattedExecutionResult> as any\n );\n });\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/link/subscriptions/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,0CAA0C;AAC1C,EAAE;AACF,+EAA+E;AAC/E,0CAA0C;AAC1C,EAAE;AACF,2CAA2C;AAC3C,EAAE;AACF,wBAAwB;AACxB,EAAE;AACF,yCAAyC;AACzC,EAAE;AACF,+EAA+E;AAC/E,gFAAgF;AAChF,+EAA+E;AAC/E,4EAA4E;AAC5E,wEAAwE;AACxE,2DAA2D;AAC3D,EAAE;AACF,6EAA6E;AAC7E,sDAAsD;AACtD,EAAE;AACF,6EAA6E;AAC7E,2EAA2E;AAC3E,8EAA8E;AAC9E,yEAAyE;AACzE,gFAAgF;AAChF,4EAA4E;AAC5E,gBAAgB;AAIhB,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAEpE,yEAAyE;AACzE,SAAS,gBAAgB,CAAC,GAAY;IACpC,OAAO,eAAe,CAAC,GAAG,CAAC,IAAI,MAAM,IAAI,GAAG,IAAI,QAAQ,IAAI,GAAG,CAAC;AAClE,CAAC;AAED,yEAAyE;AACzE,SAAS,gBAAgB,CAAC,GAAY;IACpC,OAAO,eAAe,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,MAAM,EAAE,UAAU,KAAK,SAAS,CAAC,MAAM,CAAC;AAC7E,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,OAAO,aAAc,SAAQ,UAAU;IACf;IAA5B,YAA4B,MAAc;QACxC,KAAK,EAAE,CAAC;QADkB,WAAM,GAAN,MAAM,CAAQ;IAE1C,CAAC;IAEM,OAAO,CACZ,SAA+B;QAE/B,OAAO,IAAI,UAAU,CAAC,CAAC,QAAQ,EAAE,EAAE;YACjC,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,SAAS,CAAC;YAClE,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAC1B,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,EAC7D;gBACE,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;gBAClC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC;gBAC1C,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE;oBACb,IAAI,GAAG,YAAY,KAAK,EAAE,CAAC;wBACzB,OAAO,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;oBAC7B,CAAC;oBACD,MAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;oBACxC,IAAI,SAAS,IAAI,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAC;wBACvC,OAAO,QAAQ,CAAC,KAAK;wBACnB,2CAA2C;wBAC3C,IAAI,KAAK,CACP,gBAAgB,SAAS,CAAC,CAAC,CAAC,eAAe,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,GACxD,SAAS,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EACjC,EAAE,CACH,CACF,CAAC;oBACJ,CAAC;oBAED,OAAO,QAAQ,CAAC,KAAK,CACnB,IAAI,qBAAqB,CAAC;wBACxB,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;qBACzC,CAAC,CACH,CAAC;gBACJ,CAAC;gBACD,+FAA+F;aAChD,CAClD,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["// This file is adapted from the graphql-ws npm package:\n// https://github.com/enisdenjo/graphql-ws\n//\n// Most of the file comes from that package's README; some other parts (such as\n// isLikeCloseEvent) come from its source.\n//\n// Here's the license of the original code:\n//\n// The MIT License (MIT)\n//\n// Copyright (c) 2020-2021 Denis Badurina\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\nimport type { FormattedExecutionResult } from \"graphql\";\nimport type { Client, Sink } from \"graphql-ws\";\nimport { Observable } from \"rxjs\";\n\nimport { CombinedGraphQLErrors } from \"@apollo/client/errors\";\nimport { ApolloLink } from \"@apollo/client/link\";\nimport { print } from \"@apollo/client/utilities\";\nimport { isNonNullObject } from \"@apollo/client/utilities/internal\";\n\n// https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close_event\nfunction isLikeCloseEvent(val: unknown): val is CloseEvent {\n return isNonNullObject(val) && \"code\" in val && \"reason\" in val;\n}\n\n// https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/error_event\nfunction isLikeErrorEvent(err: unknown): err is Event {\n return isNonNullObject(err) && err.target?.readyState === WebSocket.CLOSED;\n}\n\n/**\n * The `GraphQLWsLink` is a terminating link sends GraphQL operations over a\n * WebSocket connection using the [`graphql-ws`](https://www.npmjs.com/package/graphql-ws) library. It's used most\n * commonly with GraphQL [subscriptions](https://apollographql.com/docs/react/data/subscriptions/),\n *\n * > [!NOTE]\n * > This link works with the `graphql-ws` library. If your server uses\n * > the deprecated `subscriptions-transport-ws` library, use the deprecated\n * > [`WebSocketLink`](https://apollographql.com/docs/react/api/link/apollo-link-ws) link instead.\n *\n * @example\n *\n * ```ts\n * import { GraphQLWsLink } from \"@apollo/client/link/subscriptions\";\n * import { createClient } from \"graphql-ws\";\n *\n * const link = new GraphQLWsLink(\n * createClient({\n * url: \"ws://localhost:3000/subscriptions\",\n * })\n * );\n * ```\n */\nexport class GraphQLWsLink extends ApolloLink {\n constructor(public readonly client: Client) {\n super();\n }\n\n public request(\n operation: ApolloLink.Operation\n ): Observable<ApolloLink.Result> {\n return new Observable((observer) => {\n const { query, variables, operationName, extensions } = operation;\n return this.client.subscribe<ApolloLink.Result>(\n { variables, operationName, extensions, query: print(query) },\n {\n next: observer.next.bind(observer),\n complete: observer.complete.bind(observer),\n error: (err) => {\n if (err instanceof Error) {\n return observer.error(err);\n }\n const likeClose = isLikeCloseEvent(err);\n if (likeClose || isLikeErrorEvent(err)) {\n return observer.error(\n // reason will be available on clean closes\n new Error(\n `Socket closed${likeClose ? ` with event ${err.code}` : \"\"}${\n likeClose ? ` ${err.reason}` : \"\"\n }`\n )\n );\n }\n\n return observer.error(\n new CombinedGraphQLErrors({\n errors: Array.isArray(err) ? err : [err],\n })\n );\n },\n // casting around a wrong type in graphql-ws, which incorrectly expects `Sink<ExecutionResult>`\n } satisfies Sink<FormattedExecutionResult> as any\n );\n });\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apollo/client",
3
- "version": "4.0.5",
3
+ "version": "4.0.7",
4
4
  "description": "A fully-featured caching GraphQL client.",
5
5
  "private": false,
6
6
  "keywords": [
@@ -143,7 +143,9 @@ export declare namespace useMutation {
143
143
  }
144
144
  interface Result<TData = unknown> {
145
145
  /**
146
- * The data returned from your mutation. Can be `undefined` if `ignoreResults` is `true`.
146
+ * The data returned from your mutation. Can be `undefined` if the `errorPolicy`
147
+ * is `all` or `ignore` and the server returns a GraphQL response with `errors`
148
+ * but not `data` or a network error is returned.
147
149
  */
148
150
  data: MaybeMasked<TData> | null | undefined;
149
151
  /**
@@ -5,7 +5,8 @@ import type { ReactiveVar } from "@apollo/client";
5
5
  * @example
6
6
  *
7
7
  * ```jsx
8
- * import { makeVar, useReactiveVar } from "@apollo/client";
8
+ * import { makeVar } from "@apollo/client";
9
+ * import { useReactiveVar } from "@apollo/client/react";
9
10
  * export const cartItemsVar = makeVar([]);
10
11
  *
11
12
  * export function Cart() {
@@ -6,7 +6,8 @@ import { useSyncExternalStore } from "./useSyncExternalStore.js";
6
6
  * @example
7
7
  *
8
8
  * ```jsx
9
- * import { makeVar, useReactiveVar } from "@apollo/client";
9
+ * import { makeVar } from "@apollo/client";
10
+ * import { useReactiveVar } from "@apollo/client/react";
10
11
  * export const cartItemsVar = makeVar([]);
11
12
  *
12
13
  * export function Cart() {
@@ -1 +1 @@
1
- {"version":3,"file":"useReactiveVar.js","sourceRoot":"","sources":["../../../src/react/hooks/useReactiveVar.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,cAAc,CAAI,EAAkB;IAClD,OAAO,oBAAoB,CACzB,KAAK,CAAC,WAAW,CACf,CAAC,MAAM,EAAE,EAAE;QACT,4DAA4D;QAC5D,2EAA2E;QAC3E,0EAA0E;QAC1E,6DAA6D;QAC7D,sDAAsD;QACtD,OAAO,EAAE,CAAC,YAAY,CAAC,SAAS,MAAM;YACpC,MAAM,EAAE,CAAC;YACT,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;IACL,CAAC,EACD,CAAC,EAAE,CAAC,CACL,EACD,EAAE,EACF,EAAE,CACH,CAAC;AACJ,CAAC","sourcesContent":["import * as React from \"react\";\n\nimport type { ReactiveVar } from \"@apollo/client\";\n\nimport { useSyncExternalStore } from \"./useSyncExternalStore.js\";\n\n/**\n * Reads the value of a [reactive variable](https://www.apollographql.com/docs/react/local-state/reactive-variables/) and re-renders the containing component whenever that variable's value changes. This enables a reactive variable to trigger changes _without_ relying on the `useQuery` hook.\n *\n * @example\n *\n * ```jsx\n * import { makeVar, useReactiveVar } from \"@apollo/client\";\n * export const cartItemsVar = makeVar([]);\n *\n * export function Cart() {\n * const cartItems = useReactiveVar(cartItemsVar);\n * // ...\n * }\n * ```\n *\n * @param rv - A reactive variable.\n * @returns The current value of the reactive variable.\n */\nexport function useReactiveVar<T>(rv: ReactiveVar<T>): T {\n return useSyncExternalStore(\n React.useCallback(\n (update) => {\n // By reusing the same onNext function in the nested call to\n // rv.onNextChange(onNext), we can keep using the initial clean-up function\n // returned by rv.onNextChange(function onNext(v){...}), without having to\n // register the new clean-up function (returned by the nested\n // rv.onNextChange(onNext)) with yet another callback.\n return rv.onNextChange(function onNext() {\n update();\n rv.onNextChange(onNext);\n });\n },\n [rv]\n ),\n rv,\n rv\n );\n}\n"]}
1
+ {"version":3,"file":"useReactiveVar.js","sourceRoot":"","sources":["../../../src/react/hooks/useReactiveVar.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,cAAc,CAAI,EAAkB;IAClD,OAAO,oBAAoB,CACzB,KAAK,CAAC,WAAW,CACf,CAAC,MAAM,EAAE,EAAE;QACT,4DAA4D;QAC5D,2EAA2E;QAC3E,0EAA0E;QAC1E,6DAA6D;QAC7D,sDAAsD;QACtD,OAAO,EAAE,CAAC,YAAY,CAAC,SAAS,MAAM;YACpC,MAAM,EAAE,CAAC;YACT,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;IACL,CAAC,EACD,CAAC,EAAE,CAAC,CACL,EACD,EAAE,EACF,EAAE,CACH,CAAC;AACJ,CAAC","sourcesContent":["import * as React from \"react\";\n\nimport type { ReactiveVar } from \"@apollo/client\";\n\nimport { useSyncExternalStore } from \"./useSyncExternalStore.js\";\n\n/**\n * Reads the value of a [reactive variable](https://www.apollographql.com/docs/react/local-state/reactive-variables/) and re-renders the containing component whenever that variable's value changes. This enables a reactive variable to trigger changes _without_ relying on the `useQuery` hook.\n *\n * @example\n *\n * ```jsx\n * import { makeVar } from \"@apollo/client\";\n * import { useReactiveVar } from \"@apollo/client/react\";\n * export const cartItemsVar = makeVar([]);\n *\n * export function Cart() {\n * const cartItems = useReactiveVar(cartItemsVar);\n * // ...\n * }\n * ```\n *\n * @param rv - A reactive variable.\n * @returns The current value of the reactive variable.\n */\nexport function useReactiveVar<T>(rv: ReactiveVar<T>): T {\n return useSyncExternalStore(\n React.useCallback(\n (update) => {\n // By reusing the same onNext function in the nested call to\n // rv.onNextChange(onNext), we can keep using the initial clean-up function\n // returned by rv.onNextChange(function onNext(v){...}), without having to\n // register the new clean-up function (returned by the nested\n // rv.onNextChange(onNext)) with yet another callback.\n return rv.onNextChange(function onNext() {\n update();\n rv.onNextChange(onNext);\n });\n },\n [rv]\n ),\n rv,\n rv\n );\n}\n"]}
@@ -143,7 +143,9 @@ export declare namespace useMutation {
143
143
  }
144
144
  interface Result<TData = unknown> {
145
145
  /**
146
- * The data returned from your mutation. Can be `undefined` if `ignoreResults` is `true`.
146
+ * The data returned from your mutation. Can be `undefined` if the `errorPolicy`
147
+ * is `all` or `ignore` and the server returns a GraphQL response with `errors`
148
+ * but not `data` or a network error is returned.
147
149
  */
148
150
  data: MaybeMasked<TData> | null | undefined;
149
151
  /**
@@ -5,7 +5,8 @@ import type { ReactiveVar } from "@apollo/client";
5
5
  * @example
6
6
  *
7
7
  * ```jsx
8
- * import { makeVar, useReactiveVar } from "@apollo/client";
8
+ * import { makeVar } from "@apollo/client";
9
+ * import { useReactiveVar } from "@apollo/client/react";
9
10
  * export const cartItemsVar = makeVar([]);
10
11
  *
11
12
  * export function Cart() {
@@ -6,7 +6,8 @@ import { useSyncExternalStore } from "./useSyncExternalStore.js";
6
6
  * @example
7
7
  *
8
8
  * ```jsx
9
- * import { makeVar, useReactiveVar } from "@apollo/client";
9
+ * import { makeVar } from "@apollo/client";
10
+ * import { useReactiveVar } from "@apollo/client/react";
10
11
  * export const cartItemsVar = makeVar([]);
11
12
  *
12
13
  * export function Cart() {
@@ -1 +1 @@
1
- {"version":3,"file":"useReactiveVar.js","sourceRoot":"","sources":["../../../src/react/hooks/useReactiveVar.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,cAAc,CAAI,EAAkB;IAClD,OAAO,oBAAoB,CACzB,KAAK,CAAC,WAAW,CACf,CAAC,MAAM,EAAE,EAAE;QACT,4DAA4D;QAC5D,2EAA2E;QAC3E,0EAA0E;QAC1E,6DAA6D;QAC7D,sDAAsD;QACtD,OAAO,EAAE,CAAC,YAAY,CAAC,SAAS,MAAM;YACpC,MAAM,EAAE,CAAC;YACT,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;IACL,CAAC,EACD,CAAC,EAAE,CAAC,CACL,EACD,EAAE,EACF,EAAE,CACH,CAAC;AACJ,CAAC","sourcesContent":["import * as React from \"react\";\n\nimport type { ReactiveVar } from \"@apollo/client\";\n\nimport { useSyncExternalStore } from \"./useSyncExternalStore.js\";\n\n/**\n * Reads the value of a [reactive variable](https://www.apollographql.com/docs/react/local-state/reactive-variables/) and re-renders the containing component whenever that variable's value changes. This enables a reactive variable to trigger changes _without_ relying on the `useQuery` hook.\n *\n * @example\n *\n * ```jsx\n * import { makeVar, useReactiveVar } from \"@apollo/client\";\n * export const cartItemsVar = makeVar([]);\n *\n * export function Cart() {\n * const cartItems = useReactiveVar(cartItemsVar);\n * // ...\n * }\n * ```\n *\n * @param rv - A reactive variable.\n * @returns The current value of the reactive variable.\n */\nexport function useReactiveVar<T>(rv: ReactiveVar<T>): T {\n return useSyncExternalStore(\n React.useCallback(\n (update) => {\n // By reusing the same onNext function in the nested call to\n // rv.onNextChange(onNext), we can keep using the initial clean-up function\n // returned by rv.onNextChange(function onNext(v){...}), without having to\n // register the new clean-up function (returned by the nested\n // rv.onNextChange(onNext)) with yet another callback.\n return rv.onNextChange(function onNext() {\n update();\n rv.onNextChange(onNext);\n });\n },\n [rv]\n ),\n rv,\n rv\n );\n}\n"]}
1
+ {"version":3,"file":"useReactiveVar.js","sourceRoot":"","sources":["../../../src/react/hooks/useReactiveVar.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,cAAc,CAAI,EAAkB;IAClD,OAAO,oBAAoB,CACzB,KAAK,CAAC,WAAW,CACf,CAAC,MAAM,EAAE,EAAE;QACT,4DAA4D;QAC5D,2EAA2E;QAC3E,0EAA0E;QAC1E,6DAA6D;QAC7D,sDAAsD;QACtD,OAAO,EAAE,CAAC,YAAY,CAAC,SAAS,MAAM;YACpC,MAAM,EAAE,CAAC;YACT,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;IACL,CAAC,EACD,CAAC,EAAE,CAAC,CACL,EACD,EAAE,EACF,EAAE,CACH,CAAC;AACJ,CAAC","sourcesContent":["import * as React from \"react\";\n\nimport type { ReactiveVar } from \"@apollo/client\";\n\nimport { useSyncExternalStore } from \"./useSyncExternalStore.js\";\n\n/**\n * Reads the value of a [reactive variable](https://www.apollographql.com/docs/react/local-state/reactive-variables/) and re-renders the containing component whenever that variable's value changes. This enables a reactive variable to trigger changes _without_ relying on the `useQuery` hook.\n *\n * @example\n *\n * ```jsx\n * import { makeVar } from \"@apollo/client\";\n * import { useReactiveVar } from \"@apollo/client/react\";\n * export const cartItemsVar = makeVar([]);\n *\n * export function Cart() {\n * const cartItems = useReactiveVar(cartItemsVar);\n * // ...\n * }\n * ```\n *\n * @param rv - A reactive variable.\n * @returns The current value of the reactive variable.\n */\nexport function useReactiveVar<T>(rv: ReactiveVar<T>): T {\n return useSyncExternalStore(\n React.useCallback(\n (update) => {\n // By reusing the same onNext function in the nested call to\n // rv.onNextChange(onNext), we can keep using the initial clean-up function\n // returned by rv.onNextChange(function onNext(v){...}), without having to\n // register the new clean-up function (returned by the nested\n // rv.onNextChange(onNext)) with yet another callback.\n return rv.onNextChange(function onNext() {\n update();\n rv.onNextChange(onNext);\n });\n },\n [rv]\n ),\n rv,\n rv\n );\n}\n"]}
@@ -422,24 +422,12 @@ export interface MutationOptionsDocumentation {
422
422
  * @docGroup 1. Operation options
423
423
  */
424
424
  onError: unknown;
425
- /**
426
- * If `true`:
427
- *
428
- * - The initial state update (setting loading to true) is skipped
429
- * - The success state update (setting data and setting loading to false) is skipped
430
- * - Error updates will still occur
431
- *
432
- * The default value is `false`.
433
- *
434
- * This option is useful when you want to execute a mutation but don't need to track its progress or result in the UI, potentially improving performance by reducing re-renders.
435
- *
436
- * @docGroup 1. Operation options
437
- */
438
- ignoreResults: unknown;
439
425
  }
440
426
  export interface MutationResultDocumentation {
441
427
  /**
442
- * The data returned from your mutation. Can be `undefined` if `ignoreResults` is `true`.
428
+ * The data returned from your mutation. Can be `undefined` if the `errorPolicy`
429
+ * is `all` or `ignore` and the server returns a GraphQL response with `errors`
430
+ * but not `data` or a network error is returned.
443
431
  */
444
432
  data: unknown;
445
433
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"types.documentation.js","sourceRoot":"","sources":["../../../src/react/types/types.documentation.ts"],"names":[],"mappings":"","sourcesContent":["export interface QueryOptionsDocumentation {\n /**\n * A GraphQL query string parsed into an AST with the gql template literal.\n *\n * @docGroup 1. Operation options\n */\n query: unknown;\n\n /**\n * An object containing all of the GraphQL variables your query requires to execute.\n *\n * Each key in the object corresponds to a variable name, and that key's value corresponds to the variable value.\n *\n * @docGroup 1. Operation options\n */\n variables: unknown;\n\n /**\n * Specifies how the query handles a response that returns both GraphQL errors and partial results.\n *\n * For details, see [GraphQL error policies](https://www.apollographql.com/docs/react/data/error-handling/#graphql-error-policies).\n *\n * The default value is `none`, meaning that the query result includes error details but not partial results.\n *\n * @docGroup 1. Operation options\n */\n errorPolicy: unknown;\n\n /**\n * If you're using [Apollo Link](https://www.apollographql.com/docs/react/api/link/introduction/), this object is the initial value of the `context` object that's passed along your link chain.\n *\n * @docGroup 2. Networking options\n */\n context: unknown;\n\n /**\n * Specifies how the query interacts with the Apollo Client cache during execution (for example, whether it checks the cache for results before sending a request to the server).\n *\n * For details, see [Setting a fetch policy](https://www.apollographql.com/docs/react/data/queries/#setting-a-fetch-policy).\n *\n * The default value is `cache-first`.\n *\n * @docGroup 3. Caching options\n */\n fetchPolicy: unknown;\n\n /**\n * Specifies the `FetchPolicy` to be used after this query has completed.\n *\n * @docGroup 3. Caching options\n */\n nextFetchPolicy: unknown;\n\n /**\n * Defaults to the initial value of options.fetchPolicy, but can be explicitly\n * configured to specify the WatchQueryFetchPolicy to revert back to whenever\n * variables change (unless nextFetchPolicy intervenes).\n *\n * @docGroup 3. Caching options\n */\n initialFetchPolicy: unknown;\n\n /**\n * Specifies the interval (in milliseconds) at which the query polls for updated results.\n *\n * The default value is `0` (no polling).\n *\n * @docGroup 2. Networking options\n */\n pollInterval: unknown;\n\n /**\n * If `true`, the in-progress query's associated component re-renders whenever the network status changes or a network error occurs.\n *\n * The default value is `true`.\n *\n * @docGroup 2. Networking options\n */\n notifyOnNetworkStatusChange: unknown;\n\n /**\n * If `true`, the query can return partial results from the cache if the cache doesn't contain results for all queried fields.\n *\n * The default value is `false`.\n *\n * @docGroup 3. Caching options\n */\n returnPartialData: unknown;\n\n /**\n * Specifies whether a `NetworkStatus.refetch` operation should merge\n * incoming field data with existing data, or overwrite the existing data.\n * Overwriting is probably preferable, but merging is currently the default\n * behavior, for backwards compatibility with Apollo Client 3.x.\n *\n * @docGroup 3. Caching options\n */\n refetchWritePolicy: unknown;\n\n /**\n * Watched queries must opt into overwriting existing data on refetch, by passing refetchWritePolicy: \"overwrite\" in their WatchQueryOptions.\n *\n * The default value is \"overwrite\".\n *\n * @docGroup 3. Caching options\n */\n refetchWritePolicy_suspense: unknown;\n\n /**\n * If true, the query is not executed.\n *\n * The default value is `false`.\n *\n * @docGroup 1. Operation options\n */\n skip: unknown;\n\n /**\n * If `true`, the query is not executed. The default value is `false`.\n *\n * @deprecated We recommend using `skipToken` in place of the `skip` option as\n * it is more type-safe.\n *\n * This option is deprecated and only supported to ease the migration from `useQuery`. It will be removed in a future release.\n * Please use [`skipToken`](https://www.apollographql.com/docs/react/api/react/hooks#skiptoken) instead of the `skip` option as it is more type-safe.\n *\n * @docGroup 1. Operation options\n */\n skip_deprecated: unknown;\n\n /**\n * The instance of `ApolloClient` to use to execute the query.\n *\n * By default, the instance that's passed down via context is used, but you\n * can provide a different instance here.\n *\n * @docGroup 1. Operation options\n */\n client: unknown;\n\n /**\n * A unique identifier for the query. Each item in the array must be a stable\n * identifier to prevent infinite fetches.\n *\n * This is useful when using the same query and variables combination in more\n * than one component, otherwise the components may clobber each other. This\n * can also be used to force the query to re-evaluate fresh.\n *\n * @docGroup 1. Operation options\n */\n queryKey: unknown;\n\n /**\n * Pass `false` to skip executing the query during [server-side rendering](https://www.apollographql.com/docs/react/performance/server-side-rendering/).\n *\n * @docGroup 2. Networking options\n */\n ssr: unknown;\n\n /**\n * A callback function that's called whenever a refetch attempt occurs\n * while polling. If the function returns `true`, the refetch is\n * skipped and not reattempted until the next poll interval.\n *\n * @docGroup 2. Networking options\n */\n skipPollAttempt: unknown;\n}\n\nexport interface QueryResultDocumentation {\n /**\n * The instance of Apollo Client that executed the query.\n * Can be useful for manually executing followup queries or writing data to the cache.\n *\n * @docGroup 2. Network info\n */\n client: unknown;\n /**\n * A reference to the internal `ObservableQuery` used by the hook.\n */\n observable: unknown;\n /**\n * An object containing the result of your GraphQL query after it completes.\n *\n * This value might be `undefined` if a query results in one or more errors (depending on the query's `errorPolicy`).\n *\n * @docGroup 1. Operation data\n */\n data: unknown;\n /**\n * An object containing the result from the most recent _previous_ execution of this query.\n *\n * This value is `undefined` if this is the query's first execution.\n *\n * @docGroup 1. Operation data\n */\n previousData: unknown;\n /**\n * A single ErrorLike object describing the error that occured during the latest\n * query execution.\n *\n * For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).\n *\n * @docGroup 1. Operation data\n */\n error: unknown;\n /**\n * If `true`, the query is still in flight.\n *\n * @docGroup 2. Network info\n */\n loading: unknown;\n /**\n * A number indicating the current network state of the query's associated request. [See possible values.](https://github.com/apollographql/apollo-client/blob/d96f4578f89b933c281bb775a39503f6cdb59ee8/src/core/networkStatus.ts#L4)\n *\n * Used in conjunction with the [`notifyOnNetworkStatusChange`](#notifyonnetworkstatuschange) option.\n *\n * @docGroup 2. Network info\n */\n networkStatus: unknown;\n /**\n * An object containing the variables that were provided for the query.\n *\n * @docGroup 1. Operation data\n */\n variables: unknown;\n\n /**\n * A function that enables you to re-execute the query, optionally passing in new `variables`.\n *\n * To guarantee that the refetch performs a network request, its `fetchPolicy` is set to `network-only` (unless the original query's `fetchPolicy` is `no-cache` or `cache-and-network`, which also guarantee a network request).\n *\n * See also [Refetching](https://www.apollographql.com/docs/react/data/queries/#refetching).\n *\n * Returns a `ResultPromise` with an additional `.retain()` method. Calling\n * `.retain()` keeps the network operation running even if the `ObservableQuery`\n * no longer requires the result.\n *\n * @docGroup 3. Helper functions\n */\n refetch: unknown;\n /**\n * {@inheritDoc @apollo/client!ObservableQuery#fetchMore:member(1)}\n *\n * @docGroup 3. Helper functions\n */\n fetchMore: unknown;\n /**\n * {@inheritDoc @apollo/client!ObservableQuery#startPolling:member(1)}\n *\n * @docGroup 3. Helper functions\n */\n startPolling: unknown;\n /**\n * {@inheritDoc @apollo/client!ObservableQuery#stopPolling:member(1)}\n *\n * @docGroup 3. Helper functions\n */\n stopPolling: unknown;\n /**\n * {@inheritDoc @apollo/client!ObservableQuery#subscribeToMore:member(1)}\n *\n * @docGroup 3. Helper functions\n */\n subscribeToMore: unknown;\n /**\n * {@inheritDoc @apollo/client!ObservableQuery#updateQuery:member(1)}\n *\n * @docGroup 3. Helper functions\n */\n updateQuery: unknown;\n\n /**\n * Describes the completeness of `data`.\n *\n * - `empty`: No data could be fulfilled from the cache or the result is\n * incomplete. `data` is `undefined`.\n * - `partial`: Some data could be fulfilled from the cache but `data` is\n * incomplete. This is only possible when `returnPartialData` is `true`.\n * - `streaming`: `data` is incomplete as a result of a deferred query and\n * the result is still streaming in.\n * - `complete`: `data` is a fully satisfied query result fulfilled\n * either from the cache or network.\n *\n * @docGroup 1. Operation data\n */\n dataState: unknown;\n\n /**\n * Describes whether `data` is a complete or partial result. This flag is only\n * set when `returnPartialData` is `true` in query options.\n *\n * @deprecated This field will be removed in a future version of Apollo Client.\n * @docGroup 1. Operation data\n */\n partial: boolean;\n}\n\nexport interface MutationOptionsDocumentation {\n /**\n * A GraphQL document, often created with `gql` from the `graphql-tag`\n * package, that contains a single mutation inside of it.\n *\n * @docGroup 1. Operation options\n */\n mutation: unknown;\n\n /**\n * Provide `no-cache` if the mutation's result should _not_ be written to the Apollo Client cache.\n *\n * The default value is `network-only` (which means the result _is_ written to the cache).\n *\n * Unlike queries, mutations _do not_ support [fetch policies](https://www.apollographql.com/docs/react/data/queries/#setting-a-fetch-policy) besides `network-only` and `no-cache`.\n *\n * @docGroup 3. Caching options\n */\n fetchPolicy: unknown;\n\n /**\n * To avoid retaining sensitive information from mutation root field\n * arguments, Apollo Client v3.4+ automatically clears any `ROOT_MUTATION`\n * fields from the cache after each mutation finishes. If you need this\n * information to remain in the cache, you can prevent the removal by passing\n * `keepRootFields: true` to the mutation. `ROOT_MUTATION` result data are\n * also passed to the mutation `update` function, so we recommend obtaining\n * the results that way, rather than using this option, if possible.\n */\n keepRootFields: unknown;\n\n /**\n * By providing either an object or a callback function that, when invoked after\n * a mutation, allows you to return optimistic data and optionally skip updates\n * via the `IGNORE` sentinel object, Apollo Client caches this temporary\n * (and potentially incorrect) response until the mutation completes, enabling\n * more responsive UI updates.\n *\n * For more information, see [Optimistic mutation results](https://www.apollographql.com/docs/react/performance/optimistic-ui/).\n *\n * @docGroup 3. Caching options\n */\n optimisticResponse: unknown;\n\n /**\n * A `MutationQueryReducersMap`, which is map from query names to\n * mutation query reducers. Briefly, this map defines how to incorporate the\n * results of the mutation into the results of queries that are currently\n * being watched by your application.\n */\n updateQueries: unknown;\n\n /**\n * An array (or a function that _returns_ an array) that specifies which queries you want to refetch after the mutation occurs.\n *\n * Each array value can be either:\n *\n * - An object containing the `query` to execute, along with any `variables`\n *\n * - A string indicating the operation name of the query to refetch\n *\n * @docGroup 1. Operation options\n */\n refetchQueries: unknown;\n\n /**\n * If `true`, makes sure all queries included in `refetchQueries` are completed before the mutation is considered complete.\n *\n * The default value is `false` (queries are refetched asynchronously).\n *\n * @docGroup 1. Operation options\n */\n awaitRefetchQueries: unknown;\n\n /**\n * A function used to update the Apollo Client cache after the mutation completes.\n *\n * For more information, see [Updating the cache after a mutation](https://www.apollographql.com/docs/react/data/mutations#updating-the-cache-after-a-mutation).\n *\n * @docGroup 3. Caching options\n */\n update: unknown;\n\n /**\n * Optional callback for intercepting queries whose cache data has been updated by the mutation, as well as any queries specified in the `refetchQueries: [...]` list passed to `client.mutate`.\n *\n * Returning a `Promise` from `onQueryUpdated` will cause the final mutation `Promise` to await the returned `Promise`. Returning `false` causes the query to be ignored.\n *\n * @docGroup 1. Operation options\n */\n onQueryUpdated: unknown;\n\n /**\n * Specifies how the mutation handles a response that returns both GraphQL errors and partial results.\n *\n * For details, see [GraphQL error policies](https://www.apollographql.com/docs/react/data/error-handling/#graphql-error-policies).\n *\n * The default value is `none`, meaning that the mutation result includes error details but _not_ partial results.\n *\n * @docGroup 1. Operation options\n */\n errorPolicy: unknown;\n\n /**\n * An object containing all of the GraphQL variables your mutation requires to execute.\n *\n * Each key in the object corresponds to a variable name, and that key's value corresponds to the variable value.\n *\n * @docGroup 1. Operation options\n */\n variables: unknown;\n\n /**\n * If you're using [Apollo Link](https://www.apollographql.com/docs/react/api/link/introduction/), this object is the initial value of the `context` object that's passed along your link chain.\n *\n * @docGroup 2. Networking options\n */\n context: unknown;\n\n /**\n * The instance of `ApolloClient` to use to execute the mutation.\n *\n * By default, the instance that's passed down via context is used, but you can provide a different instance here.\n *\n * @docGroup 2. Networking options\n */\n client: unknown;\n /**\n * If `true`, the in-progress mutation's associated component re-renders whenever the network status changes or a network error occurs.\n *\n * The default value is `true`.\n *\n * @docGroup 2. Networking options\n */\n notifyOnNetworkStatusChange: unknown;\n /**\n * A callback function that's called when your mutation successfully completes with zero errors (or if `errorPolicy` is `ignore` and partial data is returned).\n *\n * This function is passed the mutation's result `data` and any options passed to the mutation.\n *\n * @docGroup 1. Operation options\n */\n onCompleted: unknown;\n /**\n * A callback function that's called when the mutation encounters one or more errors (unless `errorPolicy` is `ignore`).\n *\n * This function is passed an [`ApolloError`](https://github.com/apollographql/apollo-client/blob/d96f4578f89b933c281bb775a39503f6cdb59ee8/src/errors/index.ts#L36-L39) object that contains either a `networkError` object or a `graphQLErrors` array, depending on the error(s) that occurred, as well as any options passed the mutation.\n *\n * @docGroup 1. Operation options\n */\n onError: unknown;\n /**\n * If `true`:\n *\n * - The initial state update (setting loading to true) is skipped\n * - The success state update (setting data and setting loading to false) is skipped\n * - Error updates will still occur\n *\n * The default value is `false`.\n *\n * This option is useful when you want to execute a mutation but don't need to track its progress or result in the UI, potentially improving performance by reducing re-renders.\n *\n * @docGroup 1. Operation options\n */\n ignoreResults: unknown;\n}\n\nexport interface MutationResultDocumentation {\n /**\n * The data returned from your mutation. Can be `undefined` if `ignoreResults` is `true`.\n */\n data: unknown;\n /**\n * If the mutation produces one or more errors, this object contains either an array of `graphQLErrors` or a single `networkError`. Otherwise, this value is `undefined`.\n *\n * For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).\n */\n error: unknown;\n /**\n * If `true`, the mutation is currently in flight.\n */\n loading: unknown;\n /**\n * If `true`, the mutation's mutate function has been called.\n */\n called: unknown;\n /**\n * The instance of Apollo Client that executed the mutation.\n *\n * Can be useful for manually executing followup operations or writing data to the cache.\n */\n client: unknown;\n /**\n * A function that you can call to reset the mutation's result to its initial, uncalled state.\n */\n reset: unknown;\n /**\n * Custom extensions returned from the GraphQL server\n */\n extensions: unknown;\n}\n\nexport interface SubscriptionOptionsDocumentation {\n /**\n * A GraphQL document, often created with `gql` from the `graphql-tag`\n * package, that contains a single subscription inside of it.\n */\n query: unknown;\n /**\n * An object containing all of the variables your subscription needs to execute\n */\n variables: unknown;\n\n /**\n * Specifies the `ErrorPolicy` to be used for this operation\n */\n errorPolicy: unknown;\n\n /**\n * How you want your component to interact with the Apollo cache. For details, see [Setting a fetch policy](https://www.apollographql.com/docs/react/data/queries/#setting-a-fetch-policy).\n */\n fetchPolicy: unknown;\n\n /**\n * Determines if your subscription should be unsubscribed and subscribed again when an input to the hook (such as `subscription` or `variables`) changes.\n */\n shouldResubscribe: unknown;\n\n /**\n * If `true`, the hook will not cause the component to rerender. This is useful when you want to control the rendering of your component yourself with logic in the `onData` and `onError` callbacks.\n *\n * Changing this to `true` when the hook already has `data` will reset the `data` to `undefined`.\n */\n ignoreResults: unknown;\n /**\n * An `ApolloClient` instance. By default `useSubscription` / `Subscription` uses the client passed down via context, but a different client can be passed in.\n */\n client: unknown;\n\n /**\n * Determines if the current subscription should be skipped. Useful if, for example, variables depend on previous queries and are not ready yet.\n */\n skip: unknown;\n\n /**\n * Shared context between your component and your network interface (Apollo Link).\n */\n context: unknown;\n\n /**\n * Shared context between your component and your network interface (Apollo Link).\n */\n extensions: unknown;\n\n /**\n * Allows the registration of a callback function that will be triggered each time the `useSubscription` Hook / `Subscription` component completes the subscription.\n */\n onComplete: unknown;\n\n /**\n * Allows the registration of a callback function that will be triggered each time the `useSubscription` Hook / `Subscription` component receives data. The callback `options` object param consists of the current Apollo Client instance in `client`, and the received subscription data in `data`.\n */\n onData: unknown;\n\n /**\n * Allows the registration of a callback function that will be triggered each time the `useSubscription` Hook / `Subscription` component receives an error.\n */\n onError: unknown;\n}\n\nexport interface SubscriptionResultDocumentation {\n /**\n * A boolean that indicates whether any initial data has been returned\n */\n loading: unknown;\n /**\n * An object containing the result of your GraphQL subscription. Defaults to an empty object.\n */\n data: unknown;\n /**\n * A runtime error with `graphQLErrors` and `networkError` properties\n */\n error: unknown;\n}\n"]}
1
+ {"version":3,"file":"types.documentation.js","sourceRoot":"","sources":["../../../src/react/types/types.documentation.ts"],"names":[],"mappings":"","sourcesContent":["export interface QueryOptionsDocumentation {\n /**\n * A GraphQL query string parsed into an AST with the gql template literal.\n *\n * @docGroup 1. Operation options\n */\n query: unknown;\n\n /**\n * An object containing all of the GraphQL variables your query requires to execute.\n *\n * Each key in the object corresponds to a variable name, and that key's value corresponds to the variable value.\n *\n * @docGroup 1. Operation options\n */\n variables: unknown;\n\n /**\n * Specifies how the query handles a response that returns both GraphQL errors and partial results.\n *\n * For details, see [GraphQL error policies](https://www.apollographql.com/docs/react/data/error-handling/#graphql-error-policies).\n *\n * The default value is `none`, meaning that the query result includes error details but not partial results.\n *\n * @docGroup 1. Operation options\n */\n errorPolicy: unknown;\n\n /**\n * If you're using [Apollo Link](https://www.apollographql.com/docs/react/api/link/introduction/), this object is the initial value of the `context` object that's passed along your link chain.\n *\n * @docGroup 2. Networking options\n */\n context: unknown;\n\n /**\n * Specifies how the query interacts with the Apollo Client cache during execution (for example, whether it checks the cache for results before sending a request to the server).\n *\n * For details, see [Setting a fetch policy](https://www.apollographql.com/docs/react/data/queries/#setting-a-fetch-policy).\n *\n * The default value is `cache-first`.\n *\n * @docGroup 3. Caching options\n */\n fetchPolicy: unknown;\n\n /**\n * Specifies the `FetchPolicy` to be used after this query has completed.\n *\n * @docGroup 3. Caching options\n */\n nextFetchPolicy: unknown;\n\n /**\n * Defaults to the initial value of options.fetchPolicy, but can be explicitly\n * configured to specify the WatchQueryFetchPolicy to revert back to whenever\n * variables change (unless nextFetchPolicy intervenes).\n *\n * @docGroup 3. Caching options\n */\n initialFetchPolicy: unknown;\n\n /**\n * Specifies the interval (in milliseconds) at which the query polls for updated results.\n *\n * The default value is `0` (no polling).\n *\n * @docGroup 2. Networking options\n */\n pollInterval: unknown;\n\n /**\n * If `true`, the in-progress query's associated component re-renders whenever the network status changes or a network error occurs.\n *\n * The default value is `true`.\n *\n * @docGroup 2. Networking options\n */\n notifyOnNetworkStatusChange: unknown;\n\n /**\n * If `true`, the query can return partial results from the cache if the cache doesn't contain results for all queried fields.\n *\n * The default value is `false`.\n *\n * @docGroup 3. Caching options\n */\n returnPartialData: unknown;\n\n /**\n * Specifies whether a `NetworkStatus.refetch` operation should merge\n * incoming field data with existing data, or overwrite the existing data.\n * Overwriting is probably preferable, but merging is currently the default\n * behavior, for backwards compatibility with Apollo Client 3.x.\n *\n * @docGroup 3. Caching options\n */\n refetchWritePolicy: unknown;\n\n /**\n * Watched queries must opt into overwriting existing data on refetch, by passing refetchWritePolicy: \"overwrite\" in their WatchQueryOptions.\n *\n * The default value is \"overwrite\".\n *\n * @docGroup 3. Caching options\n */\n refetchWritePolicy_suspense: unknown;\n\n /**\n * If true, the query is not executed.\n *\n * The default value is `false`.\n *\n * @docGroup 1. Operation options\n */\n skip: unknown;\n\n /**\n * If `true`, the query is not executed. The default value is `false`.\n *\n * @deprecated We recommend using `skipToken` in place of the `skip` option as\n * it is more type-safe.\n *\n * This option is deprecated and only supported to ease the migration from `useQuery`. It will be removed in a future release.\n * Please use [`skipToken`](https://www.apollographql.com/docs/react/api/react/hooks#skiptoken) instead of the `skip` option as it is more type-safe.\n *\n * @docGroup 1. Operation options\n */\n skip_deprecated: unknown;\n\n /**\n * The instance of `ApolloClient` to use to execute the query.\n *\n * By default, the instance that's passed down via context is used, but you\n * can provide a different instance here.\n *\n * @docGroup 1. Operation options\n */\n client: unknown;\n\n /**\n * A unique identifier for the query. Each item in the array must be a stable\n * identifier to prevent infinite fetches.\n *\n * This is useful when using the same query and variables combination in more\n * than one component, otherwise the components may clobber each other. This\n * can also be used to force the query to re-evaluate fresh.\n *\n * @docGroup 1. Operation options\n */\n queryKey: unknown;\n\n /**\n * Pass `false` to skip executing the query during [server-side rendering](https://www.apollographql.com/docs/react/performance/server-side-rendering/).\n *\n * @docGroup 2. Networking options\n */\n ssr: unknown;\n\n /**\n * A callback function that's called whenever a refetch attempt occurs\n * while polling. If the function returns `true`, the refetch is\n * skipped and not reattempted until the next poll interval.\n *\n * @docGroup 2. Networking options\n */\n skipPollAttempt: unknown;\n}\n\nexport interface QueryResultDocumentation {\n /**\n * The instance of Apollo Client that executed the query.\n * Can be useful for manually executing followup queries or writing data to the cache.\n *\n * @docGroup 2. Network info\n */\n client: unknown;\n /**\n * A reference to the internal `ObservableQuery` used by the hook.\n */\n observable: unknown;\n /**\n * An object containing the result of your GraphQL query after it completes.\n *\n * This value might be `undefined` if a query results in one or more errors (depending on the query's `errorPolicy`).\n *\n * @docGroup 1. Operation data\n */\n data: unknown;\n /**\n * An object containing the result from the most recent _previous_ execution of this query.\n *\n * This value is `undefined` if this is the query's first execution.\n *\n * @docGroup 1. Operation data\n */\n previousData: unknown;\n /**\n * A single ErrorLike object describing the error that occured during the latest\n * query execution.\n *\n * For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).\n *\n * @docGroup 1. Operation data\n */\n error: unknown;\n /**\n * If `true`, the query is still in flight.\n *\n * @docGroup 2. Network info\n */\n loading: unknown;\n /**\n * A number indicating the current network state of the query's associated request. [See possible values.](https://github.com/apollographql/apollo-client/blob/d96f4578f89b933c281bb775a39503f6cdb59ee8/src/core/networkStatus.ts#L4)\n *\n * Used in conjunction with the [`notifyOnNetworkStatusChange`](#notifyonnetworkstatuschange) option.\n *\n * @docGroup 2. Network info\n */\n networkStatus: unknown;\n /**\n * An object containing the variables that were provided for the query.\n *\n * @docGroup 1. Operation data\n */\n variables: unknown;\n\n /**\n * A function that enables you to re-execute the query, optionally passing in new `variables`.\n *\n * To guarantee that the refetch performs a network request, its `fetchPolicy` is set to `network-only` (unless the original query's `fetchPolicy` is `no-cache` or `cache-and-network`, which also guarantee a network request).\n *\n * See also [Refetching](https://www.apollographql.com/docs/react/data/queries/#refetching).\n *\n * Returns a `ResultPromise` with an additional `.retain()` method. Calling\n * `.retain()` keeps the network operation running even if the `ObservableQuery`\n * no longer requires the result.\n *\n * @docGroup 3. Helper functions\n */\n refetch: unknown;\n /**\n * {@inheritDoc @apollo/client!ObservableQuery#fetchMore:member(1)}\n *\n * @docGroup 3. Helper functions\n */\n fetchMore: unknown;\n /**\n * {@inheritDoc @apollo/client!ObservableQuery#startPolling:member(1)}\n *\n * @docGroup 3. Helper functions\n */\n startPolling: unknown;\n /**\n * {@inheritDoc @apollo/client!ObservableQuery#stopPolling:member(1)}\n *\n * @docGroup 3. Helper functions\n */\n stopPolling: unknown;\n /**\n * {@inheritDoc @apollo/client!ObservableQuery#subscribeToMore:member(1)}\n *\n * @docGroup 3. Helper functions\n */\n subscribeToMore: unknown;\n /**\n * {@inheritDoc @apollo/client!ObservableQuery#updateQuery:member(1)}\n *\n * @docGroup 3. Helper functions\n */\n updateQuery: unknown;\n\n /**\n * Describes the completeness of `data`.\n *\n * - `empty`: No data could be fulfilled from the cache or the result is\n * incomplete. `data` is `undefined`.\n * - `partial`: Some data could be fulfilled from the cache but `data` is\n * incomplete. This is only possible when `returnPartialData` is `true`.\n * - `streaming`: `data` is incomplete as a result of a deferred query and\n * the result is still streaming in.\n * - `complete`: `data` is a fully satisfied query result fulfilled\n * either from the cache or network.\n *\n * @docGroup 1. Operation data\n */\n dataState: unknown;\n\n /**\n * Describes whether `data` is a complete or partial result. This flag is only\n * set when `returnPartialData` is `true` in query options.\n *\n * @deprecated This field will be removed in a future version of Apollo Client.\n * @docGroup 1. Operation data\n */\n partial: boolean;\n}\n\nexport interface MutationOptionsDocumentation {\n /**\n * A GraphQL document, often created with `gql` from the `graphql-tag`\n * package, that contains a single mutation inside of it.\n *\n * @docGroup 1. Operation options\n */\n mutation: unknown;\n\n /**\n * Provide `no-cache` if the mutation's result should _not_ be written to the Apollo Client cache.\n *\n * The default value is `network-only` (which means the result _is_ written to the cache).\n *\n * Unlike queries, mutations _do not_ support [fetch policies](https://www.apollographql.com/docs/react/data/queries/#setting-a-fetch-policy) besides `network-only` and `no-cache`.\n *\n * @docGroup 3. Caching options\n */\n fetchPolicy: unknown;\n\n /**\n * To avoid retaining sensitive information from mutation root field\n * arguments, Apollo Client v3.4+ automatically clears any `ROOT_MUTATION`\n * fields from the cache after each mutation finishes. If you need this\n * information to remain in the cache, you can prevent the removal by passing\n * `keepRootFields: true` to the mutation. `ROOT_MUTATION` result data are\n * also passed to the mutation `update` function, so we recommend obtaining\n * the results that way, rather than using this option, if possible.\n */\n keepRootFields: unknown;\n\n /**\n * By providing either an object or a callback function that, when invoked after\n * a mutation, allows you to return optimistic data and optionally skip updates\n * via the `IGNORE` sentinel object, Apollo Client caches this temporary\n * (and potentially incorrect) response until the mutation completes, enabling\n * more responsive UI updates.\n *\n * For more information, see [Optimistic mutation results](https://www.apollographql.com/docs/react/performance/optimistic-ui/).\n *\n * @docGroup 3. Caching options\n */\n optimisticResponse: unknown;\n\n /**\n * A `MutationQueryReducersMap`, which is map from query names to\n * mutation query reducers. Briefly, this map defines how to incorporate the\n * results of the mutation into the results of queries that are currently\n * being watched by your application.\n */\n updateQueries: unknown;\n\n /**\n * An array (or a function that _returns_ an array) that specifies which queries you want to refetch after the mutation occurs.\n *\n * Each array value can be either:\n *\n * - An object containing the `query` to execute, along with any `variables`\n *\n * - A string indicating the operation name of the query to refetch\n *\n * @docGroup 1. Operation options\n */\n refetchQueries: unknown;\n\n /**\n * If `true`, makes sure all queries included in `refetchQueries` are completed before the mutation is considered complete.\n *\n * The default value is `false` (queries are refetched asynchronously).\n *\n * @docGroup 1. Operation options\n */\n awaitRefetchQueries: unknown;\n\n /**\n * A function used to update the Apollo Client cache after the mutation completes.\n *\n * For more information, see [Updating the cache after a mutation](https://www.apollographql.com/docs/react/data/mutations#updating-the-cache-after-a-mutation).\n *\n * @docGroup 3. Caching options\n */\n update: unknown;\n\n /**\n * Optional callback for intercepting queries whose cache data has been updated by the mutation, as well as any queries specified in the `refetchQueries: [...]` list passed to `client.mutate`.\n *\n * Returning a `Promise` from `onQueryUpdated` will cause the final mutation `Promise` to await the returned `Promise`. Returning `false` causes the query to be ignored.\n *\n * @docGroup 1. Operation options\n */\n onQueryUpdated: unknown;\n\n /**\n * Specifies how the mutation handles a response that returns both GraphQL errors and partial results.\n *\n * For details, see [GraphQL error policies](https://www.apollographql.com/docs/react/data/error-handling/#graphql-error-policies).\n *\n * The default value is `none`, meaning that the mutation result includes error details but _not_ partial results.\n *\n * @docGroup 1. Operation options\n */\n errorPolicy: unknown;\n\n /**\n * An object containing all of the GraphQL variables your mutation requires to execute.\n *\n * Each key in the object corresponds to a variable name, and that key's value corresponds to the variable value.\n *\n * @docGroup 1. Operation options\n */\n variables: unknown;\n\n /**\n * If you're using [Apollo Link](https://www.apollographql.com/docs/react/api/link/introduction/), this object is the initial value of the `context` object that's passed along your link chain.\n *\n * @docGroup 2. Networking options\n */\n context: unknown;\n\n /**\n * The instance of `ApolloClient` to use to execute the mutation.\n *\n * By default, the instance that's passed down via context is used, but you can provide a different instance here.\n *\n * @docGroup 2. Networking options\n */\n client: unknown;\n /**\n * If `true`, the in-progress mutation's associated component re-renders whenever the network status changes or a network error occurs.\n *\n * The default value is `true`.\n *\n * @docGroup 2. Networking options\n */\n notifyOnNetworkStatusChange: unknown;\n /**\n * A callback function that's called when your mutation successfully completes with zero errors (or if `errorPolicy` is `ignore` and partial data is returned).\n *\n * This function is passed the mutation's result `data` and any options passed to the mutation.\n *\n * @docGroup 1. Operation options\n */\n onCompleted: unknown;\n /**\n * A callback function that's called when the mutation encounters one or more errors (unless `errorPolicy` is `ignore`).\n *\n * This function is passed an [`ApolloError`](https://github.com/apollographql/apollo-client/blob/d96f4578f89b933c281bb775a39503f6cdb59ee8/src/errors/index.ts#L36-L39) object that contains either a `networkError` object or a `graphQLErrors` array, depending on the error(s) that occurred, as well as any options passed the mutation.\n *\n * @docGroup 1. Operation options\n */\n onError: unknown;\n}\n\nexport interface MutationResultDocumentation {\n /**\n * The data returned from your mutation. Can be `undefined` if the `errorPolicy`\n * is `all` or `ignore` and the server returns a GraphQL response with `errors`\n * but not `data` or a network error is returned.\n */\n data: unknown;\n /**\n * If the mutation produces one or more errors, this object contains either an array of `graphQLErrors` or a single `networkError`. Otherwise, this value is `undefined`.\n *\n * For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).\n */\n error: unknown;\n /**\n * If `true`, the mutation is currently in flight.\n */\n loading: unknown;\n /**\n * If `true`, the mutation's mutate function has been called.\n */\n called: unknown;\n /**\n * The instance of Apollo Client that executed the mutation.\n *\n * Can be useful for manually executing followup operations or writing data to the cache.\n */\n client: unknown;\n /**\n * A function that you can call to reset the mutation's result to its initial, uncalled state.\n */\n reset: unknown;\n /**\n * Custom extensions returned from the GraphQL server\n */\n extensions: unknown;\n}\n\nexport interface SubscriptionOptionsDocumentation {\n /**\n * A GraphQL document, often created with `gql` from the `graphql-tag`\n * package, that contains a single subscription inside of it.\n */\n query: unknown;\n /**\n * An object containing all of the variables your subscription needs to execute\n */\n variables: unknown;\n\n /**\n * Specifies the `ErrorPolicy` to be used for this operation\n */\n errorPolicy: unknown;\n\n /**\n * How you want your component to interact with the Apollo cache. For details, see [Setting a fetch policy](https://www.apollographql.com/docs/react/data/queries/#setting-a-fetch-policy).\n */\n fetchPolicy: unknown;\n\n /**\n * Determines if your subscription should be unsubscribed and subscribed again when an input to the hook (such as `subscription` or `variables`) changes.\n */\n shouldResubscribe: unknown;\n\n /**\n * If `true`, the hook will not cause the component to rerender. This is useful when you want to control the rendering of your component yourself with logic in the `onData` and `onError` callbacks.\n *\n * Changing this to `true` when the hook already has `data` will reset the `data` to `undefined`.\n */\n ignoreResults: unknown;\n /**\n * An `ApolloClient` instance. By default `useSubscription` / `Subscription` uses the client passed down via context, but a different client can be passed in.\n */\n client: unknown;\n\n /**\n * Determines if the current subscription should be skipped. Useful if, for example, variables depend on previous queries and are not ready yet.\n */\n skip: unknown;\n\n /**\n * Shared context between your component and your network interface (Apollo Link).\n */\n context: unknown;\n\n /**\n * Shared context between your component and your network interface (Apollo Link).\n */\n extensions: unknown;\n\n /**\n * Allows the registration of a callback function that will be triggered each time the `useSubscription` Hook / `Subscription` component completes the subscription.\n */\n onComplete: unknown;\n\n /**\n * Allows the registration of a callback function that will be triggered each time the `useSubscription` Hook / `Subscription` component receives data. The callback `options` object param consists of the current Apollo Client instance in `client`, and the received subscription data in `data`.\n */\n onData: unknown;\n\n /**\n * Allows the registration of a callback function that will be triggered each time the `useSubscription` Hook / `Subscription` component receives an error.\n */\n onError: unknown;\n}\n\nexport interface SubscriptionResultDocumentation {\n /**\n * A boolean that indicates whether any initial data has been returned\n */\n loading: unknown;\n /**\n * An object containing the result of your GraphQL subscription. Defaults to an empty object.\n */\n data: unknown;\n /**\n * A runtime error with `graphQLErrors` and `networkError` properties\n */\n error: unknown;\n}\n"]}
package/version.js CHANGED
@@ -1,3 +1,3 @@
1
- export const version = "4.0.5";
1
+ export const version = "4.0.7";
2
2
  export const build = "esm";
3
3
  //# sourceMappingURL=version.js.map