@apollo/client 4.1.0-alpha.5 → 4.1.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"useFragment.js","sourceRoot":"","sources":["../../../src/react/hooks/useFragment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAc/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;AA+JjE,MAAM,UAAU,WAAW,CAIzB,OAA+C;IAE/C,aAAa,CAAC;IACd,OAAO,QAAQ,CACb,aAAa,EACb,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,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAClC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;IAEzB,4EAA4E;IAC5E,6EAA6E;IAC7E,2EAA2E;IAC3E,gBAAgB;IAChB,MAAM,GAAG,GAAG,WAAW,CAAC,GAAG,EAAE;QAC3B,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAEtD,MAAM,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAClC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK;YACjC,CAAC,CAAC,KAAK,KAAK,IAAI,CAAC,C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O,GAAG,EAAE;YACV,YAAY,CAAC,WAAW,EAAE,CAAC;YAC3B,YAAY,CAAC,WAAW,CAAC,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC,EACD,CAAC,UAAU,CAAC,CACb,EACD,WAAW,EACX,WAAW,CACZ,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC;IAC/B,IAAI,EAAE,EAAE;IACR,SAAS,EAAE,SAAS;IACpB,QAAQ,EAAE,KAAK;CAChB,CAA4B,CAAC","sourcesContent":["import * 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 { ApolloCache, MissingTree } from \"@apollo/client/cache\";\nimport type { 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\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 or array containing a `__typename` and primary key fields\n * (such as `id`) identifying the entity object from which the fragment will\n * be retrieved, or a `{ __ref: \"...\" }` reference, or a `string` ID (uncommon).\n */\n from: useFragment.FromValue<TData> | Array<useFragment.FromValue<TData>>;\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 /**\n * Acceptable values provided to the `from` option.\n */\n export type FromValue<TData> = ApolloCache.WatchFragmentFromValue<TData>;\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 /** {@inheritDoc @apollo/client!QueryResultDocumentation#data:member} */\n data: TData extends Array<infer TItem> ?\n Array<DataValue.Partial<TItem> | null>\n : DataValue.Partial<TData>;\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#dataState:member} */\n dataState: \"partial\";\n };\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>(\n options: useFragment.Options<TData, TVariables> & {\n from: Array<NonNullable<useFragment.FromValue<TData>>>;\n }\n): useFragment.Result<Array<TData>>;\n\n/** {@inheritDoc @apollo/client/react!useFragment:function(1)} */\nexport function useFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useFragment.Options<TData, TVariables> & {\n from: Array<null>;\n }\n): useFragment.Result<Array<null>>;\n\n/** {@inheritDoc @apollo/client/react!useFragment:function(1)} */\nexport function useFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useFragment.Options<TData, TVariables> & {\n from: Array<useFragment.FromValue<TData>>;\n }\n): useFragment.Result<Array<TData | null>>;\n\n/** {@inheritDoc @apollo/client/react!useFragment:function(1)} */\nexport function useFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(options: useFragment.Options<TData, TVariables>): useFragment.Result<TData>;\n\nexport function useFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useFragment.Options<TData, TVariables>\n): useFragment.Result<TData> | useFragment.Result<Array<TData | null>> {\n \"use no memo\";\n return wrapHook(\n \"useFragment\",\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> | useFragment.Result<Array<TData | null>> {\n const client = useApolloClient(options.client);\n const { from, ...rest } = options;\n const { cache } = client;\n\n // We calculate the cache id seperately because we don't want changes to non\n // key fields in the `from` property to recreate the observable. If the cache\n // identifier stays the same between renders, we want to reuse the existing\n // subscription.\n const ids = useDeepMemo(() => {\n const fromArray = Array.isArray(from) ? from : [from];\n\n const ids = fromArray.map((value) =>\n typeof value === \"string\" ? value\n : value === null ? null\n : cache.identify(value)\n );\n\n return Array.isArray(from) ? ids : ids[0];\n }, [cache, from]);\n\n const stableOptions = useDeepMemo(\n () => ({ ...rest, from: ids as any }),\n [rest, ids]\n );\n\n const observable = React.useMemo(\n () => client.watchFragment(stableOptions),\n [client, stableOptions]\n );\n\n // Unfortunately we forgot to update the use case of `from: null` on\n // useFragment in 4.0 to match `useSuspenseFragment`. As such, we need to\n // fallback to data: {} with complete: false when `from` is `null` to maintain\n // backwards compatibility. We should plan to change this in v5.\n const getSnapshot = React.useCallback(\n () => (from === null ? nullResult : observable.getCurrentResult()),\n [from, observable]\n );\n\n return useSyncExternalStore(\n React.useCallback(\n (update) => {\n let lastTimeout = 0;\n const subscription = observable.subscribe({\n next: () => {\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(update) as any;\n },\n });\n\n return () => {\n subscription.unsubscribe();\n clearTimeout(lastTimeout);\n };\n },\n [observable]\n ),\n getSnapshot,\n getSnapshot\n );\n}\n\nconst nullResult = Object.freeze({\n data: {},\n dataState: \"partial\",\n complete: false,\n}) as useFragment.Result<any>;\n"]}
1
+ {"version":3,"file":"useFragment.js","sourceRoot":"","sources":["../../../src/react/hooks/useFragment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK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,CAAC;IAC/B,IAAI,EAAE,EAAE;IACR,SAAS,EAAE,SAAS;IACpB,QAAQ,EAAE,KAAK;CAChB,CAA4B,CAAC","sourcesContent":["import * 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 { ApolloCache, MissingTree } from \"@apollo/client/cache\";\nimport type { 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\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 or array containing a `__typename` and primary key fields\n * (such as `id`) identifying the entity object from which the fragment will\n * be retrieved, or a `{ __ref: \"...\" }` reference, or a `string` ID (uncommon).\n */\n from:\n | useFragment.FromOptionValue<TData>\n | Array<useFragment.FromOptionValue<TData> | null>\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 /**\n * Acceptable values provided to the `from` option.\n */\n export type FromOptionValue<TData> = ApolloCache.FromOptionValue<TData>;\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 /** {@inheritDoc @apollo/client!QueryResultDocumentation#data:member} */\n data: TData extends Array<infer TItem> ?\n Array<DataValue.Partial<TItem> | null>\n : DataValue.Partial<TData>;\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#dataState:member} */\n dataState: \"partial\";\n };\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>(\n options: useFragment.Options<TData, TVariables> & {\n from: Array<useFragment.FromOptionValue<TData>>;\n }\n): useFragment.Result<Array<TData>>;\n\n/** {@inheritDoc @apollo/client/react!useFragment:function(1)} */\nexport function useFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useFragment.Options<TData, TVariables> & {\n from: Array<null>;\n }\n): useFragment.Result<Array<null>>;\n\n/** {@inheritDoc @apollo/client/react!useFragment:function(1)} */\nexport function useFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useFragment.Options<TData, TVariables> & {\n from: Array<useFragment.FromOptionValue<TData> | null>;\n }\n): useFragment.Result<Array<TData | null>>;\n\n/** {@inheritDoc @apollo/client/react!useFragment:function(1)} */\nexport function useFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(options: useFragment.Options<TData, TVariables>): useFragment.Result<TData>;\n\nexport function useFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useFragment.Options<TData, TVariables>\n): useFragment.Result<TData> | useFragment.Result<Array<TData | null>> {\n \"use no memo\";\n return wrapHook(\n \"useFragment\",\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> | useFragment.Result<Array<TData | null>> {\n const client = useApolloClient(options.client);\n const { from, ...rest } = options;\n const { cache } = client;\n\n // We calculate the cache id seperately because we don't want changes to non\n // key fields in the `from` property to recreate the observable. If the cache\n // identifier stays the same between renders, we want to reuse the existing\n // subscription.\n const ids = useDeepMemo(() => {\n const fromArray = Array.isArray(from) ? from : [from];\n\n const ids = fromArray.map((value) =>\n typeof value === \"string\" ? value\n : value === null ? null\n : cache.identify(value)\n );\n\n return Array.isArray(from) ? ids : ids[0];\n }, [cache, from]);\n\n const stableOptions = useDeepMemo(\n () => ({ ...rest, from: ids as any }),\n [rest, ids]\n );\n\n const observable = React.useMemo(\n () => client.watchFragment(stableOptions),\n [client, stableOptions]\n );\n\n // Unfortunately we forgot to update the use case of `from: null` on\n // useFragment in 4.0 to match `useSuspenseFragment`. As such, we need to\n // fallback to data: {} with complete: false when `from` is `null` to maintain\n // backwards compatibility. We should plan to change this in v5.\n const getSnapshot = React.useCallback(\n () => (from === null ? nullResult : observable.getCurrentResult()),\n [from, observable]\n );\n\n return useSyncExternalStore(\n React.useCallback(\n (update) => {\n let lastTimeout = 0;\n const subscription = observable.subscribe({\n next: () => {\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(update) as any;\n },\n });\n\n return () => {\n subscription.unsubscribe();\n clearTimeout(lastTimeout);\n };\n },\n [observable]\n ),\n getSnapshot,\n getSnapshot\n );\n}\n\nconst nullResult = Object.freeze({\n data: {},\n dataState: \"partial\",\n complete: false,\n}) as useFragment.Result<any>;\n"]}
@@ -24,7 +24,7 @@ export declare namespace useSuspenseFragment {
24
24
  * (such as `id`) identifying the entity object from which the fragment will
25
25
  * be retrieved, or a `{ __ref: "..." }` reference, or a `string` ID (uncommon).
26
26
  */
27
- from: useSuspenseFragment.FromValue<TData> | Array<useSuspenseFragment.FromValue<TData>>;
27
+ from: useSuspenseFragment.FromOptionValue<TData> | Array<useSuspenseFragment.FromOptionValue<TData> | null> | null;
28
28
  optimistic?: boolean;
29
29
  /**
30
30
  * The instance of `ApolloClient` to use to look up the fragment.
@@ -47,7 +47,7 @@ export declare namespace useSuspenseFragment {
47
47
  /**
48
48
  * Acceptable values provided to the `from` option.
49
49
  */
50
- type FromValue<TData> = ApolloCache.WatchFragmentFromValue<TData>;
50
+ type FromOptionValue<TData> = ApolloCache.FromOptionValue<TData>;
51
51
  interface Result<TData> {
52
52
  data: DataValue.Complete<MaybeMasked<TData>>;
53
53
  }
@@ -66,7 +66,7 @@ export declare namespace useSuspenseFragment {
66
66
  }
67
67
  /** #TODO documentation */
68
68
  export declare function useSuspenseFragment<TData = unknown, TVariables extends OperationVariables = OperationVariables>(options: useSuspenseFragment.Options<TData, TVariables> & {
69
- from: Array<NonNullable<useSuspenseFragment.FromValue<TData>>>;
69
+ from: Array<useSuspenseFragment.FromOptionValue<TData>>;
70
70
  }): useSuspenseFragment.Result<Array<TData>>;
71
71
  /**
72
72
  * #TODO documentation
@@ -78,13 +78,13 @@ export declare function useSuspenseFragment<TData = unknown, TVariables extends
78
78
  * #TODO documentation
79
79
  */
80
80
  export declare function useSuspenseFragment<TData = unknown, TVariables extends OperationVariables = OperationVariables>(options: useSuspenseFragment.Options<TData, TVariables> & {
81
- from: Array<useSuspenseFragment.FromValue<TData>>;
81
+ from: Array<useSuspenseFragment.FromOptionValue<TData> | null>;
82
82
  }): useSuspenseFragment.Result<Array<TData | null>>;
83
83
  /**
84
84
  * #TODO documentation
85
85
  */
86
86
  export declare function useSuspenseFragment<TData, TVariables extends OperationVariables = OperationVariables>(options: useSuspenseFragment.Options<TData, TVariables> & {
87
- from: NonNullable<useSuspenseFragment.FromValue<TData>>;
87
+ from: useSuspenseFragment.FromOptionValue<TData>;
88
88
  }): useSuspenseFragment.Result<TData>;
89
89
  /**
90
90
  * #TODO documentation
@@ -96,7 +96,7 @@ export declare function useSuspenseFragment<TData, TVariables extends OperationV
96
96
  * #TODO documentation
97
97
  */
98
98
  export declare function useSuspenseFragment<TData, TVariables extends OperationVariables = OperationVariables>(options: useSuspenseFragment.Options<TData, TVariables> & {
99
- from: useSuspenseFragment.FromValue<TData>;
99
+ from: useSuspenseFragment.FromOptionValue<TData> | null;
100
100
  }): useSuspenseFragment.Result<TData | null>;
101
101
  /**
102
102
  * #TODO documentation
@@ -1 +1 @@
1
- {"version":3,"file":"useSuspenseFragment.js","sourceRoot":"","sources":["../../../src/react/hooks/useSuspenseFragment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAU/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAOjE,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAuJvD,MAAM,UAAU,mBAAmB,CAIjC,OAAuD;IAEvD,aAAa,CAAC;IACd,OAAO,QAAQ,CACb,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,CAAC,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAC1E,CAAC,OAAO,CAAC,CAAC;AACb,CAAC;AAED,SAAS,oBAAoB,CAI3B,OAAuD;IAEvD,MAAM,MAAM,GAAG,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/C,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IACpC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;IAEzB,MAAM,GAAG,GAAG,WAAW,CAAC,GAAG,EAAE;QAC3B,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;YACxB,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE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C,oDAAoD;QACpD,OAAO,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC;QAC7B,oDAAoD;QACpD,OAAO,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,OAAO,CAAC;IACnC,CAAC;IAED,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAE/B,OAAO,EAAE,IAAI,EAAE,CAAC;AAClB,CAAC;AAED,SAAS,UAAU,CACjB,KAAkB,EAClB,IAAwC;IAExC,OAAO,CACL,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI;QAC/B,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI;YACtB,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAkB,CAAC;AAC7C,CAAC","sourcesContent":["import * as React from \"react\";\n\nimport type {\n ApolloClient,\n DataValue,\n DocumentNode,\n OperationVariables,\n TypedDocumentNode,\n} from \"@apollo/client\";\nimport type { ApolloCache } from \"@apollo/client/cache\";\nimport { canonicalStringify } from \"@apollo/client/cache\";\nimport type { MaybeMasked } from \"@apollo/client/masking\";\nimport type { FragmentKey } from \"@apollo/client/react/internal\";\nimport { getSuspenseCache } from \"@apollo/client/react/internal\";\nimport type {\n DocumentationTypes as UtilityDocumentationTypes,\n NoInfer,\n VariablesOption,\n} from \"@apollo/client/utilities/internal\";\n\nimport { __use } from \"./internal/__use.js\";\nimport { useDeepMemo, wrapHook } from \"./internal/index.js\";\nimport { useApolloClient } from \"./useApolloClient.js\";\n\nexport declare namespace useSuspenseFragment {\n import _self = useSuspenseFragment;\n export namespace Base {\n export type 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 * An object or array containing a `__typename` and primary key fields\n * (such as `id`) identifying the entity object from which the fragment will\n * be retrieved, or a `{ __ref: \"...\" }` reference, or a `string` ID (uncommon).\n */\n from:\n | useSuspenseFragment.FromValue<TData>\n | Array<useSuspenseFragment.FromValue<TData>>;\n\n // Override this field to make it optional (default: true).\n optimistic?: boolean;\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 export type Options<\n TData,\n TVariables extends OperationVariables,\n > = Base.Options<TData, TVariables> & VariablesOption<NoInfer<TVariables>>;\n\n export namespace DocumentationTypes {\n export namespace useSuspenseFragment {\n export interface Options<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n > extends Base.Options<TData, TVariables>,\n UtilityDocumentationTypes.VariableOptions<TVariables> {}\n }\n }\n\n /**\n * Acceptable values provided to the `from` option.\n */\n export type FromValue<TData> = ApolloCache.WatchFragmentFromValue<TData>;\n\n export interface Result<TData> {\n data: DataValue.Complete<MaybeMasked<TData>>;\n }\n export namespace DocumentationTypes {\n export namespace useSuspenseFragment {\n export interface Result<TData = unknown> extends _self.Result<TData> {}\n }\n }\n\n export namespace DocumentationTypes {\n /** {@inheritDoc @apollo/client/react!useSuspenseFragment:function(1)} */\n export function useSuspenseFragment<\n TData,\n TVariables extends OperationVariables = OperationVariables,\n >(\n options: useSuspenseFragment.Options<TData, TVariables>\n ): useSuspenseFragment.Result<TData>;\n }\n}\n\n/** #TODO documentation */\nexport function useSuspenseFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useSuspenseFragment.Options<TData, TVariables> & {\n from: Array<NonNullable<useSuspenseFragment.FromValue<TData>>>;\n }\n): useSuspenseFragment.Result<Array<TData>>;\n\n/** {@inheritDoc @apollo/client/react!useSuspenseFragment:function(1)} */\nexport function useSuspenseFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useSuspenseFragment.Options<TData, TVariables> & {\n from: Array<null>;\n }\n): useSuspenseFragment.Result<Array<null>>;\n\n/** {@inheritDoc @apollo/client/react!useSuspenseFragment:function(1)} */\nexport function useSuspenseFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useSuspenseFragment.Options<TData, TVariables> & {\n from: Array<useSuspenseFragment.FromValue<TData>>;\n }\n): useSuspenseFragment.Result<Array<TData | null>>;\n\n/** {@inheritDoc @apollo/client/react!useSuspenseFragment:function(1)} */\nexport function useSuspenseFragment<\n TData,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useSuspenseFragment.Options<TData, TVariables> & {\n from: NonNullable<useSuspenseFragment.FromValue<TData>>;\n }\n): useSuspenseFragment.Result<TData>;\n\n/** {@inheritDoc @apollo/client/react!useSuspenseFragment:function(1)} */\nexport function useSuspenseFragment<\n TData,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useSuspenseFragment.Options<TData, TVariables> & {\n from: null;\n }\n): useSuspenseFragment.Result<null>;\n\n/** {@inheritDoc @apollo/client/react!useSuspenseFragment:function(1)} */\nexport function useSuspenseFragment<\n TData,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useSuspenseFragment.Options<TData, TVariables> & {\n from: useSuspenseFragment.FromValue<TData>;\n }\n): useSuspenseFragment.Result<TData | null>;\n\n/** {@inheritDoc @apollo/client/react!useSuspenseFragment:function(1)} */\nexport function useSuspenseFragment<\n TData,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useSuspenseFragment.Options<TData, TVariables>\n): useSuspenseFragment.Result<TData>;\n\nexport function useSuspenseFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useSuspenseFragment.Options<TData, TVariables>\n): useSuspenseFragment.Result<TData | null> {\n \"use no memo\";\n return wrapHook(\n \"useSuspenseFragment\",\n useSuspenseFragment_,\n useApolloClient(typeof options === \"object\" ? options.client : undefined)\n )(options);\n}\n\nfunction useSuspenseFragment_<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useSuspenseFragment.Options<TData, TVariables>\n): useSuspenseFragment.Result<TData | null> {\n const client = useApolloClient(options.client);\n const { from, variables } = options;\n const { cache } = client;\n\n const ids = useDeepMemo(() => {\n return Array.isArray(from) ?\n from.map((id) => toStringId(cache, id))\n : toStringId(cache, from);\n }, [cache, from]);\n const idString = React.useMemo(\n () => (Array.isArray(ids) ? ids.join(\",\") : ids),\n [ids]\n );\n\n const fragmentRef = getSuspenseCache(client).getFragmentRef(\n [options.fragment, canonicalStringify(variables), idString],\n client,\n { ...options, variables: variables as TVariables, from: ids }\n );\n\n let [current, setPromise] = React.useState<\n [FragmentKey, Promise<MaybeMasked<TData> | null>]\n >([fragmentRef.key, fragmentRef.promise]);\n\n React.useEffect(() => {\n const dispose = fragmentRef.retain();\n const removeListener = fragmentRef.listen((promise) => {\n setPromise([fragmentRef.key, promise]);\n });\n\n return () => {\n dispose();\n removeListener();\n };\n }, [fragmentRef]);\n\n if (current[0] !== fragmentRef.key) {\n // eslint-disable-next-line react-hooks/immutability\n current[0] = fragmentRef.key;\n // eslint-disable-next-line react-hooks/immutability\n current[1] = fragmentRef.promise;\n }\n\n const data = __use(current[1]);\n\n return { data };\n}\n\nfunction toStringId(\n cache: ApolloCache,\n from: useSuspenseFragment.FromValue<any>\n) {\n return (\n typeof from === \"string\" ? from\n : from === null ? null\n : cache.identify(from)) as string | null;\n}\n"]}
1
+ {"version":3,"file":"useSuspenseFragment.js","sourceRoot":"","sources":["../../../src/react/hooks/useSuspenseFragment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAU/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG1D,OAAO,EAAE,g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AQ,CAAC,CAAC,CAAC,IAAI;QAC/B,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI;YACtB,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAkB,CAAC;AAC7C,CAAC","sourcesContent":["import * as React from \"react\";\n\nimport type {\n ApolloClient,\n DataValue,\n DocumentNode,\n OperationVariables,\n TypedDocumentNode,\n} from \"@apollo/client\";\nimport type { ApolloCache } from \"@apollo/client/cache\";\nimport { canonicalStringify } from \"@apollo/client/cache\";\nimport type { MaybeMasked } from \"@apollo/client/masking\";\nimport type { FragmentKey } from \"@apollo/client/react/internal\";\nimport { getSuspenseCache } from \"@apollo/client/react/internal\";\nimport type {\n DocumentationTypes as UtilityDocumentationTypes,\n NoInfer,\n VariablesOption,\n} from \"@apollo/client/utilities/internal\";\n\nimport { __use } from \"./internal/__use.js\";\nimport { useDeepMemo, wrapHook } from \"./internal/index.js\";\nimport { useApolloClient } from \"./useApolloClient.js\";\n\nexport declare namespace useSuspenseFragment {\n import _self = useSuspenseFragment;\n export namespace Base {\n export type 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 * An object or array containing a `__typename` and primary key fields\n * (such as `id`) identifying the entity object from which the fragment will\n * be retrieved, or a `{ __ref: \"...\" }` reference, or a `string` ID (uncommon).\n */\n from:\n | useSuspenseFragment.FromOptionValue<TData>\n | Array<useSuspenseFragment.FromOptionValue<TData> | null>\n | null;\n\n // Override this field to make it optional (default: true).\n optimistic?: boolean;\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 export type Options<\n TData,\n TVariables extends OperationVariables,\n > = Base.Options<TData, TVariables> & VariablesOption<NoInfer<TVariables>>;\n\n export namespace DocumentationTypes {\n export namespace useSuspenseFragment {\n export interface Options<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n > extends Base.Options<TData, TVariables>,\n UtilityDocumentationTypes.VariableOptions<TVariables> {}\n }\n }\n\n /**\n * Acceptable values provided to the `from` option.\n */\n export type FromOptionValue<TData> = ApolloCache.FromOptionValue<TData>;\n\n export interface Result<TData> {\n data: DataValue.Complete<MaybeMasked<TData>>;\n }\n export namespace DocumentationTypes {\n export namespace useSuspenseFragment {\n export interface Result<TData = unknown> extends _self.Result<TData> {}\n }\n }\n\n export namespace DocumentationTypes {\n /** {@inheritDoc @apollo/client/react!useSuspenseFragment:function(1)} */\n export function useSuspenseFragment<\n TData,\n TVariables extends OperationVariables = OperationVariables,\n >(\n options: useSuspenseFragment.Options<TData, TVariables>\n ): useSuspenseFragment.Result<TData>;\n }\n}\n\n/** #TODO documentation */\nexport function useSuspenseFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useSuspenseFragment.Options<TData, TVariables> & {\n from: Array<useSuspenseFragment.FromOptionValue<TData>>;\n }\n): useSuspenseFragment.Result<Array<TData>>;\n\n/** {@inheritDoc @apollo/client/react!useSuspenseFragment:function(1)} */\nexport function useSuspenseFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useSuspenseFragment.Options<TData, TVariables> & {\n from: Array<null>;\n }\n): useSuspenseFragment.Result<Array<null>>;\n\n/** {@inheritDoc @apollo/client/react!useSuspenseFragment:function(1)} */\nexport function useSuspenseFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useSuspenseFragment.Options<TData, TVariables> & {\n from: Array<useSuspenseFragment.FromOptionValue<TData> | null>;\n }\n): useSuspenseFragment.Result<Array<TData | null>>;\n\n/** {@inheritDoc @apollo/client/react!useSuspenseFragment:function(1)} */\nexport function useSuspenseFragment<\n TData,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useSuspenseFragment.Options<TData, TVariables> & {\n from: useSuspenseFragment.FromOptionValue<TData>;\n }\n): useSuspenseFragment.Result<TData>;\n\n/** {@inheritDoc @apollo/client/react!useSuspenseFragment:function(1)} */\nexport function useSuspenseFragment<\n TData,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useSuspenseFragment.Options<TData, TVariables> & {\n from: null;\n }\n): useSuspenseFragment.Result<null>;\n\n/** {@inheritDoc @apollo/client/react!useSuspenseFragment:function(1)} */\nexport function useSuspenseFragment<\n TData,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useSuspenseFragment.Options<TData, TVariables> & {\n from: useSuspenseFragment.FromOptionValue<TData> | null;\n }\n): useSuspenseFragment.Result<TData | null>;\n\n/** {@inheritDoc @apollo/client/react!useSuspenseFragment:function(1)} */\nexport function useSuspenseFragment<\n TData,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useSuspenseFragment.Options<TData, TVariables>\n): useSuspenseFragment.Result<TData>;\n\nexport function useSuspenseFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useSuspenseFragment.Options<TData, TVariables>\n): useSuspenseFragment.Result<TData | null> {\n \"use no memo\";\n return wrapHook(\n \"useSuspenseFragment\",\n useSuspenseFragment_,\n useApolloClient(typeof options === \"object\" ? options.client : undefined)\n )(options);\n}\n\nfunction useSuspenseFragment_<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useSuspenseFragment.Options<TData, TVariables>\n): useSuspenseFragment.Result<TData | null> {\n const client = useApolloClient(options.client);\n const { from, variables } = options;\n const { cache } = client;\n\n const ids = useDeepMemo(() => {\n return Array.isArray(from) ?\n from.map((id) => toStringId(cache, id))\n : toStringId(cache, from);\n }, [cache, from]);\n const idString = React.useMemo(\n () => (Array.isArray(ids) ? ids.join(\",\") : ids),\n [ids]\n );\n\n const fragmentRef = getSuspenseCache(client).getFragmentRef(\n [options.fragment, canonicalStringify(variables), idString],\n client,\n { ...options, variables: variables as TVariables, from: ids }\n );\n\n let [current, setPromise] = React.useState<\n [FragmentKey, Promise<MaybeMasked<TData> | null>]\n >([fragmentRef.key, fragmentRef.promise]);\n\n React.useEffect(() => {\n const dispose = fragmentRef.retain();\n const removeListener = fragmentRef.listen((promise) => {\n setPromise([fragmentRef.key, promise]);\n });\n\n return () => {\n dispose();\n removeListener();\n };\n }, [fragmentRef]);\n\n if (current[0] !== fragmentRef.key) {\n // eslint-disable-next-line react-hooks/immutability\n current[0] = fragmentRef.key;\n // eslint-disable-next-line react-hooks/immutability\n current[1] = fragmentRef.promise;\n }\n\n const data = __use(current[1]);\n\n return { data };\n}\n\nfunction toStringId(\n cache: ApolloCache,\n from: useSuspenseFragment.FromOptionValue<any> | null\n) {\n return (\n typeof from === \"string\" ? from\n : from === null ? null\n : cache.identify(from)) as string | null;\n}\n"]}
@@ -27,7 +27,7 @@ export declare namespace useFragment {
27
27
  * (such as `id`) identifying the entity object from which the fragment will
28
28
  * be retrieved, or a `{ __ref: "..." }` reference, or a `string` ID (uncommon).
29
29
  */
30
- from: useFragment.FromValue<TData> | Array<useFragment.FromValue<TData>>;
30
+ from: useFragment.FromOptionValue<TData> | Array<useFragment.FromOptionValue<TData> | null> | null;
31
31
  /**
32
32
  * Whether to read from optimistic or non-optimistic cache data. If
33
33
  * this named option is provided, the optimistic parameter of the
@@ -55,7 +55,7 @@ export declare namespace useFragment {
55
55
  /**
56
56
  * Acceptable values provided to the `from` option.
57
57
  */
58
- type FromValue<TData> = ApolloCache.WatchFragmentFromValue<TData>;
58
+ type FromOptionValue<TData> = ApolloCache.FromOptionValue<TData>;
59
59
  type Result<TData> = ({
60
60
  /**
61
61
  *
@@ -129,7 +129,7 @@ export declare namespace useFragment {
129
129
  * To view a `useFragment` example, see the [Fragments](https://www.apollographql.com/docs/react/data/fragments#usefragment) page.
130
130
  */
131
131
  export declare function useFragment<TData = unknown, TVariables extends OperationVariables = OperationVariables>(options: useFragment.Options<TData, TVariables> & {
132
- from: Array<NonNullable<useFragment.FromValue<TData>>>;
132
+ from: Array<useFragment.FromOptionValue<TData>>;
133
133
  }): useFragment.Result<Array<TData>>;
134
134
  /**
135
135
  * `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.
@@ -149,7 +149,7 @@ export declare function useFragment<TData = unknown, TVariables extends Operatio
149
149
  * To view a `useFragment` example, see the [Fragments](https://www.apollographql.com/docs/react/data/fragments#usefragment) page.
150
150
  */
151
151
  export declare function useFragment<TData = unknown, TVariables extends OperationVariables = OperationVariables>(options: useFragment.Options<TData, TVariables> & {
152
- from: Array<useFragment.FromValue<TData>>;
152
+ from: Array<useFragment.FromOptionValue<TData> | null>;
153
153
  }): useFragment.Result<Array<TData | null>>;
154
154
  /**
155
155
  * `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.
@@ -1 +1 @@
1
- {"version":3,"file":"useFragment.js","sources":["../../../src/react/hooks/useFragment.ts"],"sourcesContent":["import * 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 { ApolloCache, MissingTree } from \"@apollo/client/cache\";\nimport type { 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\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 or array containing a `__typename` and primary key fields\n * (such as `id`) identifying the entity object from which the fragment will\n * be retrieved, or a `{ __ref: \"...\" }` reference, or a `string` ID (uncommon).\n */\n from: useFragment.FromValue<TData> | Array<useFragment.FromValue<TData>>;\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 /**\n * Acceptable values provided to the `from` option.\n */\n export type FromValue<TData> = ApolloCache.WatchFragmentFromValue<TData>;\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 /** {@inheritDoc @apollo/client!QueryResultDocumentation#data:member} */\n data: TData extends Array<infer TItem> ?\n Array<DataValue.Partial<TItem> | null>\n : DataValue.Partial<TData>;\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#dataState:member} */\n dataState: \"partial\";\n };\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>(\n options: useFragment.Options<TData, TVariables> & {\n from: Array<NonNullable<useFragment.FromValue<TData>>>;\n }\n): useFragment.Result<Array<TData>>;\n\n/** {@inheritDoc @apollo/client/react!useFragment:function(1)} */\nexport function useFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useFragment.Options<TData, TVariables> & {\n from: Array<null>;\n }\n): useFragment.Result<Array<null>>;\n\n/** {@inheritDoc @apollo/client/react!useFragment:function(1)} */\nexport function useFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useFragment.Options<TData, TVariables> & {\n from: Array<useFragment.FromValue<TData>>;\n }\n): useFragment.Result<Array<TData | null>>;\n\n/** {@inheritDoc @apollo/client/react!useFragment:function(1)} */\nexport function useFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(options: useFragment.Options<TData, TVariables>): useFragment.Result<TData>;\n\nexport function useFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useFragment.Options<TData, TVariables>\n): useFragment.Result<TData> | useFragment.Result<Array<TData | null>> {\n \"use no memo\";\n return wrapHook(\n \"useFragment\",\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> | useFragment.Result<Array<TData | null>> {\n const client = useApolloClient(options.client);\n const { from, ...rest } = options;\n const { cache } = client;\n\n // We calculate the cache id seperately because we don't want changes to non\n // key fields in the `from` property to recreate the observable. If the cache\n // identifier stays the same between renders, we want to reuse the existing\n // subscription.\n const ids = useDeepMemo(() => {\n const fromArray = Array.isArray(from) ? from : [from];\n\n const ids = fromArray.map((value) =>\n typeof value === \"string\" ? value\n : value === null ? null\n : cache.identify(value)\n );\n\n return Array.isArray(from) ? ids : ids[0];\n }, [cache, from]);\n\n const stableOptions = useDeepMemo(\n () => ({ ...rest, from: ids as any }),\n [rest, ids]\n );\n\n const observable = React.useMemo(\n () => client.watchFragment(stableOptions),\n [client, stableOptions]\n );\n\n // Unfortunately we forgot to update the use case of `from: null` on\n // useFragment in 4.0 to match `useSuspenseFragment`. As such, we need to\n // fallback to data: {} with complete: false when `from` is `null` to maintain\n // backwards compatibility. We should plan to change this in v5.\n const getSnapshot = React.useCallback(\n () => (from === null ? nullResult : observable.getCurrentResult()),\n [from, observable]\n );\n\n return useSyncExternalStore(\n React.useCallback(\n (update) => {\n let lastTimeout = 0;\n const subscription = observable.subscribe({\n next: () => {\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(update) as any;\n },\n });\n\n return () => {\n subscription.unsubscribe();\n clearTimeout(lastTimeout);\n };\n },\n [observable]\n ),\n getSnapshot,\n getSnapshot\n );\n}\n\nconst nullResult = Object.freeze({\n data: {},\n dataState: \"partial\",\n complete: false,\n}) as useFragment.Result<any>;\n"],"names":[],"mappings":";AAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAO,EAAP,CAAA,EAAY,CAAZ,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,EAAuB,CAAvB,CAAA,CAAA,CAAA,CAAA,CAAA,CAA8B;AAc9B,CAAA,CAAA,CAAA,CAAA,CAAA,EAAO,EAAE,CAAT,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAoB,EAAE,CAAtB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,EAAsC,CAAtC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA2D;AAC3D,CAAA,CAAA,CAAA,CAAA,CAAA,EAAO,EAAE,CAAT,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,EAAgC,CAAhC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAuEM,CAAN,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAmB,CAAnB,CAAA,CAAA,CAAA,CAAA,CAAyB,CAAC,CAA1B,CAAA,CAAA,CAAA,CAAA,CAAgC,CAAC;IAC/B,CAAF,CAAA,CAAA,CAAM,EAAE,CAAR,CAAU;IACR,CAAF,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAW,EAAE,CAAb,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAsB;IACpB,CAAF,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAU,EAAE,CAAZ,CAAA,CAAA,CAAA,CAAiB;AACjB,CAAC;"}
1
+ {"version":3,"file":"useFragment.js","sources":["../../../src/react/hooks/useFragment.ts"],"sourcesContent":["import * 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 { ApolloCache, MissingTree } from \"@apollo/client/cache\";\nimport type { 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\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 or array containing a `__typename` and primary key fields\n * (such as `id`) identifying the entity object from which the fragment will\n * be retrieved, or a `{ __ref: \"...\" }` reference, or a `string` ID (uncommon).\n */\n from:\n | useFragment.FromOptionValue<TData>\n | Array<useFragment.FromOptionValue<TData> | null>\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 /**\n * Acceptable values provided to the `from` option.\n */\n export type FromOptionValue<TData> = ApolloCache.FromOptionValue<TData>;\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 /** {@inheritDoc @apollo/client!QueryResultDocumentation#data:member} */\n data: TData extends Array<infer TItem> ?\n Array<DataValue.Partial<TItem> | null>\n : DataValue.Partial<TData>;\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#dataState:member} */\n dataState: \"partial\";\n };\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>(\n options: useFragment.Options<TData, TVariables> & {\n from: Array<useFragment.FromOptionValue<TData>>;\n }\n): useFragment.Result<Array<TData>>;\n\n/** {@inheritDoc @apollo/client/react!useFragment:function(1)} */\nexport function useFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useFragment.Options<TData, TVariables> & {\n from: Array<null>;\n }\n): useFragment.Result<Array<null>>;\n\n/** {@inheritDoc @apollo/client/react!useFragment:function(1)} */\nexport function useFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useFragment.Options<TData, TVariables> & {\n from: Array<useFragment.FromOptionValue<TData> | null>;\n }\n): useFragment.Result<Array<TData | null>>;\n\n/** {@inheritDoc @apollo/client/react!useFragment:function(1)} */\nexport function useFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(options: useFragment.Options<TData, TVariables>): useFragment.Result<TData>;\n\nexport function useFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useFragment.Options<TData, TVariables>\n): useFragment.Result<TData> | useFragment.Result<Array<TData | null>> {\n \"use no memo\";\n return wrapHook(\n \"useFragment\",\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> | useFragment.Result<Array<TData | null>> {\n const client = useApolloClient(options.client);\n const { from, ...rest } = options;\n const { cache } = client;\n\n // We calculate the cache id seperately because we don't want changes to non\n // key fields in the `from` property to recreate the observable. If the cache\n // identifier stays the same between renders, we want to reuse the existing\n // subscription.\n const ids = useDeepMemo(() => {\n const fromArray = Array.isArray(from) ? from : [from];\n\n const ids = fromArray.map((value) =>\n typeof value === \"string\" ? value\n : value === null ? null\n : cache.identify(value)\n );\n\n return Array.isArray(from) ? ids : ids[0];\n }, [cache, from]);\n\n const stableOptions = useDeepMemo(\n () => ({ ...rest, from: ids as any }),\n [rest, ids]\n );\n\n const observable = React.useMemo(\n () => client.watchFragment(stableOptions),\n [client, stableOptions]\n );\n\n // Unfortunately we forgot to update the use case of `from: null` on\n // useFragment in 4.0 to match `useSuspenseFragment`. As such, we need to\n // fallback to data: {} with complete: false when `from` is `null` to maintain\n // backwards compatibility. We should plan to change this in v5.\n const getSnapshot = React.useCallback(\n () => (from === null ? nullResult : observable.getCurrentResult()),\n [from, observable]\n );\n\n return useSyncExternalStore(\n React.useCallback(\n (update) => {\n let lastTimeout = 0;\n const subscription = observable.subscribe({\n next: () => {\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(update) as any;\n },\n });\n\n return () => {\n subscription.unsubscribe();\n clearTimeout(lastTimeout);\n };\n },\n [observable]\n ),\n getSnapshot,\n getSnapshot\n );\n}\n\nconst nullResult = Object.freeze({\n data: {},\n dataState: \"partial\",\n complete: false,\n}) as useFragment.Result<any>;\n"],"names":[],"mappings":";AAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAO,EAAP,CAAA,EAAY,CAAZ,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,EAAuB,CAAvB,CAAA,CAAA,CAAA,CAAA,CAAA,CAA8B;AAc9B,CAAA,CAAA,CAAA,CAAA,CAAA,EAAO,EAAE,CAAT,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAoB,EAAE,CAAtB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,EAAsC,CAAtC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA2D;AAC3D,CAAA,CAAA,CAAA,CAAA,CAAA,EAAO,EAAE,CAAT,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,EAAgC,CAAhC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAsD;AACtD,CAAA,CAAA,CAAA,CAAA,CAAA,EAAO,EAAE,CAAT,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,EAAqC,CAArC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A,CAAA,CAAA,CAAA,CAAgC,CAAC;IAC/B,CAAF,CAAA,CAAA,CAAM,EAAE,CAAR,CAAU;IACR,CAAF,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAW,EAAE,CAAb,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAsB;IACpB,CAAF,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAU,EAAE,CAAZ,CAAA,CAAA,CAAA,CAAiB;AACjB,CAAC;"}
@@ -24,7 +24,7 @@ export declare namespace useSuspenseFragment {
24
24
  * (such as `id`) identifying the entity object from which the fragment will
25
25
  * be retrieved, or a `{ __ref: "..." }` reference, or a `string` ID (uncommon).
26
26
  */
27
- from: useSuspenseFragment.FromValue<TData> | Array<useSuspenseFragment.FromValue<TData>>;
27
+ from: useSuspenseFragment.FromOptionValue<TData> | Array<useSuspenseFragment.FromOptionValue<TData> | null> | null;
28
28
  optimistic?: boolean;
29
29
  /**
30
30
  * The instance of `ApolloClient` to use to look up the fragment.
@@ -47,7 +47,7 @@ export declare namespace useSuspenseFragment {
47
47
  /**
48
48
  * Acceptable values provided to the `from` option.
49
49
  */
50
- type FromValue<TData> = ApolloCache.WatchFragmentFromValue<TData>;
50
+ type FromOptionValue<TData> = ApolloCache.FromOptionValue<TData>;
51
51
  interface Result<TData> {
52
52
  data: DataValue.Complete<MaybeMasked<TData>>;
53
53
  }
@@ -66,7 +66,7 @@ export declare namespace useSuspenseFragment {
66
66
  }
67
67
  /** #TODO documentation */
68
68
  export declare function useSuspenseFragment<TData = unknown, TVariables extends OperationVariables = OperationVariables>(options: useSuspenseFragment.Options<TData, TVariables> & {
69
- from: Array<NonNullable<useSuspenseFragment.FromValue<TData>>>;
69
+ from: Array<useSuspenseFragment.FromOptionValue<TData>>;
70
70
  }): useSuspenseFragment.Result<Array<TData>>;
71
71
  /**
72
72
  * #TODO documentation
@@ -78,13 +78,13 @@ export declare function useSuspenseFragment<TData = unknown, TVariables extends
78
78
  * #TODO documentation
79
79
  */
80
80
  export declare function useSuspenseFragment<TData = unknown, TVariables extends OperationVariables = OperationVariables>(options: useSuspenseFragment.Options<TData, TVariables> & {
81
- from: Array<useSuspenseFragment.FromValue<TData>>;
81
+ from: Array<useSuspenseFragment.FromOptionValue<TData> | null>;
82
82
  }): useSuspenseFragment.Result<Array<TData | null>>;
83
83
  /**
84
84
  * #TODO documentation
85
85
  */
86
86
  export declare function useSuspenseFragment<TData, TVariables extends OperationVariables = OperationVariables>(options: useSuspenseFragment.Options<TData, TVariables> & {
87
- from: NonNullable<useSuspenseFragment.FromValue<TData>>;
87
+ from: useSuspenseFragment.FromOptionValue<TData>;
88
88
  }): useSuspenseFragment.Result<TData>;
89
89
  /**
90
90
  * #TODO documentation
@@ -96,7 +96,7 @@ export declare function useSuspenseFragment<TData, TVariables extends OperationV
96
96
  * #TODO documentation
97
97
  */
98
98
  export declare function useSuspenseFragment<TData, TVariables extends OperationVariables = OperationVariables>(options: useSuspenseFragment.Options<TData, TVariables> & {
99
- from: useSuspenseFragment.FromValue<TData>;
99
+ from: useSuspenseFragment.FromOptionValue<TData> | null;
100
100
  }): useSuspenseFragment.Result<TData | null>;
101
101
  /**
102
102
  * #TODO documentation
@@ -1 +1 @@
1
- {"version":3,"file":"useSuspenseFragment.js","sourceRoot":"","sources":["../../../src/react/hooks/useSuspenseFragment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAU/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAOjE,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAuJvD,MAAM,UAAU,mBAAmB,CAIjC,OAAuD;IAEvD,aA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Node,\n} from \"@apollo/client\";\nimport type { ApolloCache } from \"@apollo/client/cache\";\nimport { canonicalStringify } from \"@apollo/client/cache\";\nimport type { MaybeMasked } from \"@apollo/client/masking\";\nimport type { FragmentKey } from \"@apollo/client/react/internal\";\nimport { getSuspenseCache } from \"@apollo/client/react/internal\";\nimport type {\n DocumentationTypes as UtilityDocumentationTypes,\n NoInfer,\n VariablesOption,\n} from \"@apollo/client/utilities/internal\";\n\nimport { __use } from \"./internal/__use.js\";\nimport { useDeepMemo, wrapHook } from \"./internal/index.js\";\nimport { useApolloClient } from \"./useApolloClient.js\";\n\nexport declare namespace useSuspenseFragment {\n import _self = useSuspenseFragment;\n export namespace Base {\n export type 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 * An object or array containing a `__typename` and primary key fields\n * (such as `id`) identifying the entity object from which the fragment will\n * be retrieved, or a `{ __ref: \"...\" }` reference, or a `string` ID (uncommon).\n */\n from:\n | useSuspenseFragment.FromValue<TData>\n | Array<useSuspenseFragment.FromValue<TData>>;\n\n // Override this field to make it optional (default: true).\n optimistic?: boolean;\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 export type Options<\n TData,\n TVariables extends OperationVariables,\n > = Base.Options<TData, TVariables> & VariablesOption<NoInfer<TVariables>>;\n\n export namespace DocumentationTypes {\n export namespace useSuspenseFragment {\n export interface Options<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n > extends Base.Options<TData, TVariables>,\n UtilityDocumentationTypes.VariableOptions<TVariables> {}\n }\n }\n\n /**\n * Acceptable values provided to the `from` option.\n */\n export type FromValue<TData> = ApolloCache.WatchFragmentFromValue<TData>;\n\n export interface Result<TData> {\n data: DataValue.Complete<MaybeMasked<TData>>;\n }\n export namespace DocumentationTypes {\n export namespace useSuspenseFragment {\n export interface Result<TData = unknown> extends _self.Result<TData> {}\n }\n }\n\n export namespace DocumentationTypes {\n /** {@inheritDoc @apollo/client/react!useSuspenseFragment:function(1)} */\n export function useSuspenseFragment<\n TData,\n TVariables extends OperationVariables = OperationVariables,\n >(\n options: useSuspenseFragment.Options<TData, TVariables>\n ): useSuspenseFragment.Result<TData>;\n }\n}\n\n/** #TODO documentation */\nexport function useSuspenseFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useSuspenseFragment.Options<TData, TVariables> & {\n from: Array<NonNullable<useSuspenseFragment.FromValue<TData>>>;\n }\n): useSuspenseFragment.Result<Array<TData>>;\n\n/** {@inheritDoc @apollo/client/react!useSuspenseFragment:function(1)} */\nexport function useSuspenseFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useSuspenseFragment.Options<TData, TVariables> & {\n from: Array<null>;\n }\n): useSuspenseFragment.Result<Array<null>>;\n\n/** {@inheritDoc @apollo/client/react!useSuspenseFragment:function(1)} */\nexport function useSuspenseFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useSuspenseFragment.Options<TData, TVariables> & {\n from: Array<useSuspenseFragment.FromValue<TData>>;\n }\n): useSuspenseFragment.Result<Array<TData | null>>;\n\n/** {@inheritDoc @apollo/client/react!useSuspenseFragment:function(1)} */\nexport function useSuspenseFragment<\n TData,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useSuspenseFragment.Options<TData, TVariables> & {\n from: NonNullable<useSuspenseFragment.FromValue<TData>>;\n }\n): useSuspenseFragment.Result<TData>;\n\n/** {@inheritDoc @apollo/client/react!useSuspenseFragment:function(1)} */\nexport function useSuspenseFragment<\n TData,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useSuspenseFragment.Options<TData, TVariables> & {\n from: null;\n }\n): useSuspenseFragment.Result<null>;\n\n/** {@inheritDoc @apollo/client/react!useSuspenseFragment:function(1)} */\nexport function useSuspenseFragment<\n TData,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useSuspenseFragment.Options<TData, TVariables> & {\n from: useSuspenseFragment.FromValue<TData>;\n }\n): useSuspenseFragment.Result<TData | null>;\n\n/** {@inheritDoc @apollo/client/react!useSuspenseFragment:function(1)} */\nexport function useSuspenseFragment<\n TData,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useSuspenseFragment.Options<TData, TVariables>\n): useSuspenseFragment.Result<TData>;\n\nexport function useSuspenseFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useSuspenseFragment.Options<TData, TVariables>\n): useSuspenseFragment.Result<TData | null> {\n \"use no memo\";\n return wrapHook(\n \"useSuspenseFragment\",\n useSuspenseFragment_,\n useApolloClient(typeof options === \"object\" ? options.client : undefined)\n )(options);\n}\n\nfunction useSuspenseFragment_<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useSuspenseFragment.Options<TData, TVariables>\n): useSuspenseFragment.Result<TData | null> {\n const client = useApolloClient(options.client);\n const { from, variables } = options;\n const { cache } = client;\n\n const ids = useDeepMemo(() => {\n return Array.isArray(from) ?\n from.map((id) => toStringId(cache, id))\n : toStringId(cache, from);\n }, [cache, from]);\n const idString = React.useMemo(\n () => (Array.isArray(ids) ? ids.join(\",\") : ids),\n [ids]\n );\n\n const fragmentRef = getSuspenseCache(client).getFragmentRef(\n [options.fragment, canonicalStringify(variables), idString],\n client,\n { ...options, variables: variables as TVariables, from: ids }\n );\n\n let [current, setPromise] = React.useState<\n [FragmentKey, Promise<MaybeMasked<TData> | null>]\n >([fragmentRef.key, fragmentRef.promise]);\n\n React.useEffect(() => {\n const dispose = fragmentRef.retain();\n const removeListener = fragmentRef.listen((promise) => {\n setPromise([fragmentRef.key, promise]);\n });\n\n return () => {\n dispose();\n removeListener();\n };\n }, [fragmentRef]);\n\n if (current[0] !== fragmentRef.key) {\n // eslint-disable-next-line react-hooks/immutability\n current[0] = fragmentRef.key;\n // eslint-disable-next-line react-hooks/immutability\n current[1] = fragmentRef.promise;\n }\n\n const data = __use(current[1]);\n\n return { data };\n}\n\nfunction toStringId(\n cache: ApolloCache,\n from: useSuspenseFragment.FromValue<any>\n) {\n return (\n typeof from === \"string\" ? from\n : from === null ? null\n : cache.identify(from)) as string | null;\n}\n"]}
1
+ {"version":3,"file":"useSuspenseFragment.js","sourceRoot":"","sources":["../../../src/react/hooks/useSuspenseFragment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAU/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAOjE,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAwJvD,MAAM,UAAU,mBAAmB,CAIjC,OAAuD;IAEvD,aAAa,CAAC;IACd,OAAO,QAAQ,CACb,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,CAAC,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAC1E,CAAC,OAAO,CAAC,CAAC;AACb,CAAC;AAED,SAAS,oBAAoB,CAI3B,OAAuD;IAEvD,MAAM,MAAM,GAAG,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/C,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,OA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AO,CAAC,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;QAEH,OAAO,GAAG,EAAE;YACV,OAAO,EAAE,CAAC;YACV,cAAc,EAAE,CAAC;QACnB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAElB,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,WAAW,CAAC,GAAG,EAAE,CAAC;QACnC,oDAAoD;QACpD,OAAO,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC;QAC7B,oDAAoD;QACpD,OAAO,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,OAAO,CAAC;IACnC,CAAC;IAED,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAE/B,OAAO,EAAE,IAAI,EAAE,CAAC;AAClB,CAAC;AAED,SAAS,UAAU,CACjB,KAAkB,EAClB,IAAqD;IAErD,OAAO,CACL,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI;QAC/B,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI;YACtB,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAkB,CAAC;AAC7C,CAAC","sourcesContent":["import * as React from \"react\";\n\nimport type {\n ApolloClient,\n DataValue,\n DocumentNode,\n OperationVariables,\n TypedDocumentNode,\n} from \"@apollo/client\";\nimport type { ApolloCache } from \"@apollo/client/cache\";\nimport { canonicalStringify } from \"@apollo/client/cache\";\nimport type { MaybeMasked } from \"@apollo/client/masking\";\nimport type { FragmentKey } from \"@apollo/client/react/internal\";\nimport { getSuspenseCache } from \"@apollo/client/react/internal\";\nimport type {\n DocumentationTypes as UtilityDocumentationTypes,\n NoInfer,\n VariablesOption,\n} from \"@apollo/client/utilities/internal\";\n\nimport { __use } from \"./internal/__use.js\";\nimport { useDeepMemo, wrapHook } from \"./internal/index.js\";\nimport { useApolloClient } from \"./useApolloClient.js\";\n\nexport declare namespace useSuspenseFragment {\n import _self = useSuspenseFragment;\n export namespace Base {\n export type 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 * An object or array containing a `__typename` and primary key fields\n * (such as `id`) identifying the entity object from which the fragment will\n * be retrieved, or a `{ __ref: \"...\" }` reference, or a `string` ID (uncommon).\n */\n from:\n | useSuspenseFragment.FromOptionValue<TData>\n | Array<useSuspenseFragment.FromOptionValue<TData> | null>\n | null;\n\n // Override this field to make it optional (default: true).\n optimistic?: boolean;\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 export type Options<\n TData,\n TVariables extends OperationVariables,\n > = Base.Options<TData, TVariables> & VariablesOption<NoInfer<TVariables>>;\n\n export namespace DocumentationTypes {\n export namespace useSuspenseFragment {\n export interface Options<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n > extends Base.Options<TData, TVariables>,\n UtilityDocumentationTypes.VariableOptions<TVariables> {}\n }\n }\n\n /**\n * Acceptable values provided to the `from` option.\n */\n export type FromOptionValue<TData> = ApolloCache.FromOptionValue<TData>;\n\n export interface Result<TData> {\n data: DataValue.Complete<MaybeMasked<TData>>;\n }\n export namespace DocumentationTypes {\n export namespace useSuspenseFragment {\n export interface Result<TData = unknown> extends _self.Result<TData> {}\n }\n }\n\n export namespace DocumentationTypes {\n /** {@inheritDoc @apollo/client/react!useSuspenseFragment:function(1)} */\n export function useSuspenseFragment<\n TData,\n TVariables extends OperationVariables = OperationVariables,\n >(\n options: useSuspenseFragment.Options<TData, TVariables>\n ): useSuspenseFragment.Result<TData>;\n }\n}\n\n/** #TODO documentation */\nexport function useSuspenseFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useSuspenseFragment.Options<TData, TVariables> & {\n from: Array<useSuspenseFragment.FromOptionValue<TData>>;\n }\n): useSuspenseFragment.Result<Array<TData>>;\n\n/** {@inheritDoc @apollo/client/react!useSuspenseFragment:function(1)} */\nexport function useSuspenseFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useSuspenseFragment.Options<TData, TVariables> & {\n from: Array<null>;\n }\n): useSuspenseFragment.Result<Array<null>>;\n\n/** {@inheritDoc @apollo/client/react!useSuspenseFragment:function(1)} */\nexport function useSuspenseFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useSuspenseFragment.Options<TData, TVariables> & {\n from: Array<useSuspenseFragment.FromOptionValue<TData> | null>;\n }\n): useSuspenseFragment.Result<Array<TData | null>>;\n\n/** {@inheritDoc @apollo/client/react!useSuspenseFragment:function(1)} */\nexport function useSuspenseFragment<\n TData,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useSuspenseFragment.Options<TData, TVariables> & {\n from: useSuspenseFragment.FromOptionValue<TData>;\n }\n): useSuspenseFragment.Result<TData>;\n\n/** {@inheritDoc @apollo/client/react!useSuspenseFragment:function(1)} */\nexport function useSuspenseFragment<\n TData,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useSuspenseFragment.Options<TData, TVariables> & {\n from: null;\n }\n): useSuspenseFragment.Result<null>;\n\n/** {@inheritDoc @apollo/client/react!useSuspenseFragment:function(1)} */\nexport function useSuspenseFragment<\n TData,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useSuspenseFragment.Options<TData, TVariables> & {\n from: useSuspenseFragment.FromOptionValue<TData> | null;\n }\n): useSuspenseFragment.Result<TData | null>;\n\n/** {@inheritDoc @apollo/client/react!useSuspenseFragment:function(1)} */\nexport function useSuspenseFragment<\n TData,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useSuspenseFragment.Options<TData, TVariables>\n): useSuspenseFragment.Result<TData>;\n\nexport function useSuspenseFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useSuspenseFragment.Options<TData, TVariables>\n): useSuspenseFragment.Result<TData | null> {\n \"use no memo\";\n return wrapHook(\n \"useSuspenseFragment\",\n useSuspenseFragment_,\n useApolloClient(typeof options === \"object\" ? options.client : undefined)\n )(options);\n}\n\nfunction useSuspenseFragment_<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n options: useSuspenseFragment.Options<TData, TVariables>\n): useSuspenseFragment.Result<TData | null> {\n const client = useApolloClient(options.client);\n const { from, variables } = options;\n const { cache } = client;\n\n const ids = useDeepMemo(() => {\n return Array.isArray(from) ?\n from.map((id) => toStringId(cache, id))\n : toStringId(cache, from);\n }, [cache, from]);\n const idString = React.useMemo(\n () => (Array.isArray(ids) ? ids.join(\",\") : ids),\n [ids]\n );\n\n const fragmentRef = getSuspenseCache(client).getFragmentRef(\n [options.fragment, canonicalStringify(variables), idString],\n client,\n { ...options, variables: variables as TVariables, from: ids }\n );\n\n let [current, setPromise] = React.useState<\n [FragmentKey, Promise<MaybeMasked<TData> | null>]\n >([fragmentRef.key, fragmentRef.promise]);\n\n React.useEffect(() => {\n const dispose = fragmentRef.retain();\n const removeListener = fragmentRef.listen((promise) => {\n setPromise([fragmentRef.key, promise]);\n });\n\n return () => {\n dispose();\n removeListener();\n };\n }, [fragmentRef]);\n\n if (current[0] !== fragmentRef.key) {\n // eslint-disable-next-line react-hooks/immutability\n current[0] = fragmentRef.key;\n // eslint-disable-next-line react-hooks/immutability\n current[1] = fragmentRef.promise;\n }\n\n const data = __use(current[1]);\n\n return { data };\n}\n\nfunction toStringId(\n cache: ApolloCache,\n from: useSuspenseFragment.FromOptionValue<any> | null\n) {\n return (\n typeof from === \"string\" ? from\n : from === null ? null\n : cache.identify(from)) as string | null;\n}\n"]}
package/version.js CHANGED
@@ -1,3 +1,3 @@
1
- export const version = "4.1.0-alpha.5";
1
+ export const version = "4.1.0-alpha.7";
2
2
  export const build = "esm";
3
3
  //# sourceMappingURL=version.js.map