@apollo/client 4.0.7 → 4.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/__cjs/cache/core/types/common.cjs.map +1 -1
- package/__cjs/cache/core/types/common.d.cts +1 -1
- package/__cjs/cache/inmemory/fragmentRegistry.cjs +1 -1
- package/__cjs/cache/inmemory/fragmentRegistry.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +1 -1
- package/__cjs/core/ObservableQuery.cjs +3 -3
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/ObservableQuery.d.cts +2 -2
- package/__cjs/core/QueryManager.cjs +1 -1
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/dev/setErrorMessageHandler.cjs.map +1 -1
- package/__cjs/dev/setErrorMessageHandler.d.cts +1 -1
- package/__cjs/masking/maskDefinition.cjs +1 -1
- package/__cjs/masking/maskDefinition.cjs.map +1 -1
- package/__cjs/react/hooks/internal/index.cjs +3 -1
- package/__cjs/react/hooks/internal/index.cjs.map +1 -1
- package/__cjs/react/hooks/internal/index.d.cts +1 -0
- package/__cjs/react/hooks/internal/useRenderGuard.cjs +1 -1
- package/__cjs/react/hooks/internal/useRenderGuard.cjs.map +1 -1
- package/__cjs/react/hooks/internal/useSuspenseHookCacheKey.cjs +28 -0
- package/__cjs/react/hooks/internal/useSuspenseHookCacheKey.cjs.map +1 -0
- package/__cjs/react/hooks/internal/useSuspenseHookCacheKey.d.cts +11 -0
- package/__cjs/react/hooks/useBackgroundQuery.cjs +2 -8
- package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useFragment.cjs +1 -1
- package/__cjs/react/hooks/useFragment.cjs.map +1 -1
- package/__cjs/react/hooks/useLazyQuery.d.cts +1 -1
- package/__cjs/react/hooks/useQuery.d.cts +1 -1
- package/__cjs/react/hooks/useReadQuery.d.cts +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.cjs +2 -8
- package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.d.cts +1 -1
- package/__cjs/react/hooks/useSyncExternalStore.cjs +1 -1
- package/__cjs/react/hooks/useSyncExternalStore.cjs.map +1 -1
- package/__cjs/react/internal/cache/QueryReference.cjs +1 -1
- package/__cjs/react/internal/cache/QueryReference.cjs.map +1 -1
- package/__cjs/react/types/types.documentation.d.cts +1 -1
- package/__cjs/testing/core/mocking/mockLink.cjs +2 -2
- package/__cjs/testing/core/mocking/mockLink.cjs.map +1 -1
- package/__cjs/utilities/internal/getMemoryInternals.cjs.map +1 -1
- package/__cjs/utilities/internal/types/DocumentationTypes.d.cts +1 -1
- package/__cjs/version.cjs +1 -1
- package/cache/core/types/common.d.ts +1 -1
- package/cache/core/types/common.js.map +1 -1
- package/cache/inmemory/fragmentRegistry.js +1 -1
- package/cache/inmemory/fragmentRegistry.js.map +1 -1
- package/core/ApolloClient.d.ts +1 -1
- package/core/ObservableQuery.d.ts +2 -2
- package/core/ObservableQuery.js +3 -3
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryManager.js +1 -1
- package/core/QueryManager.js.map +1 -1
- package/dev/setErrorMessageHandler.d.ts +1 -1
- package/dev/setErrorMessageHandler.js.map +1 -1
- package/masking/internal/types.js.map +1 -1
- package/masking/maskDefinition.js +1 -1
- package/masking/maskDefinition.js.map +1 -1
- package/package.json +1 -1
- package/react/hooks/internal/index.d.ts +1 -0
- package/react/hooks/internal/index.js +1 -0
- package/react/hooks/internal/index.js.map +1 -1
- package/react/hooks/internal/useRenderGuard.js +1 -1
- package/react/hooks/internal/useRenderGuard.js.map +1 -1
- package/react/hooks/internal/useSuspenseHookCacheKey.d.ts +11 -0
- package/react/hooks/internal/useSuspenseHookCacheKey.js +24 -0
- package/react/hooks/internal/useSuspenseHookCacheKey.js.map +1 -0
- package/react/hooks/useBackgroundQuery.js +3 -9
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useFragment.js +1 -1
- package/react/hooks/useFragment.js.map +1 -1
- package/react/hooks/useLazyQuery.d.ts +1 -1
- package/react/hooks/useQuery.d.ts +1 -1
- package/react/hooks/useReadQuery.d.ts +1 -1
- package/react/hooks/useSuspenseQuery.d.ts +1 -1
- package/react/hooks/useSuspenseQuery.js +3 -9
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks/useSyncExternalStore.js +1 -1
- package/react/hooks/useSyncExternalStore.js.map +1 -1
- package/react/hooks-compiled/internal/index.d.ts +1 -0
- package/react/hooks-compiled/internal/index.js +1 -0
- package/react/hooks-compiled/internal/index.js.map +1 -1
- package/react/hooks-compiled/internal/useRenderGuard.js +1 -1
- package/react/hooks-compiled/internal/useRenderGuard.js.map +1 -1
- package/react/hooks-compiled/internal/useSuspenseHookCacheKey.d.ts +11 -0
- package/react/hooks-compiled/internal/useSuspenseHookCacheKey.js +73 -0
- package/react/hooks-compiled/internal/useSuspenseHookCacheKey.js.map +1 -0
- package/react/hooks-compiled/useBackgroundQuery.js +5 -11
- package/react/hooks-compiled/useBackgroundQuery.js.map +1 -1
- package/react/hooks-compiled/useFragment.js +1 -1
- package/react/hooks-compiled/useFragment.js.map +1 -1
- package/react/hooks-compiled/useLazyQuery.d.ts +1 -1
- package/react/hooks-compiled/useQuery.d.ts +1 -1
- package/react/hooks-compiled/useReadQuery.d.ts +1 -1
- package/react/hooks-compiled/useSuspenseQuery.d.ts +1 -1
- package/react/hooks-compiled/useSuspenseQuery.js +5 -11
- package/react/hooks-compiled/useSuspenseQuery.js.map +1 -1
- package/react/hooks-compiled/useSyncExternalStore.js +1 -1
- package/react/hooks-compiled/useSyncExternalStore.js.map +1 -1
- package/react/internal/cache/QueryReference.js +1 -1
- package/react/internal/cache/QueryReference.js.map +1 -1
- package/react/types/types.documentation.d.ts +1 -1
- package/react/types/types.documentation.js.map +1 -1
- package/testing/core/mocking/mockLink.js +2 -2
- package/testing/core/mocking/mockLink.js.map +1 -1
- package/utilities/internal/getMemoryInternals.js.map +1 -1
- package/utilities/internal/types/DocumentationTypes.d.ts +1 -1
- package/version.js +1 -1
|
@@ -16,7 +16,7 @@ export type ErrorMessageHandler = {
|
|
|
16
16
|
*
|
|
17
17
|
* ⚠️ Note that arguments will only be passed in for error messages.
|
|
18
18
|
* For normal log messages, you will get an empty array here and they will directly
|
|
19
|
-
* be passed to `console.log` instead, to have the string
|
|
19
|
+
* be passed to `console.log` instead, to have the string substitution done by the
|
|
20
20
|
* engine, as that allows for nicer (and in the case of a browser, interactive)
|
|
21
21
|
* output.
|
|
22
22
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setErrorMessageHandler.js","sourceRoot":"","sources":["../../src/dev/setErrorMessageHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAInE,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAgCxD;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAA4B;IACjE,MAAM,CAAC,yBAAyB,CAAC,GAAG,OAAsC,CAAC;AAC7E,CAAC","sourcesContent":["import { global } from \"@apollo/client/utilities/internal/globals\";\n\nimport type { ErrorCodes } from \"../invariantErrorCodes.js\";\n\nimport { ApolloErrorMessageHandler } from \"./symbol.js\";\n\n/**\n * The error message handler is a function that is called when a message is\n * logged or an error is thrown to determine the contents of the error message\n * to be logged or thrown.\n */\nexport type ErrorMessageHandler = {\n /**\n * @param message - Usually the error message number (as defined in\n * `@apollo/client/invariantErrorCodes.js`).\n * In some edge cases, this can already be a string, that can be passed through\n * as an error message.\n *\n * @param args - The placeholders that can be passed into the error message (pre-stringified).\n * These relate with the `%s` and `%d` [substitution strings](https://developer.mozilla.org/en-US/docs/Web/API/console#using_string_substitutions)\n * in the error message defined in `@apollo/client/invariantErrorCodes.js`.\n *\n * ⚠️ Note that arguments will only be passed in for error messages.\n * For normal log messages, you will get an empty array here and they will directly\n * be passed to `console.log` instead, to have the string
|
|
1
|
+
{"version":3,"file":"setErrorMessageHandler.js","sourceRoot":"","sources":["../../src/dev/setErrorMessageHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAInE,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAgCxD;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAA4B;IACjE,MAAM,CAAC,yBAAyB,CAAC,GAAG,OAAsC,CAAC;AAC7E,CAAC","sourcesContent":["import { global } from \"@apollo/client/utilities/internal/globals\";\n\nimport type { ErrorCodes } from \"../invariantErrorCodes.js\";\n\nimport { ApolloErrorMessageHandler } from \"./symbol.js\";\n\n/**\n * The error message handler is a function that is called when a message is\n * logged or an error is thrown to determine the contents of the error message\n * to be logged or thrown.\n */\nexport type ErrorMessageHandler = {\n /**\n * @param message - Usually the error message number (as defined in\n * `@apollo/client/invariantErrorCodes.js`).\n * In some edge cases, this can already be a string, that can be passed through\n * as an error message.\n *\n * @param args - The placeholders that can be passed into the error message (pre-stringified).\n * These relate with the `%s` and `%d` [substitution strings](https://developer.mozilla.org/en-US/docs/Web/API/console#using_string_substitutions)\n * in the error message defined in `@apollo/client/invariantErrorCodes.js`.\n *\n * ⚠️ Note that arguments will only be passed in for error messages.\n * For normal log messages, you will get an empty array here and they will directly\n * be passed to `console.log` instead, to have the string substitution done by the\n * engine, as that allows for nicer (and in the case of a browser, interactive)\n * output.\n *\n * @returns The error message to be logged or thrown. If it returns `undefined`,\n * the mechanism will fall back to the default:\n * A link to https://go.apollo.dev/c/err with Apollo Client version,\n * the error message number, and the error message arguments encoded into\n * the URL hash.\n */ (message: string | number, args: string[]): string | undefined;\n};\n\n/**\n * Overrides the global \"Error Message Handler\" with a custom implementation.\n */\nexport function setErrorMessageHandler(handler: ErrorMessageHandler) {\n global[ApolloErrorMessageHandler] = handler as typeof handler & ErrorCodes;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/masking/internal/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n IsAny,\n Prettify,\n Primitive,\n RemoveIndexSignature,\n} from \"@apollo/client/utilities/internal\";\n\nexport type UnwrapFragmentRefs<TData> =\n true extends IsAny<TData> ? TData\n : TData extends any ?\n // Ensure tagged/branded types are left alone (i.e. type UUID = string & { ... })\n TData extends Primitive ? TData\n : // Leave TData alone if it is Record<string, any> and not a specific shape\n string extends keyof TData ? TData\n : // short-circuit on empty object\n keyof TData extends never ? TData\n : TData extends { \" $fragmentRefs\"?: infer FragmentRefs } ?\n UnwrapFragmentRefs<\n CombineIntersection<\n | Omit<TData, \" $fragmentRefs\">\n | RemoveFragmentName<\n NonNullable<\n NonNullable<FragmentRefs>[keyof NonNullable<FragmentRefs>]\n >\n >\n >\n >\n : TData extends object ?\n {\n [K in keyof TData]: UnwrapFragmentRefs<TData[K]>;\n }\n : TData\n : never;\n\n/**\n * ```ts\n * CombineIntersection<\n * | { foo: string }\n * | { __typename: \"A\"; a: string }\n * | { __typename: \"B\"; b1: number }\n * | { __typename: \"B\"; b2: string }\n * > =>\n * | { foo: string }\n * | CombineByTypeName<\n * | { __typename: \"A\"; a: string }\n * | { __typename: \"B\"; b1: number }\n * | { __typename: \"B\"; b2: string }\n * >\n * ```\n */\ntype CombineIntersection<T> =\n | Exclude<T, { __typename?: string }>\n | CombineByTypeName<Extract<T, { __typename?: string }>>;\n/**\n * ```ts\n * CombineByTypeName<\n * | { __typename: \"A\"; a: string }\n * | { __typename: \"B\"; b1: number }\n * | { __typename: \"B\"; b2: string }\n * > =>\n * | CombineWithArrays<\n * | { __typename: \"A\"; a: string }\n * >\n * | CombineWithArrays<\n * | { __typename: \"B\"; b1: number }\n * | { __typename: \"B\"; b2: number }\n * >\n * ```\n */\ntype CombineByTypeName<T extends { __typename?: string }> = {\n [TypeName in NonNullable<T[\"__typename\"]>]: Prettify<\n MergeUnions<ExtractByMatchingTypeNames<T, TypeName>>\n >;\n}[NonNullable<T[\"__typename\"]>];\n\n/**\n * ```ts\n * CombineByTypeName<\n * | {\n * __typename: \"Person\" | \"Animatronic\" | \"CartoonCharacter\";\n * id: number;\n * name: string;\n * }\n * | {\n * __typename: \"Person\";\n * birthdate: string;\n * }\n * | {\n * __typename: \"Animatronic\";\n * manufacturer: string;\n * warrantyEndDate: string;\n * }\n * | {\n * __typename: \"CartoonCharacter\";\n * animator: string;\n * voiceActor: string;\n * }\n * >\n * =>\n * {\n * id: number;\n * name: string;\n * __typename: \"Person\";\n * birthdate: string;\n * } | {\n * id: number;\n * name: string;\n * __typename: \"Animatronic\";\n * manufacturer: string;\n * warrantyEndDate: string;\n * } | {\n * id: number;\n * name: string;\n * __typename: \"CartoonCharacter\";\n * animator: string;\n * voiceActor: string;\n * }\n * ```\n */\ntype ExtractByMatchingTypeNames<\n Union extends { __typename?: string },\n TypeName extends string,\n> = Union extends any ?\n TypeName extends NonNullable<Union[\"__typename\"]> ?\n Omit<Union, \"__typename\"> & {\n // preserve `?`, which `& { __typename: TypeName }` would not do\n [K in keyof Union as K extends \"__typename\" ? K : never]: TypeName;\n }\n : never\n: never;\n\ntype MergeUnions<TUnion> = MergeUnionsAcc<\n TUnion,\n takeOneFromUnion<TUnion>,\n never\n>;\n\ntype DistributedRequiredExclude<T, U> =\n T extends any ?\n Required<T> extends Required<U> ?\n Required<U> extends Required<T> ?\n never\n : T\n : T\n : T;\n\ntype MergeUnionsAcc<TUnion, Curr, Merged> =\n [Curr] extends [never] ? Merged\n : MergeUnionsAcc<\n DistributedRequiredExclude<TUnion, Curr>,\n takeOneFromUnion<DistributedRequiredExclude<TUnion, Curr>>,\n [Merged] extends [never] ? Curr : MergeObjects<Curr, Merged>\n >;\ntype unionToIntersection<T> =\n (T extends unknown ? (x: T) => unknown : never) extends (\n (x: infer U) => unknown\n ) ?\n U\n : never;\n\ntype takeOneFromUnion<T> =\n unionToIntersection<T extends T ? (x: T) => 0 : never> extends (\n (x: infer U) => 0\n ) ?\n U\n : never;\n\ntype MergeObjects<T, U> = Prettify<\n {\n [k in keyof T]: k extends keyof U ?\n [NonNullable<T[k]>, NonNullable<U[k]>] extends (\n [infer TK extends object, infer UK extends object]\n ) ?\n TK extends unknown[] ?\n UK extends unknown[] ?\n | CombineIntersection<TK[number] | UK[number]>[]\n | Extract<T[k] | U[k], undefined | null>\n : T[k]\n : CombineIntersection<TK | UK> | Extract<T[k] | U[k], undefined | null>\n : T[k]\n : T[k];\n } & Pick<U, Exclude<keyof U, keyof T>>\n>;\n\n// force
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/masking/internal/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n IsAny,\n Prettify,\n Primitive,\n RemoveIndexSignature,\n} from \"@apollo/client/utilities/internal\";\n\nexport type UnwrapFragmentRefs<TData> =\n true extends IsAny<TData> ? TData\n : TData extends any ?\n // Ensure tagged/branded types are left alone (i.e. type UUID = string & { ... })\n TData extends Primitive ? TData\n : // Leave TData alone if it is Record<string, any> and not a specific shape\n string extends keyof TData ? TData\n : // short-circuit on empty object\n keyof TData extends never ? TData\n : TData extends { \" $fragmentRefs\"?: infer FragmentRefs } ?\n UnwrapFragmentRefs<\n CombineIntersection<\n | Omit<TData, \" $fragmentRefs\">\n | RemoveFragmentName<\n NonNullable<\n NonNullable<FragmentRefs>[keyof NonNullable<FragmentRefs>]\n >\n >\n >\n >\n : TData extends object ?\n {\n [K in keyof TData]: UnwrapFragmentRefs<TData[K]>;\n }\n : TData\n : never;\n\n/**\n * ```ts\n * CombineIntersection<\n * | { foo: string }\n * | { __typename: \"A\"; a: string }\n * | { __typename: \"B\"; b1: number }\n * | { __typename: \"B\"; b2: string }\n * > =>\n * | { foo: string }\n * | CombineByTypeName<\n * | { __typename: \"A\"; a: string }\n * | { __typename: \"B\"; b1: number }\n * | { __typename: \"B\"; b2: string }\n * >\n * ```\n */\ntype CombineIntersection<T> =\n | Exclude<T, { __typename?: string }>\n | CombineByTypeName<Extract<T, { __typename?: string }>>;\n/**\n * ```ts\n * CombineByTypeName<\n * | { __typename: \"A\"; a: string }\n * | { __typename: \"B\"; b1: number }\n * | { __typename: \"B\"; b2: string }\n * > =>\n * | CombineWithArrays<\n * | { __typename: \"A\"; a: string }\n * >\n * | CombineWithArrays<\n * | { __typename: \"B\"; b1: number }\n * | { __typename: \"B\"; b2: number }\n * >\n * ```\n */\ntype CombineByTypeName<T extends { __typename?: string }> = {\n [TypeName in NonNullable<T[\"__typename\"]>]: Prettify<\n MergeUnions<ExtractByMatchingTypeNames<T, TypeName>>\n >;\n}[NonNullable<T[\"__typename\"]>];\n\n/**\n * ```ts\n * CombineByTypeName<\n * | {\n * __typename: \"Person\" | \"Animatronic\" | \"CartoonCharacter\";\n * id: number;\n * name: string;\n * }\n * | {\n * __typename: \"Person\";\n * birthdate: string;\n * }\n * | {\n * __typename: \"Animatronic\";\n * manufacturer: string;\n * warrantyEndDate: string;\n * }\n * | {\n * __typename: \"CartoonCharacter\";\n * animator: string;\n * voiceActor: string;\n * }\n * >\n * =>\n * {\n * id: number;\n * name: string;\n * __typename: \"Person\";\n * birthdate: string;\n * } | {\n * id: number;\n * name: string;\n * __typename: \"Animatronic\";\n * manufacturer: string;\n * warrantyEndDate: string;\n * } | {\n * id: number;\n * name: string;\n * __typename: \"CartoonCharacter\";\n * animator: string;\n * voiceActor: string;\n * }\n * ```\n */\ntype ExtractByMatchingTypeNames<\n Union extends { __typename?: string },\n TypeName extends string,\n> = Union extends any ?\n TypeName extends NonNullable<Union[\"__typename\"]> ?\n Omit<Union, \"__typename\"> & {\n // preserve `?`, which `& { __typename: TypeName }` would not do\n [K in keyof Union as K extends \"__typename\" ? K : never]: TypeName;\n }\n : never\n: never;\n\ntype MergeUnions<TUnion> = MergeUnionsAcc<\n TUnion,\n takeOneFromUnion<TUnion>,\n never\n>;\n\ntype DistributedRequiredExclude<T, U> =\n T extends any ?\n Required<T> extends Required<U> ?\n Required<U> extends Required<T> ?\n never\n : T\n : T\n : T;\n\ntype MergeUnionsAcc<TUnion, Curr, Merged> =\n [Curr] extends [never] ? Merged\n : MergeUnionsAcc<\n DistributedRequiredExclude<TUnion, Curr>,\n takeOneFromUnion<DistributedRequiredExclude<TUnion, Curr>>,\n [Merged] extends [never] ? Curr : MergeObjects<Curr, Merged>\n >;\ntype unionToIntersection<T> =\n (T extends unknown ? (x: T) => unknown : never) extends (\n (x: infer U) => unknown\n ) ?\n U\n : never;\n\ntype takeOneFromUnion<T> =\n unionToIntersection<T extends T ? (x: T) => 0 : never> extends (\n (x: infer U) => 0\n ) ?\n U\n : never;\n\ntype MergeObjects<T, U> = Prettify<\n {\n [k in keyof T]: k extends keyof U ?\n [NonNullable<T[k]>, NonNullable<U[k]>] extends (\n [infer TK extends object, infer UK extends object]\n ) ?\n TK extends unknown[] ?\n UK extends unknown[] ?\n | CombineIntersection<TK[number] | UK[number]>[]\n | Extract<T[k] | U[k], undefined | null>\n : T[k]\n : CombineIntersection<TK | UK> | Extract<T[k] | U[k], undefined | null>\n : T[k]\n : T[k];\n } & Pick<U, Exclude<keyof U, keyof T>>\n>;\n\n// force distribution when T is a union with | undefined\nexport type RemoveFragmentName<T> =\n T extends any ? Omit<T, \" $fragmentName\"> : T;\n\ntype Exact<in out T> = (x: T) => T;\nexport type ContainsFragmentsRefs<TData, Seen = never> = true extends (\n IsAny<TData>\n) ?\n false\n: TData extends object ?\n Exact<TData> extends Seen ? false\n : \" $fragmentRefs\" extends keyof RemoveIndexSignature<TData> ? true\n : ContainsFragmentsRefs<TData[keyof TData], Seen | Exact<TData>>\n: false;\n"]}
|
|
@@ -39,7 +39,7 @@ function maskSelectionSet(data, selectionSet, context, migration, path) {
|
|
|
39
39
|
}
|
|
40
40
|
for (const selection of selectionSet.selections) {
|
|
41
41
|
let value;
|
|
42
|
-
// we later want to add
|
|
42
|
+
// we later want to add accessor warnings to the final result
|
|
43
43
|
// so we need a new object to add the accessor warning to
|
|
44
44
|
if (migration) {
|
|
45
45
|
knownChanged.add(memo);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maskDefinition.js","sources":["../../src/masking/maskDefinition.ts"],"sourcesContent":["import type { FragmentDefinitionNode, SelectionSetNode } from \"graphql\";\nimport { Kind } from \"graphql\";\n\nimport type { ApolloCache } from \"@apollo/client/cache\";\nimport { __DEV__ } from \"@apollo/client/utilities/environment\";\nimport type { FragmentMap } from \"@apollo/client/utilities/internal\";\nimport {\n maybeDeepFreeze,\n resultKeyNameFromField,\n} from \"@apollo/client/utilities/internal\";\nimport { invariant } from \"@apollo/client/utilities/invariant\";\n\nimport { disableWarningsSlot, getFragmentMaskMode } from \"./utils.js\";\n\ninterface MaskingContext {\n operationType: \"query\" | \"mutation\" | \"subscription\" | \"fragment\";\n operationName: string | undefined;\n fragmentMap: FragmentMap;\n cache: ApolloCache;\n mutableTargets: WeakMap<any, any>;\n knownChanged: WeakSet<any>;\n}\n\nexport function maskDefinition(\n data: Record<string, any>,\n selectionSet: SelectionSetNode,\n context: MaskingContext\n) {\n return disableWarningsSlot.withValue(true, () => {\n const masked = maskSelectionSet(data, selectionSet, context, false);\n\n if (Object.isFrozen(data)) {\n maybeDeepFreeze(masked);\n }\n return masked;\n });\n}\n\nfunction getMutableTarget(\n data: Record<string, any>,\n mutableTargets: WeakMap<any, any>\n): typeof data {\n if (mutableTargets.has(data)) {\n return mutableTargets.get(data);\n }\n\n const mutableTarget = Array.isArray(data) ? [] : {};\n mutableTargets.set(data, mutableTarget);\n return mutableTarget;\n}\n\nfunction maskSelectionSet(\n data: any,\n selectionSet: SelectionSetNode,\n context: MaskingContext,\n migration: boolean,\n path?: string | undefined\n): typeof data {\n const { knownChanged } = context;\n const memo = getMutableTarget(data, context.mutableTargets);\n\n if (Array.isArray(data)) {\n for (const [index, item] of Array.from(data.entries())) {\n if (item === null) {\n memo[index] = null;\n continue;\n }\n\n const masked = maskSelectionSet(\n item,\n selectionSet,\n context,\n migration,\n __DEV__ ? `${path || \"\"}[${index}]` : void 0\n );\n if (knownChanged.has(masked)) {\n knownChanged.add(memo);\n }\n\n memo[index] = masked;\n }\n\n return knownChanged.has(memo) ? memo : data;\n }\n\n for (const selection of selectionSet.selections) {\n let value: any;\n\n // we later want to add acessor warnings to the final result\n // so we need a new object to add the accessor warning to\n if (migration) {\n knownChanged.add(memo);\n }\n\n if (selection.kind === Kind.FIELD) {\n const keyName = resultKeyNameFromField(selection);\n const childSelectionSet = selection.selectionSet;\n\n value = memo[keyName] || data[keyName];\n\n if (value === void 0) {\n continue;\n }\n\n if (childSelectionSet && value !== null) {\n const masked = maskSelectionSet(\n data[keyName],\n childSelectionSet,\n context,\n migration,\n __DEV__ ? `${path || \"\"}.${keyName}` : void 0\n );\n\n if (knownChanged.has(masked)) {\n value = masked;\n }\n }\n\n if (!__DEV__) {\n memo[keyName] = value;\n }\n if (__DEV__) {\n if (\n migration &&\n keyName !== \"__typename\" &&\n // either the field is not present in the memo object\n // or it has a `get` descriptor, not a `value` descriptor\n // => it is a warning accessor and we can overwrite it\n // with another accessor\n !Object.getOwnPropertyDescriptor(memo, keyName)?.value\n ) {\n Object.defineProperty(\n memo,\n keyName,\n getAccessorWarningDescriptor(\n keyName,\n value,\n path || \"\",\n context.operationName,\n context.operationType\n )\n );\n } else {\n delete memo[keyName];\n memo[keyName] = value;\n }\n }\n }\n\n if (\n selection.kind === Kind.INLINE_FRAGMENT &&\n (!selection.typeCondition ||\n context.cache.fragmentMatches(selection, data.__typename))\n ) {\n value = maskSelectionSet(\n data,\n selection.selectionSet,\n context,\n migration,\n path\n );\n }\n\n if (selection.kind === Kind.FRAGMENT_SPREAD) {\n const fragmentName = selection.name.value;\n const fragment: FragmentDefinitionNode | null =\n context.fragmentMap[fragmentName] ||\n (context.fragmentMap[fragmentName] =\n context.cache.lookupFragment(fragmentName)!);\n invariant(\n fragment,\n \"Could not find fragment with name '%s'.\",\n fragmentName\n );\n\n const mode = getFragmentMaskMode(selection);\n\n if (mode !== \"mask\") {\n value = maskSelectionSet(\n data,\n fragment.selectionSet,\n context,\n mode === \"migrate\",\n path\n );\n }\n }\n\n if (knownChanged.has(value)) {\n knownChanged.add(memo);\n }\n }\n\n if (\"__typename\" in data && !(\"__typename\" in memo)) {\n memo.__typename = data.__typename;\n }\n\n // This check prevents cases where masked fields may accidentally be\n // returned as part of this object when the fragment also selects\n // additional fields from the same child selection.\n if (Object.keys(memo).length !== Object.keys(data).length) {\n knownChanged.add(memo);\n }\n\n return knownChanged.has(memo) ? memo : data;\n}\n\nfunction getAccessorWarningDescriptor(\n fieldName: string,\n value: any,\n path: string,\n operationName: string | undefined,\n operationType: string\n): PropertyDescriptor {\n let getValue = () => {\n if (disableWarningsSlot.getValue()) {\n return value;\n }\n\n invariant.warn(\n \"Accessing unmasked field on %s at path '%s'. This field will not be available when masking is enabled. Please read the field from the fragment instead.\",\n operationName ?\n `${operationType} '${operationName}'`\n : `anonymous ${operationType}`,\n `${path}.${fieldName}`.replace(/^\\./, \"\")\n );\n\n getValue = () => value;\n\n return value;\n };\n\n return {\n get() {\n return getValue();\n },\n set(newValue) {\n getValue = () => newValue;\n },\n enumerable: true,\n configurable: true,\n };\n}\n"],"names":[],"mappings":"AACA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAO,EAAE,CAAT,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,EAAqB,CAArB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA8B;AAG9B,CAAA,CAAA,CAAA,CAAA,CAAA,EAAO,EAAE,CAAT,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,EAAwB,CAAxB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA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AA,CAAA,CAAsB;IACtB,CAAG;AACH;"}
|
|
1
|
+
{"version":3,"file":"maskDefinition.js","sources":["../../src/masking/maskDefinition.ts"],"sourcesContent":["import type { FragmentDefinitionNode, SelectionSetNode } from \"graphql\";\nimport { Kind } from \"graphql\";\n\nimport type { ApolloCache } from \"@apollo/client/cache\";\nimport { __DEV__ } from \"@apollo/client/utilities/environment\";\nimport type { FragmentMap } from \"@apollo/client/utilities/internal\";\nimport {\n maybeDeepFreeze,\n resultKeyNameFromField,\n} from \"@apollo/client/utilities/internal\";\nimport { invariant } from \"@apollo/client/utilities/invariant\";\n\nimport { disableWarningsSlot, getFragmentMaskMode } from \"./utils.js\";\n\ninterface MaskingContext {\n operationType: \"query\" | \"mutation\" | \"subscription\" | \"fragment\";\n operationName: string | undefined;\n fragmentMap: FragmentMap;\n cache: ApolloCache;\n mutableTargets: WeakMap<any, any>;\n knownChanged: WeakSet<any>;\n}\n\nexport function maskDefinition(\n data: Record<string, any>,\n selectionSet: SelectionSetNode,\n context: MaskingContext\n) {\n return disableWarningsSlot.withValue(true, () => {\n const masked = maskSelectionSet(data, selectionSet, context, false);\n\n if (Object.isFrozen(data)) {\n maybeDeepFreeze(masked);\n }\n return masked;\n });\n}\n\nfunction getMutableTarget(\n data: Record<string, any>,\n mutableTargets: WeakMap<any, any>\n): typeof data {\n if (mutableTargets.has(data)) {\n return mutableTargets.get(data);\n }\n\n const mutableTarget = Array.isArray(data) ? [] : {};\n mutableTargets.set(data, mutableTarget);\n return mutableTarget;\n}\n\nfunction maskSelectionSet(\n data: any,\n selectionSet: SelectionSetNode,\n context: MaskingContext,\n migration: boolean,\n path?: string | undefined\n): typeof data {\n const { knownChanged } = context;\n const memo = getMutableTarget(data, context.mutableTargets);\n\n if (Array.isArray(data)) {\n for (const [index, item] of Array.from(data.entries())) {\n if (item === null) {\n memo[index] = null;\n continue;\n }\n\n const masked = maskSelectionSet(\n item,\n selectionSet,\n context,\n migration,\n __DEV__ ? `${path || \"\"}[${index}]` : void 0\n );\n if (knownChanged.has(masked)) {\n knownChanged.add(memo);\n }\n\n memo[index] = masked;\n }\n\n return knownChanged.has(memo) ? memo : data;\n }\n\n for (const selection of selectionSet.selections) {\n let value: any;\n\n // we later want to add accessor warnings to the final result\n // so we need a new object to add the accessor warning to\n if (migration) {\n knownChanged.add(memo);\n }\n\n if (selection.kind === Kind.FIELD) {\n const keyName = resultKeyNameFromField(selection);\n const childSelectionSet = selection.selectionSet;\n\n value = memo[keyName] || data[keyName];\n\n if (value === void 0) {\n continue;\n }\n\n if (childSelectionSet && value !== null) {\n const masked = maskSelectionSet(\n data[keyName],\n childSelectionSet,\n context,\n migration,\n __DEV__ ? `${path || \"\"}.${keyName}` : void 0\n );\n\n if (knownChanged.has(masked)) {\n value = masked;\n }\n }\n\n if (!__DEV__) {\n memo[keyName] = value;\n }\n if (__DEV__) {\n if (\n migration &&\n keyName !== \"__typename\" &&\n // either the field is not present in the memo object\n // or it has a `get` descriptor, not a `value` descriptor\n // => it is a warning accessor and we can overwrite it\n // with another accessor\n !Object.getOwnPropertyDescriptor(memo, keyName)?.value\n ) {\n Object.defineProperty(\n memo,\n keyName,\n getAccessorWarningDescriptor(\n keyName,\n value,\n path || \"\",\n context.operationName,\n context.operationType\n )\n );\n } else {\n delete memo[keyName];\n memo[keyName] = value;\n }\n }\n }\n\n if (\n selection.kind === Kind.INLINE_FRAGMENT &&\n (!selection.typeCondition ||\n context.cache.fragmentMatches(selection, data.__typename))\n ) {\n value = maskSelectionSet(\n data,\n selection.selectionSet,\n context,\n migration,\n path\n );\n }\n\n if (selection.kind === Kind.FRAGMENT_SPREAD) {\n const fragmentName = selection.name.value;\n const fragment: FragmentDefinitionNode | null =\n context.fragmentMap[fragmentName] ||\n (context.fragmentMap[fragmentName] =\n context.cache.lookupFragment(fragmentName)!);\n invariant(\n fragment,\n \"Could not find fragment with name '%s'.\",\n fragmentName\n );\n\n const mode = getFragmentMaskMode(selection);\n\n if (mode !== \"mask\") {\n value = maskSelectionSet(\n data,\n fragment.selectionSet,\n context,\n mode === \"migrate\",\n path\n );\n }\n }\n\n if (knownChanged.has(value)) {\n knownChanged.add(memo);\n }\n }\n\n if (\"__typename\" in data && !(\"__typename\" in memo)) {\n memo.__typename = data.__typename;\n }\n\n // This check prevents cases where masked fields may accidentally be\n // returned as part of this object when the fragment also selects\n // additional fields from the same child selection.\n if (Object.keys(memo).length !== Object.keys(data).length) {\n knownChanged.add(memo);\n }\n\n return knownChanged.has(memo) ? memo : data;\n}\n\nfunction getAccessorWarningDescriptor(\n fieldName: string,\n value: any,\n path: string,\n operationName: string | undefined,\n operationType: string\n): PropertyDescriptor {\n let getValue = () => {\n if (disableWarningsSlot.getValue()) {\n return value;\n }\n\n invariant.warn(\n \"Accessing unmasked field on %s at path '%s'. This field will not be available when masking is enabled. Please read the field from the fragment instead.\",\n operationName ?\n `${operationType} '${operationName}'`\n : `anonymous ${operationType}`,\n `${path}.${fieldName}`.replace(/^\\./, \"\")\n );\n\n getValue = () => value;\n\n return value;\n };\n\n return {\n get() {\n return getValue();\n },\n set(newValue) {\n getValue = () => newValue;\n },\n enumerable: true,\n configurable: true,\n };\n}\n"],"names":[],"mappings":"AACA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAO,EAAE,CAAT,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,EAAqB,CAArB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA8B;AAG9B,CAAA,CAAA,CAAA,CAAA,CAAA,EAAO,EAAE,CAAT,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,EAAwB,CAAxB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,C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;"}
|
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { useDeepMemo } from "./useDeepMemo.js";
|
|
2
2
|
export { useRenderGuard } from "./useRenderGuard.js";
|
|
3
|
+
export { useSuspenseHookCacheKey } from "./useSuspenseHookCacheKey.js";
|
|
3
4
|
export { __use } from "./__use.js";
|
|
4
5
|
export { wrapHook } from "./wrapHook.js";
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// These hooks are used internally and are not exported publicly by the library
|
|
2
2
|
export { useDeepMemo } from "./useDeepMemo.js";
|
|
3
3
|
export { useRenderGuard } from "./useRenderGuard.js";
|
|
4
|
+
export { useSuspenseHookCacheKey } from "./useSuspenseHookCacheKey.js";
|
|
4
5
|
export { __use } from "./__use.js";
|
|
5
6
|
export { wrapHook } from "./wrapHook.js";
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/react/hooks/internal/index.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC","sourcesContent":["// These hooks are used internally and are not exported publicly by the library\nexport { useDeepMemo } from \"./useDeepMemo.js\";\nexport { useRenderGuard } from \"./useRenderGuard.js\";\nexport { __use } from \"./__use.js\";\nexport { wrapHook } from \"./wrapHook.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/react/hooks/internal/index.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC","sourcesContent":["// These hooks are used internally and are not exported publicly by the library\nexport { useDeepMemo } from \"./useDeepMemo.js\";\nexport { useRenderGuard } from \"./useRenderGuard.js\";\nexport { useSuspenseHookCacheKey } from \"./useSuspenseHookCacheKey.js\";\nexport { __use } from \"./__use.js\";\nexport { wrapHook } from \"./wrapHook.js\";\n"]}
|
|
@@ -3,7 +3,7 @@ let Ctx;
|
|
|
3
3
|
function noop() { }
|
|
4
4
|
export function useRenderGuard() {
|
|
5
5
|
if (!Ctx) {
|
|
6
|
-
// we want the
|
|
6
|
+
// we want the initialization to be lazy because `createContext` would error on import in a RSC
|
|
7
7
|
Ctx = React.createContext(null);
|
|
8
8
|
}
|
|
9
9
|
return React.useCallback(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRenderGuard.js","sourceRoot":"","sources":["../../../../src/react/hooks/internal/useRenderGuard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,IAAI,GAAwB,CAAC;AAE7B,SAAS,IAAI,KAAI,CAAC;AAClB,MAAM,UAAU,cAAc;IAC5B,IAAI,CAAC,GAAG,EAAE,CAAC;QACT
|
|
1
|
+
{"version":3,"file":"useRenderGuard.js","sourceRoot":"","sources":["../../../../src/react/hooks/internal/useRenderGuard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,IAAI,GAAwB,CAAC;AAE7B,SAAS,IAAI,KAAI,CAAC;AAClB,MAAM,UAAU,cAAc;IAC5B,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,+FAA+F;QAC/F,GAAG,GAAG,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;IAED,OAAO,KAAK,CAAC,WAAW;IACtB;;OAEG,CAAC,GAAG,EAAE;QACP,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC;YACH,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;YAErB;;;;;;;;;;;;;;eAcG;YACH,KAAK,CAAC,YAAY,CAAC,+BAA+B,CAAC,CAAC,GAAG,CAAC,CAAC;YACzD,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,KAAK,CAAC;QACf,CAAC;gBAAS,CAAC;YACT,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;QACvB,CAAC;IACH,CAAC,EACD,EAAE,CACH,CAAC;AACJ,CAAC","sourcesContent":["import * as React from \"react\";\n\nlet Ctx: React.Context<null>;\n\nfunction noop() {}\nexport function useRenderGuard() {\n if (!Ctx) {\n // we want the initialization to be lazy because `createContext` would error on import in a RSC\n Ctx = React.createContext(null);\n }\n\n return React.useCallback(\n /**\n * @returns true if the hook was called during render\n */ () => {\n const orig = console.error;\n try {\n console.error = noop;\n\n /**\n * `useContext` can be called conditionally during render, so this is safe.\n * (Also, during render we would want to throw as a reaction to this anyways, so it\n * wouldn't even matter if we got the order of hooks mixed up...)\n *\n * They cannot however be called outside of Render, and that's what we're testing here.\n *\n * Different versions of React have different behaviour on an invalid hook call:\n *\n * React 16.8 - 17: throws an error\n * https://github.com/facebook/react/blob/2b93d686e359c7afa299e2ec5cf63160a32a1155/packages/react/src/ReactHooks.js#L18-L26\n *\n * React 18 & 19: `console.error` in development, then `resolveDispatcher` returns `null` and a member access on `null` throws.\n * https://github.com/facebook/react/blob/58e8304483ebfadd02a295339b5e9a989ac98c6e/packages/react/src/ReactHooks.js#L28-L35\n */\n React[\"useContext\" /* hide this from the linter */](Ctx);\n return true;\n } catch (e) {\n return false;\n } finally {\n console.error = orig;\n }\n },\n []\n );\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DocumentNode } from "graphql";
|
|
2
|
+
import type { OperationVariables } from "@apollo/client";
|
|
3
|
+
import type { SkipToken } from "../constants.js";
|
|
4
|
+
export declare namespace useSuspenseHookCacheKey {
|
|
5
|
+
interface Options {
|
|
6
|
+
variables?: OperationVariables;
|
|
7
|
+
queryKey?: string | number | any[];
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export declare function useSuspenseHookCacheKey(query: DocumentNode, options: (SkipToken & Partial<useSuspenseHookCacheKey.Options>) | useSuspenseHookCacheKey.Options): [DocumentNode, string, ...any[]];
|
|
11
|
+
//# sourceMappingURL=useSuspenseHookCacheKey.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { canonicalStringify } from "@apollo/client/utilities";
|
|
3
|
+
import { skipToken } from "../constants.js";
|
|
4
|
+
export function useSuspenseHookCacheKey(query, options) {
|
|
5
|
+
const { queryKey = [], variables } = options;
|
|
6
|
+
const canonicalVariables = canonicalStringify(variables);
|
|
7
|
+
// This state value let's us maintain the variables used for the cache key
|
|
8
|
+
// when `skipToken` is used to skip a query after its been executed.
|
|
9
|
+
// Since options aren't provided when using `skipToken`, `variables` would
|
|
10
|
+
// otherwise disappear which means we'd return a new cache key without a
|
|
11
|
+
// variables value which creates a new `ObservableQuery` instance. This was
|
|
12
|
+
// particularly problematic when `refetchQueries` was used because it meant
|
|
13
|
+
// refetching against an `ObservableQuery` instance that had no variables.
|
|
14
|
+
let [cacheKeyVariables, setCacheKeyVariables] = React.useState(canonicalVariables);
|
|
15
|
+
if (options !== skipToken && cacheKeyVariables !== canonicalVariables) {
|
|
16
|
+
setCacheKeyVariables((cacheKeyVariables = canonicalVariables));
|
|
17
|
+
}
|
|
18
|
+
return [
|
|
19
|
+
query,
|
|
20
|
+
cacheKeyVariables,
|
|
21
|
+
...[].concat(queryKey),
|
|
22
|
+
];
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=useSuspenseHookCacheKey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSuspenseHookCacheKey.js","sourceRoot":"","sources":["../../../../src/react/hooks/internal/useSuspenseHookCacheKey.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAG9D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAS5C,MAAM,UAAU,uBAAuB,CACrC,KAAmB,EACnB,OAEmC;IAEnC,MAAM,EAAE,QAAQ,GAAG,EAAE,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC7C,MAAM,kBAAkB,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAEzD,0EAA0E;IAC1E,oEAAoE;IACpE,0EAA0E;IAC1E,wEAAwE;IACxE,2EAA2E;IAC3E,2EAA2E;IAC3E,0EAA0E;IAC1E,IAAI,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,GAC3C,KAAK,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;IAErC,IAAI,OAAO,KAAK,SAAS,IAAI,iBAAiB,KAAK,kBAAkB,EAAE,CAAC;QACtE,oBAAoB,CAAC,CAAC,iBAAiB,GAAG,kBAAkB,CAAC,CAAC,CAAC;IACjE,CAAC;IAED,OAAO;QACL,KAAK;QACL,iBAAiB;QACjB,GAAI,EAAY,CAAC,MAAM,CAAC,QAAQ,CAAC;KACf,CAAC;AACvB,CAAC","sourcesContent":["import type { DocumentNode } from \"graphql\";\nimport * as React from \"react\";\n\nimport type { OperationVariables } from \"@apollo/client\";\nimport type { CacheKey } from \"@apollo/client/react/internal\";\nimport { canonicalStringify } from \"@apollo/client/utilities\";\n\nimport type { SkipToken } from \"../constants.js\";\nimport { skipToken } from \"../constants.js\";\n\nexport declare namespace useSuspenseHookCacheKey {\n export interface Options {\n variables?: OperationVariables;\n queryKey?: string | number | any[];\n }\n}\n\nexport function useSuspenseHookCacheKey(\n query: DocumentNode,\n options:\n | (SkipToken & Partial<useSuspenseHookCacheKey.Options>)\n | useSuspenseHookCacheKey.Options\n) {\n const { queryKey = [], variables } = options;\n const canonicalVariables = canonicalStringify(variables);\n\n // This state value let's us maintain the variables used for the cache key\n // when `skipToken` is used to skip a query after its been executed.\n // Since options aren't provided when using `skipToken`, `variables` would\n // otherwise disappear which means we'd return a new cache key without a\n // variables value which creates a new `ObservableQuery` instance. This was\n // particularly problematic when `refetchQueries` was used because it meant\n // refetching against an `ObservableQuery` instance that had no variables.\n let [cacheKeyVariables, setCacheKeyVariables] =\n React.useState(canonicalVariables);\n\n if (options !== skipToken && cacheKeyVariables !== canonicalVariables) {\n setCacheKeyVariables((cacheKeyVariables = canonicalVariables));\n }\n\n return [\n query,\n cacheKeyVariables,\n ...([] as any[]).concat(queryKey),\n ] satisfies CacheKey;\n}\n"]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { canonicalStringify } from "@apollo/client/cache";
|
|
3
2
|
import { getSuspenseCache, unwrapQueryRef, updateWrappedQueryRef, wrapQueryRef, } from "@apollo/client/react/internal";
|
|
4
|
-
import { wrapHook } from "./internal/index.js";
|
|
3
|
+
import { useSuspenseHookCacheKey, wrapHook } from "./internal/index.js";
|
|
5
4
|
import { useApolloClient } from "./useApolloClient.js";
|
|
6
5
|
import { useWatchQueryOptions } from "./useSuspenseQuery.js";
|
|
7
6
|
export function useBackgroundQuery(query, options) {
|
|
@@ -14,8 +13,8 @@ function useBackgroundQuery_(query, options) {
|
|
|
14
13
|
const client = useApolloClient(options.client);
|
|
15
14
|
const suspenseCache = getSuspenseCache(client);
|
|
16
15
|
const watchQueryOptions = useWatchQueryOptions({ client, query, options });
|
|
17
|
-
const { fetchPolicy
|
|
18
|
-
const
|
|
16
|
+
const { fetchPolicy } = watchQueryOptions;
|
|
17
|
+
const cacheKey = useSuspenseHookCacheKey(query, options);
|
|
19
18
|
// This ref tracks the first time query execution is enabled to determine
|
|
20
19
|
// whether to return a query ref or `undefined`. When initialized
|
|
21
20
|
// in a skipped state (either via `skip: true` or `skipToken`) we return
|
|
@@ -24,11 +23,6 @@ function useBackgroundQuery_(query, options) {
|
|
|
24
23
|
// skipped again later.
|
|
25
24
|
const didFetchResult = React.useRef(fetchPolicy !== "standby");
|
|
26
25
|
didFetchResult.current ||= fetchPolicy !== "standby";
|
|
27
|
-
const cacheKey = [
|
|
28
|
-
query,
|
|
29
|
-
canonicalStringify(variables),
|
|
30
|
-
...[].concat(queryKey),
|
|
31
|
-
];
|
|
32
26
|
const queryRef = suspenseCache.getQueryRef(cacheKey, () => client.watchQuery(watchQueryOptions));
|
|
33
27
|
const [wrappedQueryRef, setWrappedQueryRef] = React.useState(wrapQueryRef(queryRef));
|
|
34
28
|
if (unwrapQueryRef(wrappedQueryRef) !== queryRef) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBackgroundQuery.js","sourceRoot":"","sources":["../../../src/react/hooks/useBackgroundQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAc/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAO1D,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,qBAAqB,EACrB,YAAY,GACb,MAAM,+BAA+B,CAAC;AAQvC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AA4X7D,MAAM,UAAU,kBAAkB,CAIhC,KAA0D,EAC1D,OAAqE;IAKrE,aAAa,CAAC;IACd,OAAO,QAAQ,CACb,oBAAoB;IACpB,yDAAyD;IACzD,mBAAmB,EACnB,eAAe,CAAC,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,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AC,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEzD,OAAO;QACL,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC;QACjD;YACE,SAAS;YACT,OAAO;YACP,kGAAkG;YAClG,eAAe,EAAE,QAAQ,CAAC,UAAU;iBACjC,eAA6D;SACjE;KACF,CAAC;AACJ,CAAC","sourcesContent":["import * as React from \"react\";\n\nimport type {\n ApolloClient,\n DataState,\n DefaultContext,\n DocumentNode,\n ErrorPolicy,\n OperationVariables,\n RefetchWritePolicy,\n TypedDocumentNode,\n WatchQueryFetchPolicy,\n} from \"@apollo/client\";\nimport type { SubscribeToMoreFunction } from \"@apollo/client\";\nimport { canonicalStringify } from \"@apollo/client/cache\";\nimport type { QueryRef } from \"@apollo/client/react\";\nimport type {\n CacheKey,\n FetchMoreFunction,\n RefetchFunction,\n} from \"@apollo/client/react/internal\";\nimport {\n getSuspenseCache,\n unwrapQueryRef,\n updateWrappedQueryRef,\n wrapQueryRef,\n} from \"@apollo/client/react/internal\";\nimport type {\n DocumentationTypes as UtilityDocumentationTypes,\n NoInfer,\n VariablesOption,\n} from \"@apollo/client/utilities/internal\";\n\nimport type { SkipToken } from \"./constants.js\";\nimport { wrapHook } from \"./internal/index.js\";\nimport { useApolloClient } from \"./useApolloClient.js\";\nimport { useWatchQueryOptions } from \"./useSuspenseQuery.js\";\n\nexport declare namespace useBackgroundQuery {\n import _self = useBackgroundQuery;\n export type FetchPolicy = Extract<\n WatchQueryFetchPolicy,\n \"cache-first\" | \"network-only\" | \"no-cache\" | \"cache-and-network\"\n >;\n\n export namespace Base {\n export interface Options {\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#client:member} */\n client?: ApolloClient;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#refetchWritePolicy_suspense:member} */\n refetchWritePolicy?: RefetchWritePolicy;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#errorPolicy:member} */\n errorPolicy?: ErrorPolicy;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#context:member} */\n context?: DefaultContext;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#returnPartialData:member} */\n returnPartialData?: boolean;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#fetchPolicy:member} */\n fetchPolicy?: FetchPolicy;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#queryKey:member} */\n queryKey?: string | number | any[];\n\n /**\n * {@inheritDoc @apollo/client!QueryOptionsDocumentation#skip_deprecated:member}\n *\n * @example Recommended usage of `skipToken`:\n *\n * ```ts\n * import { skipToken, useBackgroundQuery } from \"@apollo/client\";\n *\n * const [queryRef] = useBackgroundQuery(\n * query,\n * id ? { variables: { id } } : skipToken\n * );\n * ```\n */\n skip?: boolean;\n }\n }\n\n export type Options<\n TVariables extends OperationVariables = OperationVariables,\n > = Base.Options & VariablesOption<TVariables>;\n\n export namespace DocumentationTypes {\n namespace useBackgroundQuery {\n export interface Options<\n TVariables extends OperationVariables = OperationVariables,\n > extends Base.Options,\n UtilityDocumentationTypes.VariableOptions<TVariables> {}\n }\n }\n\n export interface Result<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n > {\n /** {@inheritDoc @apollo/client!ObservableQuery#subscribeToMore:member(1)} */\n subscribeToMore: SubscribeToMoreFunction<TData, TVariables>;\n\n /**\n * {@inheritDoc @apollo/client!ObservableQuery#fetchMore:member(1)}\n *\n * @remarks\n * Calling this function will cause the component to re-suspend, unless the call site is wrapped in [`startTransition`](https://react.dev/reference/react/startTransition).\n */\n fetchMore: FetchMoreFunction<TData, TVariables>;\n\n /**\n * {@inheritDoc @apollo/client!QueryResultDocumentation#refetch:member}\n *\n * @remarks\n * Calling this function will cause the component to re-suspend, unless the call site is wrapped in [`startTransition`](https://react.dev/reference/react/startTransition).\n */\n refetch: RefetchFunction<TData, TVariables>;\n }\n\n namespace DocumentationTypes {\n namespace useBackgroundQuery {\n export interface Result<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n > extends _self.Result<TData, TVariables> {}\n }\n }\n\n export namespace DocumentationTypes {\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery:function(1)} */\n export function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: SkipToken | useBackgroundQuery.Options<TVariables>\n ): [\n QueryRef<TData, TVariables> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n ];\n }\n}\n\n/**\n * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).\n *\n * @returns A tuple containing:\n *\n * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.\n * 2. An object containing helper functions for the query:\n * - `refetch`: A function to re-execute the query\n * - `fetchMore`: A function to fetch more results for pagination\n * - `subscribeToMore`: A function to subscribe to updates\n *\n * @example\n *\n * ```jsx\n * import { Suspense } from \"react\";\n * import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\";\n * import { useBackgroundQuery, useReadQuery } from \"@apollo/client/react\";\n *\n * const query = gql`\n * foo {\n * bar\n * }\n * `;\n *\n * const client = new ApolloClient({\n * link: new HttpLink({ uri: \"http://localhost:4000/graphql\" }),\n * cache: new InMemoryCache(),\n * });\n *\n * function SuspenseFallback() {\n * return <div>Loading...</div>;\n * }\n *\n * function Child({ queryRef }) {\n * const { data } = useReadQuery(queryRef);\n *\n * return <div>{data.foo.bar}</div>;\n * }\n *\n * function Parent() {\n * const [queryRef] = useBackgroundQuery(query);\n *\n * return (\n * <Suspense fallback={<SuspenseFallback />}>\n * <Child queryRef={queryRef} />\n * </Suspense>\n * );\n * }\n *\n * function App() {\n * return (\n * <ApolloProvider client={client}>\n * <Parent />\n * </ApolloProvider>\n * );\n * }\n * ```\n *\n * @param query - A GraphQL query document parsed into an AST by `gql`.\n * @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.\n */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n /** @deprecated `returnPartialData` has no effect on `no-cache` queries */\n returnPartialData: boolean;\n fetchPolicy: \"no-cache\";\n }\n): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\">,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\n/** {@inheritDoc @apollo/client/react!useBackgroundQuery:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: false;\n errorPolicy: \"ignore\" | \"all\";\n }\n): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"empty\">,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\n/** {@inheritDoc @apollo/client/react!useBackgroundQuery:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: boolean;\n errorPolicy: \"ignore\" | \"all\";\n }\n): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"partial\" | \"empty\">,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\n/** {@inheritDoc @apollo/client/react!useBackgroundQuery:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n errorPolicy: \"ignore\" | \"all\";\n }\n): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"empty\">,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\n/** {@inheritDoc @apollo/client/react!useBackgroundQuery:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n skip: boolean;\n returnPartialData: false;\n }\n): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\n/** {@inheritDoc @apollo/client/react!useBackgroundQuery:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n skip: boolean;\n returnPartialData: boolean;\n }\n): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"partial\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\n/** {@inheritDoc @apollo/client/react!useBackgroundQuery:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: false;\n }\n): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\">,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\n/** {@inheritDoc @apollo/client/react!useBackgroundQuery:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: boolean;\n }\n): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"partial\">,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\n/** {@inheritDoc @apollo/client/react!useBackgroundQuery:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n skip: boolean;\n }\n): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\n/** {@inheritDoc @apollo/client/react!useBackgroundQuery:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: SkipToken\n): [undefined, useBackgroundQuery.Result<TData, TVariables>];\n\n/** {@inheritDoc @apollo/client/react!useBackgroundQuery:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options:\n | SkipToken\n | (useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: false;\n })\n): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options:\n | SkipToken\n | (useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: boolean;\n })\n): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"partial\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n ...[options]: {} extends TVariables ?\n [options?: useBackgroundQuery.Options<NoInfer<TVariables>>]\n : [options: useBackgroundQuery.Options<NoInfer<TVariables>>]\n): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\">,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n ...[options]: {} extends TVariables ?\n [options?: SkipToken | useBackgroundQuery.Options<NoInfer<TVariables>>]\n : [options: SkipToken | useBackgroundQuery.Options<NoInfer<TVariables>>]\n): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: SkipToken | useBackgroundQuery.Options<NoInfer<TVariables>>\n): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options?: SkipToken | useBackgroundQuery.Options<NoInfer<TVariables>>\n): [\n QueryRef<TData, TVariables, DataState<TData>[\"dataState\"]> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n] {\n \"use no memo\";\n return wrapHook(\n \"useBackgroundQuery\",\n // eslint-disable-next-line react-compiler/react-compiler\n useBackgroundQuery_,\n useApolloClient(typeof options === \"object\" ? options.client : undefined)\n )(query, options ?? ({} as any));\n}\n\nfunction useBackgroundQuery_<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n TStates extends DataState<TData>[\"dataState\"] = DataState<TData>[\"dataState\"],\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options:\n | (SkipToken & Partial<useBackgroundQuery.Options<NoInfer<TVariables>>>)\n | useBackgroundQuery.Options<NoInfer<TVariables>>\n): [\n QueryRef<TData, TVariables, TStates> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n] {\n const client = useApolloClient(options.client);\n const suspenseCache = getSuspenseCache(client);\n const watchQueryOptions = useWatchQueryOptions({ client, query, options });\n const { fetchPolicy, variables } = watchQueryOptions;\n const { queryKey = [] } = options;\n\n // This ref tracks the first time query execution is enabled to determine\n // whether to return a query ref or `undefined`. When initialized\n // in a skipped state (either via `skip: true` or `skipToken`) we return\n // `undefined` for the `queryRef` until the query has been enabled. Once\n // enabled, a query ref is always returned regardless of whether the query is\n // skipped again later.\n const didFetchResult = React.useRef(fetchPolicy !== \"standby\");\n didFetchResult.current ||= fetchPolicy !== \"standby\";\n\n const cacheKey: CacheKey = [\n query,\n canonicalStringify(variables),\n ...([] as any[]).concat(queryKey),\n ];\n\n const queryRef = suspenseCache.getQueryRef<TData, TStates>(cacheKey, () =>\n client.watchQuery(\n watchQueryOptions as ApolloClient.WatchQueryOptions<any, any>\n )\n );\n\n const [wrappedQueryRef, setWrappedQueryRef] = React.useState(\n wrapQueryRef(queryRef)\n );\n if (unwrapQueryRef(wrappedQueryRef) !== queryRef) {\n setWrappedQueryRef(wrapQueryRef(queryRef));\n }\n if (queryRef.didChangeOptions(watchQueryOptions)) {\n const promise = queryRef.applyOptions(watchQueryOptions);\n updateWrappedQueryRef(wrappedQueryRef, promise);\n }\n\n // This prevents issues where rerendering useBackgroundQuery after the\n // queryRef has been disposed would cause the hook to return a new queryRef\n // instance since disposal also removes it from the suspense cache. We add\n // the queryRef back in the suspense cache so that the next render will reuse\n // this queryRef rather than initializing a new instance.\n React.useEffect(() => {\n // Since the queryRef is disposed async via `setTimeout`, we have to wait a\n // tick before checking it and adding back to the suspense cache.\n const id = setTimeout(() => {\n if (queryRef.disposed) {\n suspenseCache.add(cacheKey, queryRef);\n }\n });\n\n return () => clearTimeout(id);\n // Omitting the deps is intentional. This avoids stale closures and the\n // conditional ensures we aren't running the logic on each render.\n });\n\n const fetchMore: FetchMoreFunction<TData, TVariables> = React.useCallback(\n (options) => {\n const promise = queryRef.fetchMore(options);\n\n setWrappedQueryRef(wrapQueryRef(queryRef));\n\n return promise;\n },\n [queryRef]\n );\n\n const refetch: RefetchFunction<TData, TVariables> = React.useCallback(\n (variables) => {\n const promise = queryRef.refetch(variables);\n\n setWrappedQueryRef(wrapQueryRef(queryRef));\n\n return promise;\n },\n [queryRef]\n );\n\n React.useEffect(() => queryRef.softRetain(), [queryRef]);\n\n return [\n didFetchResult.current ? wrappedQueryRef : void 0,\n {\n fetchMore,\n refetch,\n // TODO: The internalQueryRef doesn't have TVariables' type information so we have to cast it here\n subscribeToMore: queryRef.observable\n .subscribeToMore as SubscribeToMoreFunction<TData, TVariables>,\n },\n ];\n}\n"]}
|
|
1
|
+
{"version":3,"file":"useBackgroundQuery.js","sourceRoot":"","sources":["../../../src/react/hooks/useBackgroundQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAmB/B,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,qBAAqB,EACrB,YAAY,GACb,MAAM,+BAA+B,CAAC;AAQvC,OAAO,EAAE,uBAAuB,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AA4X7D,MAAM,UAAU,kBAAkB,CAIhC,KAA0D,EAC1D,OAAqE;IAKrE,aAAa,CAAC;IACd,OAAO,QAAQ,CACb,oBAAoB;IACpB,yDAAyD;IACzD,mBAAmB,EACnB,eAAe,CAAC,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAC1E,CAAC,KAAK,EAAE,OAAO,IAAK,EAAU,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,mBAAmB,CAK1B,KAA0D,EAC1D,OAEmD;IAKnD,MAAM,MAAM,GAAG,eA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ApolloClient,\n DataState,\n DefaultContext,\n DocumentNode,\n ErrorPolicy,\n OperationVariables,\n RefetchWritePolicy,\n TypedDocumentNode,\n WatchQueryFetchPolicy,\n} from \"@apollo/client\";\nimport type { SubscribeToMoreFunction } from \"@apollo/client\";\nimport type { QueryRef } from \"@apollo/client/react\";\nimport type {\n FetchMoreFunction,\n RefetchFunction,\n} from \"@apollo/client/react/internal\";\nimport {\n getSuspenseCache,\n unwrapQueryRef,\n updateWrappedQueryRef,\n wrapQueryRef,\n} from \"@apollo/client/react/internal\";\nimport type {\n DocumentationTypes as UtilityDocumentationTypes,\n NoInfer,\n VariablesOption,\n} from \"@apollo/client/utilities/internal\";\n\nimport type { SkipToken } from \"./constants.js\";\nimport { useSuspenseHookCacheKey, wrapHook } from \"./internal/index.js\";\nimport { useApolloClient } from \"./useApolloClient.js\";\nimport { useWatchQueryOptions } from \"./useSuspenseQuery.js\";\n\nexport declare namespace useBackgroundQuery {\n import _self = useBackgroundQuery;\n export type FetchPolicy = Extract<\n WatchQueryFetchPolicy,\n \"cache-first\" | \"network-only\" | \"no-cache\" | \"cache-and-network\"\n >;\n\n export namespace Base {\n export interface Options {\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#client:member} */\n client?: ApolloClient;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#refetchWritePolicy_suspense:member} */\n refetchWritePolicy?: RefetchWritePolicy;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#errorPolicy:member} */\n errorPolicy?: ErrorPolicy;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#context:member} */\n context?: DefaultContext;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#returnPartialData:member} */\n returnPartialData?: boolean;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#fetchPolicy:member} */\n fetchPolicy?: FetchPolicy;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#queryKey:member} */\n queryKey?: string | number | any[];\n\n /**\n * {@inheritDoc @apollo/client!QueryOptionsDocumentation#skip_deprecated:member}\n *\n * @example Recommended usage of `skipToken`:\n *\n * ```ts\n * import { skipToken, useBackgroundQuery } from \"@apollo/client\";\n *\n * const [queryRef] = useBackgroundQuery(\n * query,\n * id ? { variables: { id } } : skipToken\n * );\n * ```\n */\n skip?: boolean;\n }\n }\n\n export type Options<\n TVariables extends OperationVariables = OperationVariables,\n > = Base.Options & VariablesOption<TVariables>;\n\n export namespace DocumentationTypes {\n namespace useBackgroundQuery {\n export interface Options<\n TVariables extends OperationVariables = OperationVariables,\n > extends Base.Options,\n UtilityDocumentationTypes.VariableOptions<TVariables> {}\n }\n }\n\n export interface Result<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n > {\n /** {@inheritDoc @apollo/client!ObservableQuery#subscribeToMore:member(1)} */\n subscribeToMore: SubscribeToMoreFunction<TData, TVariables>;\n\n /**\n * {@inheritDoc @apollo/client!ObservableQuery#fetchMore:member(1)}\n *\n * @remarks\n * Calling this function will cause the component to re-suspend, unless the call site is wrapped in [`startTransition`](https://react.dev/reference/react/startTransition).\n */\n fetchMore: FetchMoreFunction<TData, TVariables>;\n\n /**\n * {@inheritDoc @apollo/client!QueryResultDocumentation#refetch:member}\n *\n * @remarks\n * Calling this function will cause the component to re-suspend, unless the call site is wrapped in [`startTransition`](https://react.dev/reference/react/startTransition).\n */\n refetch: RefetchFunction<TData, TVariables>;\n }\n\n namespace DocumentationTypes {\n namespace useBackgroundQuery {\n export interface Result<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n > extends _self.Result<TData, TVariables> {}\n }\n }\n\n export namespace DocumentationTypes {\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery:function(1)} */\n export function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: SkipToken | useBackgroundQuery.Options<TVariables>\n ): [\n QueryRef<TData, TVariables> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n ];\n }\n}\n\n/**\n * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).\n *\n * @returns A tuple containing:\n *\n * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.\n * 2. An object containing helper functions for the query:\n * - `refetch`: A function to re-execute the query\n * - `fetchMore`: A function to fetch more results for pagination\n * - `subscribeToMore`: A function to subscribe to updates\n *\n * @example\n *\n * ```jsx\n * import { Suspense } from \"react\";\n * import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\";\n * import { useBackgroundQuery, useReadQuery } from \"@apollo/client/react\";\n *\n * const query = gql`\n * foo {\n * bar\n * }\n * `;\n *\n * const client = new ApolloClient({\n * link: new HttpLink({ uri: \"http://localhost:4000/graphql\" }),\n * cache: new InMemoryCache(),\n * });\n *\n * function SuspenseFallback() {\n * return <div>Loading...</div>;\n * }\n *\n * function Child({ queryRef }) {\n * const { data } = useReadQuery(queryRef);\n *\n * return <div>{data.foo.bar}</div>;\n * }\n *\n * function Parent() {\n * const [queryRef] = useBackgroundQuery(query);\n *\n * return (\n * <Suspense fallback={<SuspenseFallback />}>\n * <Child queryRef={queryRef} />\n * </Suspense>\n * );\n * }\n *\n * function App() {\n * return (\n * <ApolloProvider client={client}>\n * <Parent />\n * </ApolloProvider>\n * );\n * }\n * ```\n *\n * @param query - A GraphQL query document parsed into an AST by `gql`.\n * @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.\n */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n /** @deprecated `returnPartialData` has no effect on `no-cache` queries */\n returnPartialData: boolean;\n fetchPolicy: \"no-cache\";\n }\n): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\">,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\n/** {@inheritDoc @apollo/client/react!useBackgroundQuery:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: false;\n errorPolicy: \"ignore\" | \"all\";\n }\n): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"empty\">,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\n/** {@inheritDoc @apollo/client/react!useBackgroundQuery:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: boolean;\n errorPolicy: \"ignore\" | \"all\";\n }\n): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"partial\" | \"empty\">,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\n/** {@inheritDoc @apollo/client/react!useBackgroundQuery:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n errorPolicy: \"ignore\" | \"all\";\n }\n): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"empty\">,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\n/** {@inheritDoc @apollo/client/react!useBackgroundQuery:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n skip: boolean;\n returnPartialData: false;\n }\n): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\n/** {@inheritDoc @apollo/client/react!useBackgroundQuery:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n skip: boolean;\n returnPartialData: boolean;\n }\n): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"partial\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\n/** {@inheritDoc @apollo/client/react!useBackgroundQuery:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: false;\n }\n): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\">,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\n/** {@inheritDoc @apollo/client/react!useBackgroundQuery:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: boolean;\n }\n): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"partial\">,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\n/** {@inheritDoc @apollo/client/react!useBackgroundQuery:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n skip: boolean;\n }\n): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\n/** {@inheritDoc @apollo/client/react!useBackgroundQuery:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: SkipToken\n): [undefined, useBackgroundQuery.Result<TData, TVariables>];\n\n/** {@inheritDoc @apollo/client/react!useBackgroundQuery:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options:\n | SkipToken\n | (useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: false;\n })\n): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options:\n | SkipToken\n | (useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: boolean;\n })\n): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"partial\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n ...[options]: {} extends TVariables ?\n [options?: useBackgroundQuery.Options<NoInfer<TVariables>>]\n : [options: useBackgroundQuery.Options<NoInfer<TVariables>>]\n): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\">,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n ...[options]: {} extends TVariables ?\n [options?: SkipToken | useBackgroundQuery.Options<NoInfer<TVariables>>]\n : [options: SkipToken | useBackgroundQuery.Options<NoInfer<TVariables>>]\n): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: SkipToken | useBackgroundQuery.Options<NoInfer<TVariables>>\n): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options?: SkipToken | useBackgroundQuery.Options<NoInfer<TVariables>>\n): [\n QueryRef<TData, TVariables, DataState<TData>[\"dataState\"]> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n] {\n \"use no memo\";\n return wrapHook(\n \"useBackgroundQuery\",\n // eslint-disable-next-line react-compiler/react-compiler\n useBackgroundQuery_,\n useApolloClient(typeof options === \"object\" ? options.client : undefined)\n )(query, options ?? ({} as any));\n}\n\nfunction useBackgroundQuery_<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n TStates extends DataState<TData>[\"dataState\"] = DataState<TData>[\"dataState\"],\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options:\n | (SkipToken & Partial<useBackgroundQuery.Options<NoInfer<TVariables>>>)\n | useBackgroundQuery.Options<NoInfer<TVariables>>\n): [\n QueryRef<TData, TVariables, TStates> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n] {\n const client = useApolloClient(options.client);\n const suspenseCache = getSuspenseCache(client);\n const watchQueryOptions = useWatchQueryOptions({ client, query, options });\n const { fetchPolicy } = watchQueryOptions;\n const cacheKey = useSuspenseHookCacheKey(query, options);\n\n // This ref tracks the first time query execution is enabled to determine\n // whether to return a query ref or `undefined`. When initialized\n // in a skipped state (either via `skip: true` or `skipToken`) we return\n // `undefined` for the `queryRef` until the query has been enabled. Once\n // enabled, a query ref is always returned regardless of whether the query is\n // skipped again later.\n const didFetchResult = React.useRef(fetchPolicy !== \"standby\");\n didFetchResult.current ||= fetchPolicy !== \"standby\";\n\n const queryRef = suspenseCache.getQueryRef<TData, TStates>(cacheKey, () =>\n client.watchQuery(\n watchQueryOptions as ApolloClient.WatchQueryOptions<any, any>\n )\n );\n\n const [wrappedQueryRef, setWrappedQueryRef] = React.useState(\n wrapQueryRef(queryRef)\n );\n if (unwrapQueryRef(wrappedQueryRef) !== queryRef) {\n setWrappedQueryRef(wrapQueryRef(queryRef));\n }\n if (queryRef.didChangeOptions(watchQueryOptions)) {\n const promise = queryRef.applyOptions(watchQueryOptions);\n updateWrappedQueryRef(wrappedQueryRef, promise);\n }\n\n // This prevents issues where rerendering useBackgroundQuery after the\n // queryRef has been disposed would cause the hook to return a new queryRef\n // instance since disposal also removes it from the suspense cache. We add\n // the queryRef back in the suspense cache so that the next render will reuse\n // this queryRef rather than initializing a new instance.\n React.useEffect(() => {\n // Since the queryRef is disposed async via `setTimeout`, we have to wait a\n // tick before checking it and adding back to the suspense cache.\n const id = setTimeout(() => {\n if (queryRef.disposed) {\n suspenseCache.add(cacheKey, queryRef);\n }\n });\n\n return () => clearTimeout(id);\n // Omitting the deps is intentional. This avoids stale closures and the\n // conditional ensures we aren't running the logic on each render.\n });\n\n const fetchMore: FetchMoreFunction<TData, TVariables> = React.useCallback(\n (options) => {\n const promise = queryRef.fetchMore(options);\n\n setWrappedQueryRef(wrapQueryRef(queryRef));\n\n return promise;\n },\n [queryRef]\n );\n\n const refetch: RefetchFunction<TData, TVariables> = React.useCallback(\n (variables) => {\n const promise = queryRef.refetch(variables);\n\n setWrappedQueryRef(wrapQueryRef(queryRef));\n\n return promise;\n },\n [queryRef]\n );\n\n React.useEffect(() => queryRef.softRetain(), [queryRef]);\n\n return [\n didFetchResult.current ? wrappedQueryRef : void 0,\n {\n fetchMore,\n refetch,\n // TODO: The internalQueryRef doesn't have TVariables' type information so we have to cast it here\n subscribeToMore: queryRef.observable\n .subscribeToMore as SubscribeToMoreFunction<TData, TVariables>,\n },\n ];\n}\n"]}
|
|
@@ -20,7 +20,7 @@ function useFragment_(options) {
|
|
|
20
20
|
const client = useApolloClient(options.client);
|
|
21
21
|
const { cache } = client;
|
|
22
22
|
const { from, ...rest } = options;
|
|
23
|
-
// We calculate the cache id
|
|
23
|
+
// We calculate the cache id separately from `stableOptions` because we don't
|
|
24
24
|
// want changes to non key fields in the `from` property to affect
|
|
25
25
|
// `stableOptions` and retrigger our subscription. If the cache identifier
|
|
26
26
|
// stays the same between renders, we want to reuse the existing subscription.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFragment.js","sourceRoot":"","sources":["../../../src/react/hooks/useFragment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAmB/B,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AA4GjE;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAGzB,OAA+C;IAC/C,aAAa,CAAC;IACd,OAAO,QAAQ,CACb,aAAa;IACb,yDAAyD;IACzD,YAAY,EACZ,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,CAChC,CAAC,OAAO,CAAC,CAAC;AACb,CAAC;AAED,SAAS,YAAY,CACnB,OAA+C;IAE/C,MAAM,MAAM,GAAG,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/C,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;IACzB,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAElC,6EAA6E;IAC7E,kEAAkE;IAClE,0EAA0E;IAC1E,8EAA8E;IAC9E,MAAM,EAAE,GAAG,KAAK,CAAC,OAAO,CAC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C;AAED,SAAS,YAAY,CACnB,IAA6B;IAE7B,MAAM,MAAM,GAAG;QACb,IAAI,EAAE,IAAI,CAAC,MAAM;QACjB,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ;QACzB,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS;KACrB,CAAC,CAAC,uDAAuD;IAEvF,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QACjB,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IACxC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { equal } from \"@wry/equality\";\nimport * as React from \"react\";\n\nimport type {\n ApolloClient,\n DataValue,\n DocumentNode,\n GetDataState,\n OperationVariables,\n TypedDocumentNode,\n} from \"@apollo/client\";\nimport type {\n Cache,\n MissingTree,\n Reference,\n StoreObject,\n} from \"@apollo/client/cache\";\nimport type { FragmentType, MaybeMasked } from \"@apollo/client/masking\";\nimport type { NoInfer } from \"@apollo/client/utilities/internal\";\n\nimport { useDeepMemo, wrapHook } from \"./internal/index.js\";\nimport { useApolloClient } from \"./useApolloClient.js\";\nimport { useSyncExternalStore } from \"./useSyncExternalStore.js\";\n\nexport declare namespace useFragment {\n import _self = useFragment;\n export interface Options<TData, TVariables extends OperationVariables> {\n /**\n * A GraphQL document created using the `gql` template string tag from\n * `graphql-tag` with one or more fragments which will be used to determine\n * the shape of data to read. If you provide more than one fragment in this\n * document then you must also specify `fragmentName` to select a single.\n */\n fragment: DocumentNode | TypedDocumentNode<TData, TVariables>;\n\n /**\n * The name of the fragment in your GraphQL document to be used. If you do\n * not provide a `fragmentName` and there is only one fragment in your\n * `fragment` document then that fragment will be used.\n */\n fragmentName?: string;\n\n /**\n * Any variables that the GraphQL query may depend on.\n */\n variables?: NoInfer<TVariables>;\n\n /**\n * An object containing a `__typename` and primary key fields (such as `id`) identifying the entity object from which the fragment will be retrieved, or a `{ __ref: \"...\" }` reference, or a `string` ID (uncommon).\n */\n from:\n | StoreObject\n | Reference\n | FragmentType<NoInfer<TData>>\n | string\n | null;\n\n /**\n * Whether to read from optimistic or non-optimistic cache data. If\n * this named option is provided, the optimistic parameter of the\n * readQuery method can be omitted.\n *\n * @defaultValue true\n */\n optimistic?: boolean;\n\n /**\n * The instance of `ApolloClient` to use to look up the fragment.\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?: ApolloClient;\n }\n\n namespace DocumentationTypes {\n namespace useFragment {\n export interface Options<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n > extends _self.Options<TData, TVariables> {}\n }\n }\n\n // TODO: Update this to return `null` when there is no data returned from the\n // fragment.\n export type Result<TData> =\n | ({\n /** {@inheritDoc @apollo/client/react!useFragment.DocumentationTypes.useFragment.Result#complete:member} */\n complete: true;\n /** {@inheritDoc @apollo/client/react!useFragment.DocumentationTypes.useFragment.Result#missing:member} */\n missing?: never;\n } & GetDataState<MaybeMasked<TData>, \"complete\">)\n | ({\n /** {@inheritDoc @apollo/client/react!useFragment.DocumentationTypes.useFragment.Result#complete:member} */\n complete: false;\n /** {@inheritDoc @apollo/client/react!useFragment.DocumentationTypes.useFragment.Result#missing:member} */\n missing?: MissingTree;\n } & GetDataState<MaybeMasked<TData>, \"partial\">);\n\n export namespace DocumentationTypes {\n namespace useFragment {\n export interface Result<TData> {\n data: MaybeMasked<TData> | DataValue.Partial<MaybeMasked<TData>>;\n complete: boolean;\n /**\n * A tree of all `MissingFieldError` messages reported during fragment reading, where the branches of the tree indicate the paths of the errors within the query result.\n */\n missing?: MissingTree;\n }\n }\n }\n export namespace DocumentationTypes {\n /** {@inheritDoc @apollo/client/react!useFragment:function(1)} */\n export function useFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n >({\n fragment,\n from,\n fragmentName,\n variables,\n optimistic,\n client,\n }: useFragment.Options<TData, TVariables>): useFragment.Result<TData>;\n }\n}\n\n/**\n * `useFragment` represents a lightweight live binding into the Apollo Client Cache and enables Apollo Client to broadcast very specific fragment results to individual components. This hook returns an always-up-to-date view of whatever data the cache currently contains for a given fragment. `useFragment` never triggers network requests of its own.\n *\n * Note that the `useQuery` hook remains the primary hook responsible for querying and populating data in the cache ([see the API reference](./hooks#usequery)). As a result, the component reading the fragment data via `useFragment` is still subscribed to all changes in the query data, but receives updates only when that fragment's specific data change.\n *\n * To view a `useFragment` example, see the [Fragments](https://www.apollographql.com/docs/react/data/fragments#usefragment) page.\n */\nexport function useFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(options: useFragment.Options<TData, TVariables>): useFragment.Result<TData> {\n \"use no memo\";\n return wrapHook(\n \"useFragment\",\n // eslint-disable-next-line react-compiler/react-compiler\n useFragment_,\n useApolloClient(options.client)\n )(options);\n}\n\nfunction useFragment_<TData, TVariables extends OperationVariables>(\n options: useFragment.Options<TData, TVariables>\n): useFragment.Result<TData> {\n const client = useApolloClient(options.client);\n const { cache } = client;\n const { from, ...rest } = options;\n\n // We calculate the cache id seperately from `stableOptions` because we don't\n // want changes to non key fields in the `from` property to affect\n // `stableOptions` and retrigger our subscription. If the cache identifier\n // stays the same between renders, we want to reuse the existing subscription.\n const id = React.useMemo(\n () =>\n typeof from === \"string\" ? from\n : from === null ? null\n : cache.identify(from),\n [cache, from]\n );\n\n const stableOptions = useDeepMemo(() => ({ ...rest, from: id! }), [rest, id]);\n\n // Since .next is async, we need to make sure that we\n // get the correct diff on the next render given new diffOptions\n const diff = React.useMemo(() => {\n const { fragment, fragmentName, from, optimistic = true } = stableOptions;\n\n if (from === null) {\n return {\n result: diffToResult({\n result: {},\n complete: false,\n } as Cache.DiffResult<TData>),\n };\n }\n\n const { cache } = client;\n const diff = cache.diff<TData, TVariables>({\n ...stableOptions,\n returnPartialData: true,\n id: from,\n query: cache[\"getFragmentDoc\"](\n client[\"transform\"](fragment),\n fragmentName\n ),\n optimistic,\n });\n\n return {\n result: diffToResult<TData>({\n ...diff,\n result: client[\"queryManager\"].maskFragment({\n fragment,\n fragmentName,\n // TODO: Revert to `diff.result` once `useFragment` supports `null` as\n // valid return value\n data: diff.result === null ? {} : diff.result,\n }) as any,\n }),\n };\n }, [client, stableOptions]);\n\n // Used for both getSnapshot and getServerSnapshot\n const getSnapshot = React.useCallback(() => diff.result, [diff]);\n\n return useSyncExternalStore(\n React.useCallback(\n (forceUpdate) => {\n let lastTimeout = 0;\n\n const subscription =\n stableOptions.from === null ?\n null\n : client.watchFragment(stableOptions).subscribe({\n next: (result) => {\n // Avoid unnecessarily rerendering this hook for the initial result\n // emitted from watchFragment which should be equal to\n // `diff.result`.\n if (equal(result, diff.result)) return;\n diff.result = result;\n // If we get another update before we've re-rendered, bail out of\n // the update and try again. This ensures that the relative timing\n // between useQuery and useFragment stays roughly the same as\n // fixed in https://github.com/apollographql/apollo-client/pull/11083\n clearTimeout(lastTimeout);\n lastTimeout = setTimeout(forceUpdate) as any;\n },\n });\n return () => {\n subscription?.unsubscribe();\n clearTimeout(lastTimeout);\n };\n },\n [client, stableOptions, diff]\n ),\n getSnapshot,\n getSnapshot\n );\n}\n\nfunction diffToResult<TData>(\n diff: Cache.DiffResult<TData>\n): useFragment.Result<TData> {\n const result = {\n data: diff.result,\n complete: !!diff.complete,\n dataState: diff.complete ? \"complete\" : \"partial\",\n } as useFragment.Result<TData>; // TODO: Remove assertion once useFragment returns null\n\n if (diff.missing) {\n result.missing = diff.missing.missing;\n }\n\n return result;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"useFragment.js","sourceRoot":"","sources":["../../../src/react/hooks/useFragment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAmB/B,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAA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,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE;oBACf,mEAAmE;oBACnE,sDAAsD;oBACtD,iBAAiB;oBACjB,IAAI,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC;wBAAE,OAAO;oBACvC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;oBACrB,iEAAiE;oBACjE,kEAAkE;oBAClE,6DAA6D;oBAC7D,qEAAqE;oBACrE,YAAY,CAAC,WAAW,CAAC,CAAC;oBAC1B,WAAW,GAAG,UAAU,CAAC,WAAW,CAAQ,CAAC;gBAC/C,CAAC;aACF,CAAC,CAAC;QACP,OAAO,GAAG,EAAE;YACV,YAAY,EAAE,WAAW,EAAE,CAAC;YAC5B,YAAY,CAAC,WAAW,CAAC,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC,EACD,CAAC,MAAM,EAAE,aAAa,EAAE,IAAI,CAAC,CAC9B,EACD,WAAW,EACX,WAAW,CACZ,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CACnB,IAA6B;IAE7B,MAAM,MAAM,GAAG;QACb,IAAI,EAAE,IAAI,CAAC,MAAM;QACjB,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ;QACzB,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS;KACrB,CAAC,CAAC,uDAAuD;IAEvF,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QACjB,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IACxC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { equal } from \"@wry/equality\";\nimport * as React from \"react\";\n\nimport type {\n ApolloClient,\n DataValue,\n DocumentNode,\n GetDataState,\n OperationVariables,\n TypedDocumentNode,\n} from \"@apollo/client\";\nimport type {\n Cache,\n MissingTree,\n Reference,\n StoreObject,\n} from \"@apollo/client/cache\";\nimport type { FragmentType, MaybeMasked } from \"@apollo/client/masking\";\nimport type { NoInfer } from \"@apollo/client/utilities/internal\";\n\nimport { useDeepMemo, wrapHook } from \"./internal/index.js\";\nimport { useApolloClient } from \"./useApolloClient.js\";\nimport { useSyncExternalStore } from \"./useSyncExternalStore.js\";\n\nexport declare namespace useFragment {\n import _self = useFragment;\n export interface Options<TData, TVariables extends OperationVariables> {\n /**\n * A GraphQL document created using the `gql` template string tag from\n * `graphql-tag` with one or more fragments which will be used to determine\n * the shape of data to read. If you provide more than one fragment in this\n * document then you must also specify `fragmentName` to select a single.\n */\n fragment: DocumentNode | TypedDocumentNode<TData, TVariables>;\n\n /**\n * The name of the fragment in your GraphQL document to be used. If you do\n * not provide a `fragmentName` and there is only one fragment in your\n * `fragment` document then that fragment will be used.\n */\n fragmentName?: string;\n\n /**\n * Any variables that the GraphQL query may depend on.\n */\n variables?: NoInfer<TVariables>;\n\n /**\n * An object containing a `__typename` and primary key fields (such as `id`) identifying the entity object from which the fragment will be retrieved, or a `{ __ref: \"...\" }` reference, or a `string` ID (uncommon).\n */\n from:\n | StoreObject\n | Reference\n | FragmentType<NoInfer<TData>>\n | string\n | null;\n\n /**\n * Whether to read from optimistic or non-optimistic cache data. If\n * this named option is provided, the optimistic parameter of the\n * readQuery method can be omitted.\n *\n * @defaultValue true\n */\n optimistic?: boolean;\n\n /**\n * The instance of `ApolloClient` to use to look up the fragment.\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?: ApolloClient;\n }\n\n namespace DocumentationTypes {\n namespace useFragment {\n export interface Options<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n > extends _self.Options<TData, TVariables> {}\n }\n }\n\n // TODO: Update this to return `null` when there is no data returned from the\n // fragment.\n export type Result<TData> =\n | ({\n /** {@inheritDoc @apollo/client/react!useFragment.DocumentationTypes.useFragment.Result#complete:member} */\n complete: true;\n /** {@inheritDoc @apollo/client/react!useFragment.DocumentationTypes.useFragment.Result#missing:member} */\n missing?: never;\n } & GetDataState<MaybeMasked<TData>, \"complete\">)\n | ({\n /** {@inheritDoc @apollo/client/react!useFragment.DocumentationTypes.useFragment.Result#complete:member} */\n complete: false;\n /** {@inheritDoc @apollo/client/react!useFragment.DocumentationTypes.useFragment.Result#missing:member} */\n missing?: MissingTree;\n } & GetDataState<MaybeMasked<TData>, \"partial\">);\n\n export namespace DocumentationTypes {\n namespace useFragment {\n export interface Result<TData> {\n data: MaybeMasked<TData> | DataValue.Partial<MaybeMasked<TData>>;\n complete: boolean;\n /**\n * A tree of all `MissingFieldError` messages reported during fragment reading, where the branches of the tree indicate the paths of the errors within the query result.\n */\n missing?: MissingTree;\n }\n }\n }\n export namespace DocumentationTypes {\n /** {@inheritDoc @apollo/client/react!useFragment:function(1)} */\n export function useFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n >({\n fragment,\n from,\n fragmentName,\n variables,\n optimistic,\n client,\n }: useFragment.Options<TData, TVariables>): useFragment.Result<TData>;\n }\n}\n\n/**\n * `useFragment` represents a lightweight live binding into the Apollo Client Cache and enables Apollo Client to broadcast very specific fragment results to individual components. This hook returns an always-up-to-date view of whatever data the cache currently contains for a given fragment. `useFragment` never triggers network requests of its own.\n *\n * Note that the `useQuery` hook remains the primary hook responsible for querying and populating data in the cache ([see the API reference](./hooks#usequery)). As a result, the component reading the fragment data via `useFragment` is still subscribed to all changes in the query data, but receives updates only when that fragment's specific data change.\n *\n * To view a `useFragment` example, see the [Fragments](https://www.apollographql.com/docs/react/data/fragments#usefragment) page.\n */\nexport function useFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(options: useFragment.Options<TData, TVariables>): useFragment.Result<TData> {\n \"use no memo\";\n return wrapHook(\n \"useFragment\",\n // eslint-disable-next-line react-compiler/react-compiler\n useFragment_,\n useApolloClient(options.client)\n )(options);\n}\n\nfunction useFragment_<TData, TVariables extends OperationVariables>(\n options: useFragment.Options<TData, TVariables>\n): useFragment.Result<TData> {\n const client = useApolloClient(options.client);\n const { cache } = client;\n const { from, ...rest } = options;\n\n // We calculate the cache id separately from `stableOptions` because we don't\n // want changes to non key fields in the `from` property to affect\n // `stableOptions` and retrigger our subscription. If the cache identifier\n // stays the same between renders, we want to reuse the existing subscription.\n const id = React.useMemo(\n () =>\n typeof from === \"string\" ? from\n : from === null ? null\n : cache.identify(from),\n [cache, from]\n );\n\n const stableOptions = useDeepMemo(() => ({ ...rest, from: id! }), [rest, id]);\n\n // Since .next is async, we need to make sure that we\n // get the correct diff on the next render given new diffOptions\n const diff = React.useMemo(() => {\n const { fragment, fragmentName, from, optimistic = true } = stableOptions;\n\n if (from === null) {\n return {\n result: diffToResult({\n result: {},\n complete: false,\n } as Cache.DiffResult<TData>),\n };\n }\n\n const { cache } = client;\n const diff = cache.diff<TData, TVariables>({\n ...stableOptions,\n returnPartialData: true,\n id: from,\n query: cache[\"getFragmentDoc\"](\n client[\"transform\"](fragment),\n fragmentName\n ),\n optimistic,\n });\n\n return {\n result: diffToResult<TData>({\n ...diff,\n result: client[\"queryManager\"].maskFragment({\n fragment,\n fragmentName,\n // TODO: Revert to `diff.result` once `useFragment` supports `null` as\n // valid return value\n data: diff.result === null ? {} : diff.result,\n }) as any,\n }),\n };\n }, [client, stableOptions]);\n\n // Used for both getSnapshot and getServerSnapshot\n const getSnapshot = React.useCallback(() => diff.result, [diff]);\n\n return useSyncExternalStore(\n React.useCallback(\n (forceUpdate) => {\n let lastTimeout = 0;\n\n const subscription =\n stableOptions.from === null ?\n null\n : client.watchFragment(stableOptions).subscribe({\n next: (result) => {\n // Avoid unnecessarily rerendering this hook for the initial result\n // emitted from watchFragment which should be equal to\n // `diff.result`.\n if (equal(result, diff.result)) return;\n diff.result = result;\n // If we get another update before we've re-rendered, bail out of\n // the update and try again. This ensures that the relative timing\n // between useQuery and useFragment stays roughly the same as\n // fixed in https://github.com/apollographql/apollo-client/pull/11083\n clearTimeout(lastTimeout);\n lastTimeout = setTimeout(forceUpdate) as any;\n },\n });\n return () => {\n subscription?.unsubscribe();\n clearTimeout(lastTimeout);\n };\n },\n [client, stableOptions, diff]\n ),\n getSnapshot,\n getSnapshot\n );\n}\n\nfunction diffToResult<TData>(\n diff: Cache.DiffResult<TData>\n): useFragment.Result<TData> {\n const result = {\n data: diff.result,\n complete: !!diff.complete,\n dataState: diff.complete ? \"complete\" : \"partial\",\n } as useFragment.Result<TData>; // TODO: Remove assertion once useFragment returns null\n\n if (diff.missing) {\n result.missing = diff.missing.missing;\n }\n\n return result;\n}\n"]}
|
|
@@ -164,7 +164,7 @@ export declare namespace useLazyQuery {
|
|
|
164
164
|
*/
|
|
165
165
|
previousData?: MaybeMasked<TData>;
|
|
166
166
|
/**
|
|
167
|
-
* A single ErrorLike object describing the error that
|
|
167
|
+
* A single ErrorLike object describing the error that occurred during the latest
|
|
168
168
|
* query execution.
|
|
169
169
|
*
|
|
170
170
|
* For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).
|
|
@@ -142,7 +142,7 @@ export declare namespace useQuery {
|
|
|
142
142
|
*/
|
|
143
143
|
previousData?: MaybeMasked<TData>;
|
|
144
144
|
/**
|
|
145
|
-
* A single ErrorLike object describing the error that
|
|
145
|
+
* A single ErrorLike object describing the error that occurred during the latest
|
|
146
146
|
* query execution.
|
|
147
147
|
*
|
|
148
148
|
* For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).
|
|
@@ -6,7 +6,7 @@ export declare namespace useReadQuery {
|
|
|
6
6
|
namespace Base {
|
|
7
7
|
interface Result<TData = unknown> {
|
|
8
8
|
/**
|
|
9
|
-
* A single ErrorLike object describing the error that
|
|
9
|
+
* A single ErrorLike object describing the error that occurred during the latest
|
|
10
10
|
* query execution.
|
|
11
11
|
*
|
|
12
12
|
* For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).
|
|
@@ -115,7 +115,7 @@ export declare namespace useSuspenseQuery {
|
|
|
115
115
|
*/
|
|
116
116
|
client: ApolloClient;
|
|
117
117
|
/**
|
|
118
|
-
* A single ErrorLike object describing the error that
|
|
118
|
+
* A single ErrorLike object describing the error that occurred during the latest
|
|
119
119
|
* query execution.
|
|
120
120
|
*
|
|
121
121
|
* For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { NetworkStatus } from "@apollo/client";
|
|
3
|
-
import { canonicalStringify } from "@apollo/client/cache";
|
|
4
3
|
import { getSuspenseCache } from "@apollo/client/react/internal";
|
|
5
4
|
import { __DEV__ } from "@apollo/client/utilities/environment";
|
|
6
5
|
import { skipToken } from "./constants.js";
|
|
7
|
-
import { __use, useDeepMemo, wrapHook } from "./internal/index.js";
|
|
6
|
+
import { __use, useDeepMemo, useSuspenseHookCacheKey, wrapHook, } from "./internal/index.js";
|
|
8
7
|
import { validateSuspenseHookOptions } from "./internal/validateSuspenseHookOptions.js";
|
|
9
8
|
import { useApolloClient } from "./useApolloClient.js";
|
|
10
9
|
export function useSuspenseQuery(query, options) {
|
|
@@ -21,13 +20,8 @@ function useSuspenseQuery_(query, options) {
|
|
|
21
20
|
query,
|
|
22
21
|
options,
|
|
23
22
|
});
|
|
24
|
-
const { fetchPolicy
|
|
25
|
-
const
|
|
26
|
-
const cacheKey = [
|
|
27
|
-
query,
|
|
28
|
-
canonicalStringify(variables),
|
|
29
|
-
...[].concat(queryKey),
|
|
30
|
-
];
|
|
23
|
+
const { fetchPolicy } = watchQueryOptions;
|
|
24
|
+
const cacheKey = useSuspenseHookCacheKey(query, options);
|
|
31
25
|
const queryRef = suspenseCache.getQueryRef(cacheKey, () => client.watchQuery(watchQueryOptions));
|
|
32
26
|
let [current, setPromise] = React.useState([queryRef.key, queryRef.promise]);
|
|
33
27
|
// This saves us a re-execution of the render function when a variable changed.
|