@apollo/client 4.0.0-rc.11 → 4.0.0-rc.13
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/README.md +4 -0
- package/__cjs/core/ObservableQuery.d.cts +1 -1
- package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs +2 -2
- package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs.map +1 -1
- package/__cjs/link/remove-typename/removeTypenameFromVariables.d.cts +2 -2
- package/__cjs/local-state/LocalState.cjs.map +1 -1
- package/__cjs/masking/types.d.cts +5 -2
- package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useBackgroundQuery.d.cts +2 -1
- package/__cjs/react/hooks/useLazyQuery.d.cts +1 -1
- package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLoadableQuery.d.cts +2 -1
- package/__cjs/react/hooks/useQuery.d.cts +1 -1
- package/__cjs/react/hooks/useQueryRefHandlers.cjs.map +1 -1
- package/__cjs/react/hooks/useQueryRefHandlers.d.cts +2 -1
- package/__cjs/react/hooks/useReadQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useReadQuery.d.cts +1 -1
- package/__cjs/react/query-preloader/createQueryPreloader.cjs.map +1 -1
- package/__cjs/react/query-preloader/createQueryPreloader.d.cts +1 -1
- package/__cjs/react/types/deprecated.d.cts +1 -1
- package/__cjs/react/types/types.documentation.d.cts +1 -1
- package/__cjs/utilities/internal/types/DocumentationTypes.d.cts +1 -1
- package/__cjs/v4-migration.cjs +9 -0
- package/__cjs/v4-migration.cjs.map +1 -0
- package/__cjs/v4-migration.d.cts +818 -0
- package/__cjs/version.cjs +1 -1
- package/core/ObservableQuery.d.ts +1 -1
- package/legacyEntryPoints/v4-migration/index.d.ts +1 -0
- package/legacyEntryPoints/v4-migration/index.js +1 -0
- package/legacyEntryPoints/v4-migration/v4-migration.cjs +1 -0
- package/legacyEntryPoints/v4-migration/v4-migration.d.cts +1 -0
- package/link/remove-typename/removeTypenameFromVariables.d.ts +2 -2
- package/link/remove-typename/removeTypenameFromVariables.js +2 -2
- package/link/remove-typename/removeTypenameFromVariables.js.map +1 -1
- package/local-state/LocalState.js.map +1 -1
- package/masking/types.d.ts +5 -2
- package/masking/types.js.map +1 -1
- package/package.json +8 -2
- package/react/hooks/useBackgroundQuery.d.ts +2 -1
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useLazyQuery.d.ts +1 -1
- package/react/hooks/useLoadableQuery.d.ts +2 -1
- package/react/hooks/useLoadableQuery.js.map +1 -1
- package/react/hooks/useQuery.d.ts +1 -1
- package/react/hooks/useQueryRefHandlers.d.ts +2 -1
- package/react/hooks/useQueryRefHandlers.js.map +1 -1
- package/react/hooks/useReadQuery.d.ts +1 -1
- package/react/hooks/useReadQuery.js.map +1 -1
- package/react/hooks-compiled/useBackgroundQuery.d.ts +2 -1
- package/react/hooks-compiled/useBackgroundQuery.js.map +1 -1
- package/react/hooks-compiled/useLazyQuery.d.ts +1 -1
- package/react/hooks-compiled/useLoadableQuery.d.ts +2 -1
- package/react/hooks-compiled/useLoadableQuery.js.map +1 -1
- package/react/hooks-compiled/useQuery.d.ts +1 -1
- package/react/hooks-compiled/useQueryRefHandlers.d.ts +2 -1
- package/react/hooks-compiled/useQueryRefHandlers.js.map +1 -1
- package/react/hooks-compiled/useReadQuery.d.ts +1 -1
- package/react/hooks-compiled/useReadQuery.js.map +1 -1
- package/react/query-preloader/createQueryPreloader.d.ts +1 -1
- package/react/query-preloader/createQueryPreloader.js.map +1 -1
- package/react/types/deprecated.d.ts +1 -1
- package/react/types/deprecated.js.map +1 -1
- package/react/types/types.documentation.d.ts +1 -1
- package/react/types/types.documentation.js.map +1 -1
- package/utilities/internal/types/DocumentationTypes.d.ts +1 -1
- package/v4-migration.d.ts +818 -0
- package/v4-migration.js +8 -0
- package/v4-migration.js.map +1 -0
- package/version.js +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLoadableQuery.js","sources":["../../../src/react/hooks/useLoadableQuery.ts"],"sourcesContent":["import * as React from \"react\";\n\nimport type {\n ApolloClient,\n DataState,\n DefaultContext,\n DocumentNode,\n ErrorPolicy,\n ObservableQuery,\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 {\n CacheKey,\n FetchMoreFunction,\n QueryRef,\n RefetchFunction,\n} from \"@apollo/client/react/internal\";\nimport {\n assertWrappedQueryRef,\n getSuspenseCache,\n unwrapQueryRef,\n updateWrappedQueryRef,\n wrapQueryRef,\n} from \"@apollo/client/react/internal\";\nimport { __DEV__ } from \"@apollo/client/utilities/environment\";\nimport { invariant } from \"@apollo/client/utilities/invariant\";\n\nimport { __use, useDeepMemo, useRenderGuard } from \"./internal/index.js\";\nimport { validateSuspenseHookOptions } from \"./internal/validateSuspenseHookOptions.js\";\nimport { useApolloClient } from \"./useApolloClient.js\";\n\ntype ResetFunction = () => void;\n\nexport declare namespace useLoadableQuery {\n export type LoadQueryFunction<TVariables extends OperationVariables> = (\n // Use variadic args to handle cases where TVariables is type `never`, in\n // which case we don't want to allow a variables argument. In other\n // words, we don't want to allow variables to be passed as an argument to this\n // function if the query does not expect variables in the document.\n ...args: {} extends TVariables ? [variables?: TVariables]\n : [variables: TVariables]\n ) => void;\n\n export type Result<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n TStates extends\n DataState<TData>[\"dataState\"] = DataState<TData>[\"dataState\"],\n > = [\n loadQuery: LoadQueryFunction<TVariables>,\n queryRef: QueryRef<TData, TVariables, TStates> | null,\n handlers: Handlers<TData, TVariables>,\n ];\n export interface Handlers<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n > {\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#fetchMore:member} */\n fetchMore: FetchMoreFunction<TData, TVariables>;\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#refetch:member} */\n refetch: RefetchFunction<TData, TVariables>;\n /** {@inheritDoc @apollo/client!ObservableQuery#subscribeToMore:member(1)} */\n subscribeToMore: SubscribeToMoreFunction<TData, TVariables>;\n /**\n * A function that resets the `queryRef` back to `null`.\n */\n reset: ResetFunction;\n }\n\n export type FetchPolicy = Extract<\n WatchQueryFetchPolicy,\n \"cache-first\" | \"network-only\" | \"no-cache\" | \"cache-and-network\"\n >;\n\n export interface Options {\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#client:member} */\n client?: ApolloClient;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#context:member} */\n context?: DefaultContext;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#errorPolicy:member} */\n errorPolicy?: ErrorPolicy;\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 /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#refetchWritePolicy:member} */\n refetchWritePolicy?: RefetchWritePolicy;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#returnPartialData:member} */\n returnPartialData?: boolean;\n }\n\n export namespace DocumentationTypes {\n /** {@inheritDoc @apollo/client/react!useLoadableQuery:function(1)} */\n export function useLoadableQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useLoadableQuery.Options\n ): useLoadableQuery.Result<TData, TVariables>;\n }\n}\n\n/**\n * A hook for imperatively loading a query, such as responding to a user\n * interaction.\n *\n * > Refer to the [Suspense - Fetching in response to user interaction](https://www.apollographql.com/docs/react/data/suspense#fetching-in-response-to-user-interaction) section for a more in-depth overview of `useLoadableQuery`.\n *\n * @example\n *\n * ```jsx\n * import { gql, useLoadableQuery } from \"@apollo/client\";\n *\n * const GET_GREETING = gql`\n * query GetGreeting($language: String!) {\n * greeting(language: $language) {\n * message\n * }\n * }\n * `;\n *\n * function App() {\n * const [loadGreeting, queryRef] = useLoadableQuery(GET_GREETING);\n *\n * return (\n * <>\n * <button onClick={() => loadGreeting({ language: \"english\" })}>\n * Load greeting\n * </button>\n * <Suspense fallback={<div>Loading...</div>}>\n * {queryRef && <Hello queryRef={queryRef} />}\n * </Suspense>\n * </>\n * );\n * }\n *\n * function Hello({ queryRef }) {\n * const { data } = useReadQuery(queryRef);\n *\n * return <div>{data.greeting.message}</div>;\n * }\n * ```\n *\n * @param query - A GraphQL query document parsed into an AST by `gql`.\n * @param options - Options to control how the query is executed.\n * @returns A tuple in the form of `[loadQuery, queryRef, handlers]`\n */\nexport function useLoadableQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useLoadableQuery.Options & {\n returnPartialData: true;\n errorPolicy: \"ignore\" | \"all\";\n }\n): useLoadableQuery.Result<\n TData,\n TVariables,\n \"complete\" | \"streaming\" | \"partial\" | \"empty\"\n>;\n\n/** {@inheritDoc @apollo/client/react!useLoadableQuery:function(1)} */\nexport function useLoadableQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useLoadableQuery.Options & {\n errorPolicy: \"ignore\" | \"all\";\n }\n): useLoadableQuery.Result<\n TData,\n TVariables,\n \"complete\" | \"streaming\" | \"empty\"\n>;\n\n/** {@inheritDoc @apollo/client/react!useLoadableQuery:function(1)} */\nexport function useLoadableQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useLoadableQuery.Options & {\n returnPartialData: true;\n }\n): useLoadableQuery.Result<\n TData,\n TVariables,\n \"complete\" | \"streaming\" | \"partial\"\n>;\n\n/** {@inheritDoc @apollo/client/react!useLoadableQuery:function(1)} */\nexport function useLoadableQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options?: useLoadableQuery.Options\n): useLoadableQuery.Result<TData, TVariables, \"complete\" | \"streaming\">;\n\nexport function useLoadableQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useLoadableQuery.Options = {}\n): useLoadableQuery.Result<TData, TVariables> {\n const client = useApolloClient(options.client);\n const suspenseCache = getSuspenseCache(client);\n const watchQueryOptions = useWatchQueryOptions({ client, query, options });\n const { queryKey = [] } = options;\n\n const [queryRef, setQueryRef] = React.useState<QueryRef<\n TData,\n TVariables,\n DataState<TData>[\"dataState\"]\n > | null>(null);\n\n assertWrappedQueryRef(queryRef);\n\n const internalQueryRef = queryRef && unwrapQueryRef(queryRef);\n\n if (queryRef && internalQueryRef?.didChangeOptions(watchQueryOptions)) {\n const promise = internalQueryRef.applyOptions(watchQueryOptions);\n updateWrappedQueryRef(queryRef, promise);\n }\n\n const calledDuringRender = useRenderGuard();\n\n const fetchMore: FetchMoreFunction<TData, TVariables> = React.useCallback(\n (options) => {\n if (!internalQueryRef) {\n throw new Error(\n \"The query has not been loaded. Please load the query.\"\n );\n }\n\n const promise = internalQueryRef.fetchMore(options);\n\n setQueryRef(wrapQueryRef(internalQueryRef));\n\n return promise;\n },\n [internalQueryRef]\n );\n\n const refetch: RefetchFunction<TData, TVariables> = React.useCallback(\n (options) => {\n if (!internalQueryRef) {\n throw new Error(\n \"The query has not been loaded. Please load the query.\"\n );\n }\n\n const promise = internalQueryRef.refetch(options);\n\n setQueryRef(wrapQueryRef(internalQueryRef));\n\n return promise;\n },\n [internalQueryRef]\n );\n\n const loadQuery: useLoadableQuery.LoadQueryFunction<TVariables> =\n React.useCallback(\n (...args) => {\n invariant(\n !calledDuringRender(),\n \"useLoadableQuery: 'loadQuery' should not be called during render. To start a query during render, use the 'useBackgroundQuery' hook.\"\n );\n\n const [variables] = args;\n\n const cacheKey: CacheKey = [\n query,\n canonicalStringify(variables),\n ...([] as any[]).concat(queryKey),\n ];\n\n const queryRef = suspenseCache.getQueryRef(cacheKey, () =>\n client.watchQuery({\n ...watchQueryOptions,\n variables,\n } as ApolloClient.WatchQueryOptions<any, any>)\n );\n\n setQueryRef(wrapQueryRef(queryRef));\n },\n [\n query,\n queryKey,\n suspenseCache,\n watchQueryOptions,\n calledDuringRender,\n client,\n ]\n );\n\n const subscribeToMore: SubscribeToMoreFunction<TData, TVariables> =\n React.useCallback(\n (options) => {\n invariant(\n internalQueryRef,\n \"The query has not been loaded. Please load the query.\"\n );\n\n return internalQueryRef.observable.subscribeToMore(\n // TODO: The internalQueryRef doesn't have TVariables' type information so we have to cast it here\n options as any as ObservableQuery.SubscribeToMoreOptions<\n TData,\n OperationVariables\n >\n );\n },\n [internalQueryRef]\n );\n\n const reset: ResetFunction = React.useCallback(() => {\n setQueryRef(null);\n }, []);\n\n return [loadQuery, queryRef, { fetchMore, refetch, reset, subscribeToMore }];\n}\n\nfunction useWatchQueryOptions<TData, TVariables extends OperationVariables>({\n client,\n query,\n options,\n}: {\n client: ApolloClient;\n query: DocumentNode | TypedDocumentNode<TData, TVariables>;\n options: useLoadableQuery.Options;\n}): ApolloClient.WatchQueryOptions<TData, TVariables> {\n return useDeepMemo<ApolloClient.WatchQueryOptions<TData, TVariables>>(() => {\n const fetchPolicy =\n options.fetchPolicy ||\n client.defaultOptions.watchQuery?.fetchPolicy ||\n \"cache-first\";\n\n const watchQueryOptions = {\n ...options,\n fetchPolicy,\n query,\n notifyOnNetworkStatusChange: false,\n nextFetchPolicy: void 0,\n };\n\n if (__DEV__) {\n validateSuspenseHookOptions(watchQueryOptions as any);\n }\n\n return watchQueryOptions as ApolloClient.WatchQueryOptions<\n TData,\n TVariables\n >;\n }, [client, options, query]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A,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,EAA4C,CAA5C,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,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAuF;AACvF,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"}
|
|
1
|
+
{"version":3,"file":"useLoadableQuery.js","sources":["../../../src/react/hooks/useLoadableQuery.ts"],"sourcesContent":["import * as React from \"react\";\n\nimport type {\n ApolloClient,\n DataState,\n DefaultContext,\n DocumentNode,\n ErrorPolicy,\n ObservableQuery,\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 assertWrappedQueryRef,\n getSuspenseCache,\n unwrapQueryRef,\n updateWrappedQueryRef,\n wrapQueryRef,\n} from \"@apollo/client/react/internal\";\nimport { __DEV__ } from \"@apollo/client/utilities/environment\";\nimport { invariant } from \"@apollo/client/utilities/invariant\";\n\nimport { __use, useDeepMemo, useRenderGuard } from \"./internal/index.js\";\nimport { validateSuspenseHookOptions } from \"./internal/validateSuspenseHookOptions.js\";\nimport { useApolloClient } from \"./useApolloClient.js\";\n\ntype ResetFunction = () => void;\n\nexport declare namespace useLoadableQuery {\n export type LoadQueryFunction<TVariables extends OperationVariables> = (\n // Use variadic args to handle cases where TVariables is type `never`, in\n // which case we don't want to allow a variables argument. In other\n // words, we don't want to allow variables to be passed as an argument to this\n // function if the query does not expect variables in the document.\n ...args: {} extends TVariables ? [variables?: TVariables]\n : [variables: TVariables]\n ) => void;\n\n export type Result<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n TStates extends\n DataState<TData>[\"dataState\"] = DataState<TData>[\"dataState\"],\n > = [\n loadQuery: LoadQueryFunction<TVariables>,\n queryRef: QueryRef<TData, TVariables, TStates> | null,\n handlers: Handlers<TData, TVariables>,\n ];\n export interface Handlers<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n > {\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#fetchMore:member} */\n fetchMore: FetchMoreFunction<TData, TVariables>;\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#refetch:member} */\n refetch: RefetchFunction<TData, TVariables>;\n /** {@inheritDoc @apollo/client!ObservableQuery#subscribeToMore:member(1)} */\n subscribeToMore: SubscribeToMoreFunction<TData, TVariables>;\n /**\n * A function that resets the `queryRef` back to `null`.\n */\n reset: ResetFunction;\n }\n\n export type FetchPolicy = Extract<\n WatchQueryFetchPolicy,\n \"cache-first\" | \"network-only\" | \"no-cache\" | \"cache-and-network\"\n >;\n\n export interface Options {\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#client:member} */\n client?: ApolloClient;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#context:member} */\n context?: DefaultContext;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#errorPolicy:member} */\n errorPolicy?: ErrorPolicy;\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 /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#refetchWritePolicy:member} */\n refetchWritePolicy?: RefetchWritePolicy;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#returnPartialData:member} */\n returnPartialData?: boolean;\n }\n\n export namespace DocumentationTypes {\n /** {@inheritDoc @apollo/client/react!useLoadableQuery:function(1)} */\n export function useLoadableQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useLoadableQuery.Options\n ): useLoadableQuery.Result<TData, TVariables>;\n }\n}\n\n/**\n * A hook for imperatively loading a query, such as responding to a user\n * interaction.\n *\n * > Refer to the [Suspense - Fetching in response to user interaction](https://www.apollographql.com/docs/react/data/suspense#fetching-in-response-to-user-interaction) section for a more in-depth overview of `useLoadableQuery`.\n *\n * @example\n *\n * ```jsx\n * import { gql, useLoadableQuery } from \"@apollo/client\";\n *\n * const GET_GREETING = gql`\n * query GetGreeting($language: String!) {\n * greeting(language: $language) {\n * message\n * }\n * }\n * `;\n *\n * function App() {\n * const [loadGreeting, queryRef] = useLoadableQuery(GET_GREETING);\n *\n * return (\n * <>\n * <button onClick={() => loadGreeting({ language: \"english\" })}>\n * Load greeting\n * </button>\n * <Suspense fallback={<div>Loading...</div>}>\n * {queryRef && <Hello queryRef={queryRef} />}\n * </Suspense>\n * </>\n * );\n * }\n *\n * function Hello({ queryRef }) {\n * const { data } = useReadQuery(queryRef);\n *\n * return <div>{data.greeting.message}</div>;\n * }\n * ```\n *\n * @param query - A GraphQL query document parsed into an AST by `gql`.\n * @param options - Options to control how the query is executed.\n * @returns A tuple in the form of `[loadQuery, queryRef, handlers]`\n */\nexport function useLoadableQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useLoadableQuery.Options & {\n returnPartialData: true;\n errorPolicy: \"ignore\" | \"all\";\n }\n): useLoadableQuery.Result<\n TData,\n TVariables,\n \"complete\" | \"streaming\" | \"partial\" | \"empty\"\n>;\n\n/** {@inheritDoc @apollo/client/react!useLoadableQuery:function(1)} */\nexport function useLoadableQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useLoadableQuery.Options & {\n errorPolicy: \"ignore\" | \"all\";\n }\n): useLoadableQuery.Result<\n TData,\n TVariables,\n \"complete\" | \"streaming\" | \"empty\"\n>;\n\n/** {@inheritDoc @apollo/client/react!useLoadableQuery:function(1)} */\nexport function useLoadableQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useLoadableQuery.Options & {\n returnPartialData: true;\n }\n): useLoadableQuery.Result<\n TData,\n TVariables,\n \"complete\" | \"streaming\" | \"partial\"\n>;\n\n/** {@inheritDoc @apollo/client/react!useLoadableQuery:function(1)} */\nexport function useLoadableQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options?: useLoadableQuery.Options\n): useLoadableQuery.Result<TData, TVariables, \"complete\" | \"streaming\">;\n\nexport function useLoadableQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useLoadableQuery.Options = {}\n): useLoadableQuery.Result<TData, TVariables> {\n const client = useApolloClient(options.client);\n const suspenseCache = getSuspenseCache(client);\n const watchQueryOptions = useWatchQueryOptions({ client, query, options });\n const { queryKey = [] } = options;\n\n const [queryRef, setQueryRef] = React.useState<QueryRef<\n TData,\n TVariables,\n DataState<TData>[\"dataState\"]\n > | null>(null);\n\n assertWrappedQueryRef(queryRef);\n\n const internalQueryRef = queryRef && unwrapQueryRef(queryRef);\n\n if (queryRef && internalQueryRef?.didChangeOptions(watchQueryOptions)) {\n const promise = internalQueryRef.applyOptions(watchQueryOptions);\n updateWrappedQueryRef(queryRef, promise);\n }\n\n const calledDuringRender = useRenderGuard();\n\n const fetchMore: FetchMoreFunction<TData, TVariables> = React.useCallback(\n (options) => {\n if (!internalQueryRef) {\n throw new Error(\n \"The query has not been loaded. Please load the query.\"\n );\n }\n\n const promise = internalQueryRef.fetchMore(options);\n\n setQueryRef(wrapQueryRef(internalQueryRef));\n\n return promise;\n },\n [internalQueryRef]\n );\n\n const refetch: RefetchFunction<TData, TVariables> = React.useCallback(\n (options) => {\n if (!internalQueryRef) {\n throw new Error(\n \"The query has not been loaded. Please load the query.\"\n );\n }\n\n const promise = internalQueryRef.refetch(options);\n\n setQueryRef(wrapQueryRef(internalQueryRef));\n\n return promise;\n },\n [internalQueryRef]\n );\n\n const loadQuery: useLoadableQuery.LoadQueryFunction<TVariables> =\n React.useCallback(\n (...args) => {\n invariant(\n !calledDuringRender(),\n \"useLoadableQuery: 'loadQuery' should not be called during render. To start a query during render, use the 'useBackgroundQuery' hook.\"\n );\n\n const [variables] = args;\n\n const cacheKey: CacheKey = [\n query,\n canonicalStringify(variables),\n ...([] as any[]).concat(queryKey),\n ];\n\n const queryRef = suspenseCache.getQueryRef(cacheKey, () =>\n client.watchQuery({\n ...watchQueryOptions,\n variables,\n } as ApolloClient.WatchQueryOptions<any, any>)\n );\n\n setQueryRef(wrapQueryRef(queryRef));\n },\n [\n query,\n queryKey,\n suspenseCache,\n watchQueryOptions,\n calledDuringRender,\n client,\n ]\n );\n\n const subscribeToMore: SubscribeToMoreFunction<TData, TVariables> =\n React.useCallback(\n (options) => {\n invariant(\n internalQueryRef,\n \"The query has not been loaded. Please load the query.\"\n );\n\n return internalQueryRef.observable.subscribeToMore(\n // TODO: The internalQueryRef doesn't have TVariables' type information so we have to cast it here\n options as any as ObservableQuery.SubscribeToMoreOptions<\n TData,\n OperationVariables\n >\n );\n },\n [internalQueryRef]\n );\n\n const reset: ResetFunction = React.useCallback(() => {\n setQueryRef(null);\n }, []);\n\n return [loadQuery, queryRef, { fetchMore, refetch, reset, subscribeToMore }];\n}\n\nfunction useWatchQueryOptions<TData, TVariables extends OperationVariables>({\n client,\n query,\n options,\n}: {\n client: ApolloClient;\n query: DocumentNode | TypedDocumentNode<TData, TVariables>;\n options: useLoadableQuery.Options;\n}): ApolloClient.WatchQueryOptions<TData, TVariables> {\n return useDeepMemo<ApolloClient.WatchQueryOptions<TData, TVariables>>(() => {\n const fetchPolicy =\n options.fetchPolicy ||\n client.defaultOptions.watchQuery?.fetchPolicy ||\n \"cache-first\";\n\n const watchQueryOptions = {\n ...options,\n fetchPolicy,\n query,\n notifyOnNetworkStatusChange: false,\n nextFetchPolicy: void 0,\n };\n\n if (__DEV__) {\n validateSuspenseHookOptions(watchQueryOptions as any);\n }\n\n return watchQueryOptions as ApolloClient.WatchQueryOptions<\n TData,\n TVariables\n >;\n }, [client, options, query]);\n}\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;AAe9B,CAAA,CAAA,CAAA,CAAA,CAAA,EAAO,EAAE,CAAT,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,EAAmC,CAAnC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAy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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"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { DataState, OperationVariables } from "@apollo/client";
|
|
2
2
|
import type { SubscribeToMoreFunction } from "@apollo/client";
|
|
3
|
-
import type {
|
|
3
|
+
import type { QueryRef } from "@apollo/client/react";
|
|
4
|
+
import type { FetchMoreFunction, RefetchFunction } from "@apollo/client/react/internal";
|
|
4
5
|
export declare namespace useQueryRefHandlers {
|
|
5
6
|
interface Result<TData = unknown, TVariables extends OperationVariables = OperationVariables> {
|
|
6
7
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQueryRefHandlers.js","sources":["../../../src/react/hooks/useQueryRefHandlers.ts"],"sourcesContent":["import * as React from \"react\";\n\nimport type { DataState, OperationVariables } from \"@apollo/client\";\nimport type { SubscribeToMoreFunction } from \"@apollo/client\";\nimport type { ApolloClient } from \"@apollo/client\";\nimport type { ObservableQuery } from \"@apollo/client\";\nimport type {\n FetchMoreFunction,\n
|
|
1
|
+
{"version":3,"file":"useQueryRefHandlers.js","sources":["../../../src/react/hooks/useQueryRefHandlers.ts"],"sourcesContent":["import * as React from \"react\";\n\nimport type { DataState, OperationVariables } from \"@apollo/client\";\nimport type { SubscribeToMoreFunction } from \"@apollo/client\";\nimport type { ApolloClient } from \"@apollo/client\";\nimport type { ObservableQuery } from \"@apollo/client\";\nimport type { QueryRef } from \"@apollo/client/react\";\nimport type {\n FetchMoreFunction,\n RefetchFunction,\n} from \"@apollo/client/react/internal\";\nimport {\n assertWrappedQueryRef,\n getWrappedPromise,\n unwrapQueryRef,\n updateWrappedQueryRef,\n wrapQueryRef,\n} from \"@apollo/client/react/internal\";\n\nimport { wrapHook } from \"./internal/index.js\";\nimport { useApolloClient } from \"./useApolloClient.js\";\n\nexport declare namespace useQueryRefHandlers {\n export interface Result<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n > {\n /** {@inheritDoc @apollo/client!ObservableQuery#refetch:member(1)} */\n refetch: RefetchFunction<TData, TVariables>;\n /** {@inheritDoc @apollo/client!ObservableQuery#fetchMore:member(1)} */\n fetchMore: FetchMoreFunction<TData, TVariables>;\n /** {@inheritDoc @apollo/client!ObservableQuery#subscribeToMore:member(1)} */\n subscribeToMore: SubscribeToMoreFunction<TData, TVariables>;\n }\n\n export namespace DocumentationTypes {\n /** {@inheritDoc @apollo/client/react!useQueryRefHandlers:function(1)} */\n export function useQueryRefHandlers<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n >(\n queryRef: QueryRef<TData, TVariables>\n ): useQueryRefHandlers.Result<TData, TVariables>;\n }\n}\n\n/**\n * A React hook that returns a `refetch` and `fetchMore` function for a given\n * `queryRef`.\n *\n * This is useful to get access to handlers for a `queryRef` that was created by\n * `createQueryPreloader` or when the handlers for a `queryRef` produced in\n * a different component are inaccessible.\n *\n * @example\n *\n * ```tsx\n * const MyComponent({ queryRef }) {\n * const { refetch, fetchMore } = useQueryRefHandlers(queryRef);\n *\n * // ...\n * }\n * ```\n *\n * @param queryRef - A `QueryRef` returned from `useBackgroundQuery`, `useLoadableQuery`, or `createQueryPreloader`.\n */\nexport function useQueryRefHandlers<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n queryRef: QueryRef<TData, TVariables, DataState<TData>[\"dataState\"]>\n): useQueryRefHandlers.Result<TData, TVariables> {\n \"use no memo\";\n const unwrapped = unwrapQueryRef(queryRef);\n const clientOrObsQuery = useApolloClient(\n unwrapped ?\n // passing an `ObservableQuery` is not supported by the types, but it will\n // return any truthy value that is passed in as an override so we cast the result\n (unwrapped[\"observable\"] as any)\n : undefined\n ) as ApolloClient | ObservableQuery<TData>;\n\n return wrapHook(\n \"useQueryRefHandlers\",\n // eslint-disable-next-line react-compiler/react-compiler\n useQueryRefHandlers_,\n clientOrObsQuery\n )(queryRef);\n}\n\nfunction useQueryRefHandlers_<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n queryRef: QueryRef<TData, TVariables, DataState<TData>[\"dataState\"]>\n): useQueryRefHandlers.Result<TData, TVariables> {\n assertWrappedQueryRef(queryRef);\n const [previousQueryRef, setPreviousQueryRef] = React.useState(queryRef);\n const [wrappedQueryRef, setWrappedQueryRef] = React.useState(queryRef);\n const internalQueryRef = unwrapQueryRef(queryRef);\n\n // To ensure we can support React transitions, this hook needs to manage the\n // queryRef state and apply React's state value immediately to the existing\n // queryRef since this hook doesn't return the queryRef directly\n if (previousQueryRef !== queryRef) {\n setPreviousQueryRef(queryRef);\n setWrappedQueryRef(queryRef);\n } else {\n updateWrappedQueryRef(queryRef, getWrappedPromise(wrappedQueryRef));\n }\n\n const refetch: RefetchFunction<TData, TVariables> = React.useCallback(\n (variables) => {\n const promise = internalQueryRef.refetch(variables);\n\n setWrappedQueryRef(wrapQueryRef(internalQueryRef));\n\n return promise;\n },\n [internalQueryRef]\n );\n\n const fetchMore: FetchMoreFunction<TData, TVariables> = React.useCallback(\n (options) => {\n const promise = internalQueryRef.fetchMore(\n options as ObservableQuery.FetchMoreOptions<any, any>\n );\n\n setWrappedQueryRef(wrapQueryRef(internalQueryRef));\n\n return promise;\n },\n [internalQueryRef]\n );\n\n return {\n refetch,\n fetchMore,\n // TODO: The internalQueryRef doesn't have TVariables' type information so we have to cast it here\n subscribeToMore: internalQueryRef.observable\n .subscribeToMore as SubscribeToMoreFunction<TData, TVariables>,\n };\n}\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,CAA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AAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;IACI,CAAJ,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAwB,EACpB,CADJ,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACoB,CACjB,CAAC,CAFJ,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAEY,CAAC;AACb"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DataState, ErrorLike, GetDataState, NetworkStatus } from "@apollo/client";
|
|
2
2
|
import type { MaybeMasked } from "@apollo/client/masking";
|
|
3
|
-
import type { QueryRef } from "@apollo/client/react
|
|
3
|
+
import type { QueryRef } from "@apollo/client/react";
|
|
4
4
|
import type { DocumentationTypes as UtilityDocumentationTypes } from "@apollo/client/utilities/internal";
|
|
5
5
|
export declare namespace useReadQuery {
|
|
6
6
|
namespace Base {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useReadQuery.js","sources":["../../../src/react/hooks/useReadQuery.ts"],"sourcesContent":["import * as React from \"react\";\n\nimport type {\n ApolloClient,\n DataState,\n ErrorLike,\n GetDataState,\n NetworkStatus,\n ObservableQuery,\n} from \"@apollo/client\";\nimport type { MaybeMasked } from \"@apollo/client/masking\";\nimport type { QueryRef } from \"@apollo/client/react/internal\";\nimport {\n assertWrappedQueryRef,\n getWrappedPromise,\n unwrapQueryRef,\n updateWrappedQueryRef,\n} from \"@apollo/client/react/internal\";\nimport type { DocumentationTypes as UtilityDocumentationTypes } from \"@apollo/client/utilities/internal\";\n\nimport { __use, wrapHook } from \"./internal/index.js\";\nimport { useApolloClient } from \"./useApolloClient.js\";\nimport { useSyncExternalStore } from \"./useSyncExternalStore.js\";\n\nexport declare namespace useReadQuery {\n export namespace Base {\n export interface Result<TData = unknown> {\n /**\n * {@inheritDoc @apollo/client!QueryResultDocumentation#error:member}\n *\n * This property can be ignored when using the default `errorPolicy` or an\n * `errorPolicy` of `none`. The hook will throw the error instead of setting\n * this property.\n */\n error: ErrorLike | undefined;\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#networkStatus:member} */\n networkStatus: NetworkStatus;\n }\n }\n export type Result<\n TData = unknown,\n TStates extends\n DataState<TData>[\"dataState\"] = DataState<TData>[\"dataState\"],\n > = Base.Result<TData> & GetDataState<MaybeMasked<TData>, TStates>;\n\n export namespace DocumentationTypes {\n namespace useReadQuery {\n export interface Result<TData = unknown>\n extends Base.Result<TData>,\n UtilityDocumentationTypes.DataState<TData> {}\n }\n\n /** {@inheritDoc @apollo/client/react!useReadQuery:function(1)} */\n export function useReadQuery<TData>(\n queryRef: QueryRef<TData>\n ): useReadQuery.Result<TData>;\n }\n}\n\n/**\n * For a detailed explanation of `useReadQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense#avoiding-request-waterfalls).\n *\n * @param queryRef - The `QueryRef` that was generated via `useBackgroundQuery`.\n * @returns An object containing the query result data, error, and network status.\n *\n * @example\n *\n * ```jsx\n * import { Suspense } from \"react\";\n * import { useBackgroundQuery, useReadQuery } from \"@apollo/client\";\n *\n * function Parent() {\n * const [queryRef] = useBackgroundQuery(query);\n *\n * return (\n * <Suspense fallback={<div>Loading...</div>}>\n * <Child queryRef={queryRef} />\n * </Suspense>\n * );\n * }\n *\n * function Child({ queryRef }) {\n * const { data } = useReadQuery(queryRef);\n *\n * return <div>{data.name}</div>;\n * }\n * ```\n */\nexport function useReadQuery<\n TData,\n TStates extends DataState<TData>[\"dataState\"],\n>(\n queryRef: QueryRef<TData, any, TStates>\n): useReadQuery.Result<TData, TStates> {\n \"use no memo\";\n const unwrapped = unwrapQueryRef(queryRef);\n const clientOrObsQuery = useApolloClient(\n unwrapped ?\n // passing an `ObservableQuery` is not supported by the types, but it will\n // return any truthy value that is passed in as an override so we cast the result\n (unwrapped[\"observable\"] as any)\n : undefined\n ) as ApolloClient | ObservableQuery<TData>;\n\n return wrapHook(\n \"useReadQuery\",\n // eslint-disable-next-line react-compiler/react-compiler\n useReadQuery_,\n clientOrObsQuery\n )(queryRef);\n}\n\nfunction useReadQuery_<TData, TStates extends DataState<TData>[\"dataState\"]>(\n queryRef: QueryRef<TData, any, TStates>\n): useReadQuery.Result<TData, TStates> {\n assertWrappedQueryRef(queryRef);\n const internalQueryRef = React.useMemo(\n () => unwrapQueryRef(queryRef),\n [queryRef]\n );\n\n const getPromise = React.useCallback(\n () => getWrappedPromise(queryRef),\n [queryRef]\n );\n\n if (internalQueryRef.disposed) {\n internalQueryRef.reinitialize();\n updateWrappedQueryRef(queryRef, internalQueryRef.promise);\n }\n\n React.useEffect(() => internalQueryRef.retain(), [internalQueryRef]);\n\n const promise = useSyncExternalStore(\n React.useCallback(\n (forceUpdate) => {\n return internalQueryRef.listen((promise) => {\n updateWrappedQueryRef(queryRef, promise);\n forceUpdate();\n });\n },\n [internalQueryRef, queryRef]\n ),\n getPromise,\n getPromise\n );\n\n const result = __use(promise);\n\n return React.useMemo(() => {\n return {\n data: result.data,\n dataState: result.dataState,\n networkStatus: result.networkStatus,\n error: result.error,\n } as useReadQuery.Result<TData, TStates>;\n }, [result]);\n}\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;AAY9B,CAAA,CAAA,CAAA,CAAA,CAAA,EAAO,EACL,CADF,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CA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A2B,CAAC,CAA5B,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAyC;YACnC,CAAN,CAAA,CAAA,CAAA,CAAW,EAAE,CAAb,CAAA,CAAA,CAAA,CAAA,CAAmB,CAAC,CAApB,CAAA,CAAA,CAAA,CAAyB;QACzB,CAA4C;IAC1C,CAAC,EAAE,CAAC,CAAN,CAAA,CAAA,CAAA,CAAA,CAAY,CAAC,CAAC;AACd;"}
|
|
1
|
+
{"version":3,"file":"useReadQuery.js","sources":["../../../src/react/hooks/useReadQuery.ts"],"sourcesContent":["import * as React from \"react\";\n\nimport type {\n ApolloClient,\n DataState,\n ErrorLike,\n GetDataState,\n NetworkStatus,\n ObservableQuery,\n} from \"@apollo/client\";\nimport type { MaybeMasked } from \"@apollo/client/masking\";\nimport type { QueryRef } from \"@apollo/client/react\";\nimport {\n assertWrappedQueryRef,\n getWrappedPromise,\n unwrapQueryRef,\n updateWrappedQueryRef,\n} from \"@apollo/client/react/internal\";\nimport type { DocumentationTypes as UtilityDocumentationTypes } from \"@apollo/client/utilities/internal\";\n\nimport { __use, wrapHook } from \"./internal/index.js\";\nimport { useApolloClient } from \"./useApolloClient.js\";\nimport { useSyncExternalStore } from \"./useSyncExternalStore.js\";\n\nexport declare namespace useReadQuery {\n export namespace Base {\n export interface Result<TData = unknown> {\n /**\n * {@inheritDoc @apollo/client!QueryResultDocumentation#error:member}\n *\n * This property can be ignored when using the default `errorPolicy` or an\n * `errorPolicy` of `none`. The hook will throw the error instead of setting\n * this property.\n */\n error: ErrorLike | undefined;\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#networkStatus:member} */\n networkStatus: NetworkStatus;\n }\n }\n export type Result<\n TData = unknown,\n TStates extends\n DataState<TData>[\"dataState\"] = DataState<TData>[\"dataState\"],\n > = Base.Result<TData> & GetDataState<MaybeMasked<TData>, TStates>;\n\n export namespace DocumentationTypes {\n namespace useReadQuery {\n export interface Result<TData = unknown>\n extends Base.Result<TData>,\n UtilityDocumentationTypes.DataState<TData> {}\n }\n\n /** {@inheritDoc @apollo/client/react!useReadQuery:function(1)} */\n export function useReadQuery<TData>(\n queryRef: QueryRef<TData>\n ): useReadQuery.Result<TData>;\n }\n}\n\n/**\n * For a detailed explanation of `useReadQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense#avoiding-request-waterfalls).\n *\n * @param queryRef - The `QueryRef` that was generated via `useBackgroundQuery`.\n * @returns An object containing the query result data, error, and network status.\n *\n * @example\n *\n * ```jsx\n * import { Suspense } from \"react\";\n * import { useBackgroundQuery, useReadQuery } from \"@apollo/client\";\n *\n * function Parent() {\n * const [queryRef] = useBackgroundQuery(query);\n *\n * return (\n * <Suspense fallback={<div>Loading...</div>}>\n * <Child queryRef={queryRef} />\n * </Suspense>\n * );\n * }\n *\n * function Child({ queryRef }) {\n * const { data } = useReadQuery(queryRef);\n *\n * return <div>{data.name}</div>;\n * }\n * ```\n */\nexport function useReadQuery<\n TData,\n TStates extends DataState<TData>[\"dataState\"],\n>(\n queryRef: QueryRef<TData, any, TStates>\n): useReadQuery.Result<TData, TStates> {\n \"use no memo\";\n const unwrapped = unwrapQueryRef(queryRef);\n const clientOrObsQuery = useApolloClient(\n unwrapped ?\n // passing an `ObservableQuery` is not supported by the types, but it will\n // return any truthy value that is passed in as an override so we cast the result\n (unwrapped[\"observable\"] as any)\n : undefined\n ) as ApolloClient | ObservableQuery<TData>;\n\n return wrapHook(\n \"useReadQuery\",\n // eslint-disable-next-line react-compiler/react-compiler\n useReadQuery_,\n clientOrObsQuery\n )(queryRef);\n}\n\nfunction useReadQuery_<TData, TStates extends DataState<TData>[\"dataState\"]>(\n queryRef: QueryRef<TData, any, TStates>\n): useReadQuery.Result<TData, TStates> {\n assertWrappedQueryRef(queryRef);\n const internalQueryRef = React.useMemo(\n () => unwrapQueryRef(queryRef),\n [queryRef]\n );\n\n const getPromise = React.useCallback(\n () => getWrappedPromise(queryRef),\n [queryRef]\n );\n\n if (internalQueryRef.disposed) {\n internalQueryRef.reinitialize();\n updateWrappedQueryRef(queryRef, internalQueryRef.promise);\n }\n\n React.useEffect(() => internalQueryRef.retain(), [internalQueryRef]);\n\n const promise = useSyncExternalStore(\n React.useCallback(\n (forceUpdate) => {\n return internalQueryRef.listen((promise) => {\n updateWrappedQueryRef(queryRef, promise);\n forceUpdate();\n });\n },\n [internalQueryRef, queryRef]\n ),\n getPromise,\n getPromise\n );\n\n const result = __use(promise);\n\n return React.useMemo(() => {\n return {\n data: result.data,\n dataState: result.dataState,\n networkStatus: result.networkStatus,\n error: result.error,\n } as useReadQuery.Result<TData, TStates>;\n }, [result]);\n}\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;AAY9B,CAAA,CAAA,CAAA,CAAA,CAAA,EAAO,EACL,CADF,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACuB,EACrB,CAFF,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAEmB,EACjB,CAHF,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAGgB,EACd,CAJF,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAIuB,EAJvB,EAAA,CAAA,CAAA,CAAA,EAKO,CALP,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA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,CAAA,CAAA,CAAA,CAIc,CACX;IAED,CAAF,CAAA,CAAA,CAAA,EAAQ,CAAR,CAAA,CAAA,CAAA,CAAA,EAAA,EAAiB,CAAjB,CAAA,CAAA,CAAA,CAAsB,UAAQ,CAAC;IAE7B,CAAF,CAAA,CAAA,CAAA,CAAA,EAAS,CAAT,CAAA,CAAA,CAAA,CAAc,CAAC,CAAf,CAAA,CAAA,CAAA,CAAA,CAAA,CAAsB,CAAC,CAAvB,EAA0B,CAA1B,EAAA;QACI,CAAJ,CAAA,CAAA,CAAA,CAAA,EAAW;YACL,CAAN,CAAA,CAAA,CAAU,EAAE,CAAZ,CAAA,CAAA,CAAA,CAAA,CAAkB,CAAC,CAAnB,CAAA,CAAA,CAAuB;YACjB,CAAN,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAe,EAAE,CAAjB,CAAA,CAAA,CAAA,CAAA,CAAuB,CAAC,CAAxB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAiC;YAC3B,CAAN,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAmB,EAAE,CAArB,CAAA,CAAA,CAAA,CAAA,CAA2B,CAAC,CAA5B,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAyC;YACnC,CAAN,CAAA,CAAA,CAAA,CAAW,EAAE,CAAb,CAAA,CAAA,CAAA,CAAA,CAAmB,CAAC,CAApB,CAAA,CAAA,CAAA,CAAyB;QACzB,CAA4C;IAC1C,CAAC,EAAE,CAAC,CAAN,CAAA,CAAA,CAAA,CAAA,CAAY,CAAC,CAAC;AACd;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ApolloClient, DefaultContext, DocumentNode, ErrorPolicy, OperationVariables, RefetchWritePolicy, TypedDocumentNode, WatchQueryFetchPolicy } from "@apollo/client";
|
|
2
|
-
import type { PreloadedQueryRef } from "@apollo/client/react
|
|
2
|
+
import type { PreloadedQueryRef } from "@apollo/client/react";
|
|
3
3
|
import type { NoInfer, VariablesOption } from "@apollo/client/utilities/internal";
|
|
4
4
|
export type PreloadQueryFetchPolicy = Extract<WatchQueryFetchPolicy, "cache-first" | "network-only" | "no-cache" | "cache-and-network">;
|
|
5
5
|
export type PreloadQueryOptions<TVariables extends OperationVariables = OperationVariables> = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createQueryPreloader.js","sourceRoot":"","sources":["../../../src/react/query-preloader/createQueryPreloader.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,sBAAsB,EACtB,YAAY,GACb,MAAM,+BAA+B,CAAC;AAMvC,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAgItD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAAoB;IAEpB,OAAO,QAAQ,CACb,sBAAsB,EACtB,qBAAqB,EACrB,MAAM,CACP,CAAC,MAAM,CAAC,CAAC;AACZ,CAAC;AAED,MAAM,qBAAqB,GAAgC,CAAC,MAAM,EAAE,EAAE;IACpE,SAAS,YAAY,CAInB,KAA0D,EAC1D,UACgC,EAAS;QAEzC,MAAM,QAAQ,GAAG,IAAI,sBAAsB,CACzC,MAAM,CAAC,UAAU,CAAC;YAChB,GAAG,OAAO;YACV,KAAK;YACL,2BAA2B,EAAE,KAAK;SACS,CAAC,EAC9C;YACE,oBAAoB,EAClB,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,QAAQ,EAAE,oBAAoB;SAC9D,CACF,CAAC;QAEF,OAAO,YAAY,CAAC,QAAQ,CAG3B,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE;QACjC,SAAS,CACP,QAAmB;YAEnB,qBAAqB,CAAC,QAAQ,CAAC,CAAC;YAChC,OAAO,iBAAiB,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC;QAC1D,CAAC;KACF,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import type {\n ApolloClient,\n DefaultContext,\n DocumentNode,\n ErrorPolicy,\n OperationVariables,\n RefetchWritePolicy,\n TypedDocumentNode,\n WatchQueryFetchPolicy,\n} from \"@apollo/client\";\nimport type { PreloadedQueryRef } from \"@apollo/client/react
|
|
1
|
+
{"version":3,"file":"createQueryPreloader.js","sourceRoot":"","sources":["../../../src/react/query-preloader/createQueryPreloader.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,sBAAsB,EACtB,YAAY,GACb,MAAM,+BAA+B,CAAC;AAMvC,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAgItD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAAoB;IAEpB,OAAO,QAAQ,CACb,sBAAsB,EACtB,qBAAqB,EACrB,MAAM,CACP,CAAC,MAAM,CAAC,CAAC;AACZ,CAAC;AAED,MAAM,qBAAqB,GAAgC,CAAC,MAAM,EAAE,EAAE;IACpE,SAAS,YAAY,CAInB,KAA0D,EAC1D,UACgC,EAAS;QAEzC,MAAM,QAAQ,GAAG,IAAI,sBAAsB,CACzC,MAAM,CAAC,UAAU,CAAC;YAChB,GAAG,OAAO;YACV,KAAK;YACL,2BAA2B,EAAE,KAAK;SACS,CAAC,EAC9C;YACE,oBAAoB,EAClB,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,QAAQ,EAAE,oBAAoB;SAC9D,CACF,CAAC;QAEF,OAAO,YAAY,CAAC,QAAQ,CAG3B,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE;QACjC,SAAS,CACP,QAAmB;YAEnB,qBAAqB,CAAC,QAAQ,CAAC,CAAC;YAChC,OAAO,iBAAiB,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC;QAC1D,CAAC;KACF,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import type {\n ApolloClient,\n DefaultContext,\n DocumentNode,\n ErrorPolicy,\n OperationVariables,\n RefetchWritePolicy,\n TypedDocumentNode,\n WatchQueryFetchPolicy,\n} from \"@apollo/client\";\nimport type { PreloadedQueryRef } from \"@apollo/client/react\";\nimport {\n assertWrappedQueryRef,\n getWrappedPromise,\n InternalQueryReference,\n wrapQueryRef,\n} from \"@apollo/client/react/internal\";\nimport type {\n NoInfer,\n VariablesOption,\n} from \"@apollo/client/utilities/internal\";\n\nimport { wrapHook } from \"../hooks/internal/index.js\";\n\nexport type PreloadQueryFetchPolicy = Extract<\n WatchQueryFetchPolicy,\n \"cache-first\" | \"network-only\" | \"no-cache\" | \"cache-and-network\"\n>;\n\nexport type PreloadQueryOptions<\n TVariables extends OperationVariables = OperationVariables,\n> = {\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#context:member} */\n context?: DefaultContext;\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#errorPolicy:member} */\n errorPolicy?: ErrorPolicy;\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#fetchPolicy:member} */\n fetchPolicy?: PreloadQueryFetchPolicy;\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#returnPartialData:member} */\n returnPartialData?: boolean;\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#refetchWritePolicy:member} */\n refetchWritePolicy?: RefetchWritePolicy;\n} & VariablesOption<TVariables>;\n\n/**\n * A function that will begin loading a query when called. It's result can be\n * read by `useReadQuery` which will suspend until the query is loaded.\n * This is useful when you want to start loading a query as early as possible\n * outside of a React component.\n *\n * @example\n *\n * ```js\n * const preloadQuery = createQueryPreloader(client);\n * const queryRef = preloadQuery(query, { variables, ...otherOptions });\n *\n * function App() {\n * return (\n * <Suspense fallback={<div>Loading</div>}>\n * <MyQuery />\n * </Suspense>\n * );\n * }\n *\n * function MyQuery() {\n * const { data } = useReadQuery(queryRef);\n *\n * // do something with `data`\n * }\n * ```\n */\nexport interface PreloadQueryFunction {\n /** {@inheritDoc @apollo/client/react!PreloadQueryFunction:interface} */\n <TData = unknown, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: PreloadQueryOptions<NoInfer<TVariables>> & {\n returnPartialData: true;\n errorPolicy: \"ignore\" | \"all\";\n }\n ): PreloadedQueryRef<\n TData,\n TVariables,\n \"complete\" | \"streaming\" | \"partial\" | \"empty\"\n >;\n\n /** {@inheritDoc @apollo/client/react!PreloadQueryFunction:interface} */\n <TData = unknown, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: PreloadQueryOptions<NoInfer<TVariables>> & {\n errorPolicy: \"ignore\" | \"all\";\n }\n ): PreloadedQueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"empty\">;\n\n /** {@inheritDoc @apollo/client/react!PreloadQueryFunction:interface} */\n <TData = unknown, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: PreloadQueryOptions<NoInfer<TVariables>> & {\n returnPartialData: true;\n }\n ): PreloadedQueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"partial\">;\n\n /** {@inheritDoc @apollo/client/react!PreloadQueryFunction:interface} */\n <TData = unknown, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n ...[options]: {} extends TVariables ?\n [options?: PreloadQueryOptions<NoInfer<TVariables>>]\n : [options: PreloadQueryOptions<NoInfer<TVariables>>]\n ): PreloadedQueryRef<TData, TVariables, \"complete\" | \"streaming\">;\n\n /**\n * A function that returns a promise that resolves when the query has finished\n * loading. The promise resolves with the `QueryReference` itself.\n *\n * @remarks\n * This method is useful for preloading queries in data loading routers, such\n * as [React Router](https://reactrouter.com/en/main) or [TanStack Router](https://tanstack.com/router),\n * to prevent routes from transitioning until the query has finished loading.\n * `data` is not exposed on the promise to discourage using the data in\n * `loader` functions and exposing it to your route components. Instead, we\n * prefer you rely on `useReadQuery` to access the data to ensure your\n * component can rerender with cache updates. If you need to access raw query\n * data, use `client.query()` directly.\n *\n * @example\n * Here's an example using React Router's `loader` function:\n *\n * ```ts\n * import { createQueryPreloader } from \"@apollo/client\";\n *\n * const preloadQuery = createQueryPreloader(client);\n *\n * export async function loader() {\n * const queryRef = preloadQuery(GET_DOGS_QUERY);\n *\n * return preloadQuery.toPromise(queryRef);\n * }\n *\n * export function RouteComponent() {\n * const queryRef = useLoaderData();\n * const { data } = useReadQuery(queryRef);\n *\n * // ...\n * }\n * ```\n */\n toPromise<TQueryRef extends PreloadedQueryRef<any, any, any>>(\n queryRef: TQueryRef\n ): Promise<TQueryRef>;\n}\n\n/**\n * A higher order function that returns a `preloadQuery` function which\n * can be used to begin loading a query with the given `client`. This is useful\n * when you want to start loading a query as early as possible outside of a\n * React component.\n *\n * > Refer to the [Suspense - Initiating queries outside React](https://www.apollographql.com/docs/react/data/suspense#initiating-queries-outside-react) section for a more in-depth overview.\n *\n * @param client - The `ApolloClient` instance that will be used to load queries\n * from the returned `preloadQuery` function.\n * @returns The `preloadQuery` function.\n *\n * @example\n *\n * ```js\n * const preloadQuery = createQueryPreloader(client);\n * ```\n */\nexport function createQueryPreloader(\n client: ApolloClient\n): PreloadQueryFunction {\n return wrapHook(\n \"createQueryPreloader\",\n _createQueryPreloader,\n client\n )(client);\n}\n\nconst _createQueryPreloader: typeof createQueryPreloader = (client) => {\n function preloadQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: PreloadQueryOptions<NoInfer<TVariables>> &\n VariablesOption<TVariables> = {} as any\n ): PreloadedQueryRef<TData, TVariables> {\n const queryRef = new InternalQueryReference(\n client.watchQuery({\n ...options,\n query,\n notifyOnNetworkStatusChange: false,\n } as ApolloClient.WatchQueryOptions<any, any>),\n {\n autoDisposeTimeoutMs:\n client.defaultOptions.react?.suspense?.autoDisposeTimeoutMs,\n }\n );\n\n return wrapQueryRef(queryRef) as unknown as PreloadedQueryRef<\n TData,\n TVariables\n >;\n }\n\n return Object.assign(preloadQuery, {\n toPromise<TQueryRef extends PreloadedQueryRef<any, any, any>>(\n queryRef: TQueryRef\n ) {\n assertWrappedQueryRef(queryRef);\n return getWrappedPromise(queryRef).then(() => queryRef);\n },\n });\n};\n"]}
|
|
@@ -22,7 +22,7 @@ export type LazyQueryResult<TData = unknown, TVariables extends OperationVariabl
|
|
|
22
22
|
export type LazyQueryResultTuple<TData = unknown, TVariables extends OperationVariables = OperationVariables> = useLazyQuery.ResultTuple<TData, TVariables>;
|
|
23
23
|
/** @deprecated Use `useLazyQuery.ExecOptions` instead */
|
|
24
24
|
export type LazyQueryHookExecOptions<TVariables extends OperationVariables = OperationVariables> = useLazyQuery.ExecOptions<TVariables>;
|
|
25
|
-
/** @deprecated Use `useLazyQuery.
|
|
25
|
+
/** @deprecated Use `useLazyQuery.ExecFunction` instead */
|
|
26
26
|
export type LazyQueryExecFunction<TData = unknown, TVariables extends OperationVariables = OperationVariables> = useLazyQuery.ExecFunction<TData, TVariables>;
|
|
27
27
|
/** @deprecated Use `useMutation.Options` instead */
|
|
28
28
|
export type MutationHookOptions<TData = unknown, TVariables extends OperationVariables = OperationVariables, _TContext = DefaultContext, TCache extends ApolloCache = ApolloCache> = useMutation.Options<TData, TVariables, TCache>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deprecated.js","sourceRoot":"","sources":["../../../src/react/types/deprecated.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n ApolloCache,\n DefaultContext,\n OperationVariables,\n} from \"@apollo/client\";\n\nimport type { useBackgroundQuery } from \"../hooks/useBackgroundQuery.js\";\nimport type { useFragment } from \"../hooks/useFragment.js\";\nimport type { useLazyQuery } from \"../hooks/useLazyQuery.js\";\nimport type { useLoadableQuery } from \"../hooks/useLoadableQuery.js\";\nimport type { useMutation } from \"../hooks/useMutation.js\";\nimport type { useQuery } from \"../hooks/useQuery.js\";\nimport type { useQueryRefHandlers } from \"../hooks/useQueryRefHandlers.js\";\nimport type { useReadQuery } from \"../hooks/useReadQuery.js\";\nimport type { useSubscription } from \"../hooks/useSubscription.js\";\nimport type { useSuspenseFragment } from \"../hooks/useSuspenseFragment.js\";\nimport type { useSuspenseQuery } from \"../hooks/useSuspenseQuery.js\";\n\n/** @deprecated Use `useQuery.Options` instead */\nexport type QueryHookOptions<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n> = useQuery.Options<TData, TVariables>;\n\n/** @deprecated Use `useQuery.Result` instead */\nexport type QueryResult<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n> = useQuery.Result<TData, TVariables>;\n\n/** @deprecated Use `useLazyQuery.Options` instead */\nexport type LazyQueryHookOptions<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n> = useLazyQuery.Options<TData, TVariables>;\n\n/** @deprecated Use `useLazyQuery.Result` instead */\nexport type LazyQueryResult<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n> = useLazyQuery.Result<TData, TVariables>;\n\n/** @deprecated Use `useLazyQuery.ResultTuple` instead */\nexport type LazyQueryResultTuple<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n> = useLazyQuery.ResultTuple<TData, TVariables>;\n\n/** @deprecated Use `useLazyQuery.ExecOptions` instead */\nexport type LazyQueryHookExecOptions<\n TVariables extends OperationVariables = OperationVariables,\n> = useLazyQuery.ExecOptions<TVariables>;\n\n/** @deprecated Use `useLazyQuery.
|
|
1
|
+
{"version":3,"file":"deprecated.js","sourceRoot":"","sources":["../../../src/react/types/deprecated.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n ApolloCache,\n DefaultContext,\n OperationVariables,\n} from \"@apollo/client\";\n\nimport type { useBackgroundQuery } from \"../hooks/useBackgroundQuery.js\";\nimport type { useFragment } from \"../hooks/useFragment.js\";\nimport type { useLazyQuery } from \"../hooks/useLazyQuery.js\";\nimport type { useLoadableQuery } from \"../hooks/useLoadableQuery.js\";\nimport type { useMutation } from \"../hooks/useMutation.js\";\nimport type { useQuery } from \"../hooks/useQuery.js\";\nimport type { useQueryRefHandlers } from \"../hooks/useQueryRefHandlers.js\";\nimport type { useReadQuery } from \"../hooks/useReadQuery.js\";\nimport type { useSubscription } from \"../hooks/useSubscription.js\";\nimport type { useSuspenseFragment } from \"../hooks/useSuspenseFragment.js\";\nimport type { useSuspenseQuery } from \"../hooks/useSuspenseQuery.js\";\n\n/** @deprecated Use `useQuery.Options` instead */\nexport type QueryHookOptions<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n> = useQuery.Options<TData, TVariables>;\n\n/** @deprecated Use `useQuery.Result` instead */\nexport type QueryResult<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n> = useQuery.Result<TData, TVariables>;\n\n/** @deprecated Use `useLazyQuery.Options` instead */\nexport type LazyQueryHookOptions<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n> = useLazyQuery.Options<TData, TVariables>;\n\n/** @deprecated Use `useLazyQuery.Result` instead */\nexport type LazyQueryResult<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n> = useLazyQuery.Result<TData, TVariables>;\n\n/** @deprecated Use `useLazyQuery.ResultTuple` instead */\nexport type LazyQueryResultTuple<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n> = useLazyQuery.ResultTuple<TData, TVariables>;\n\n/** @deprecated Use `useLazyQuery.ExecOptions` instead */\nexport type LazyQueryHookExecOptions<\n TVariables extends OperationVariables = OperationVariables,\n> = useLazyQuery.ExecOptions<TVariables>;\n\n/** @deprecated Use `useLazyQuery.ExecFunction` instead */\nexport type LazyQueryExecFunction<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n> = useLazyQuery.ExecFunction<TData, TVariables>;\n\n/** @deprecated Use `useMutation.Options` instead */\nexport type MutationHookOptions<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n _TContext = DefaultContext,\n TCache extends ApolloCache = ApolloCache,\n> = useMutation.Options<TData, TVariables, TCache>;\n\n/** @deprecated Use `useMutation.Result` instead */\nexport type MutationResult<TData = unknown> = useMutation.Result<TData>;\n\n/** @deprecated Use `useMutation.MutationFunctionOptions` instead */\nexport type MutationFunctionOptions<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n _TContext = DefaultContext,\n TCache extends ApolloCache = ApolloCache,\n> = useMutation.MutationFunctionOptions<TData, TVariables, TCache>;\n\n/** @deprecated Use `useMutation.ResultTuple` instead */\nexport type MutationTuple<\n TData,\n TVariables extends OperationVariables,\n _TContext = DefaultContext,\n TCache extends ApolloCache = ApolloCache,\n> = useMutation.ResultTuple<TData, TVariables, TCache>;\n\n/** @deprecated Use `useSubscription.Result` instead */\nexport type SubscriptionResult<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n> = useSubscription.Result<TData>;\n\n/** @deprecated Use `useSubscription.Options` instead */\nexport type SubscriptionHookOptions<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n> = useSubscription.Options<TData, TVariables>;\n\n/** @deprecated Use `useSubscription.OnDataOptions` instead */\nexport type OnDataOptions<TData = unknown> =\n useSubscription.OnDataOptions<TData>;\n\n/** @deprecated Use `useSubscription.OnSubscriptionDataOptions` instead */\nexport type OnSubscriptionDataOptions<TData = unknown> =\n useSubscription.OnSubscriptionDataOptions<TData>;\n\n/** @deprecated Use `useFragment.Options` instead */\nexport type UseFragmentOptions<\n TData,\n TVariables extends OperationVariables,\n> = useFragment.Options<TData, TVariables>;\n\n/** @deprecated Use `useFragment.Result` instead */\nexport type UseFragmentResult<TData> = useFragment.Result<TData>;\n\n/** @deprecated Use `useSuspenseQuery.Options` instead */\nexport type SuspenseQueryHookOptions<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n> = useSuspenseQuery.Options<TVariables>;\n\n/** @deprecated Use `useSuspenseQuery.Result` instead */\nexport type UseSuspenseQueryResult<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n> = useSuspenseQuery.Result<TData, TVariables>;\n\n/** @deprecated Use `useSuspenseQuery.FetchPolicy` instead */\nexport type SuspenseQueryHookFetchPolicy = useSuspenseQuery.FetchPolicy;\n\n/** @deprecated Use `useBackgroundQuery.Options` instead */\nexport type BackgroundQueryHookOptions<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n> = useBackgroundQuery.Options<TVariables>;\n\n/** @deprecated Use `useBackgroundQuery.Result` instead */\nexport type UseBackgroundQueryResult<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n> = useBackgroundQuery.Result<TData, TVariables>;\n\n/** @deprecated Use `useBackgroundQuery.FetchPolicy` instead */\nexport type BackgroundQueryHookFetchPolicy = useBackgroundQuery.FetchPolicy;\n\n/** @deprecated Use `useSuspenseFragment.Options` instead */\nexport type UseSuspenseFragmentOptions<\n TData,\n TVariables extends OperationVariables,\n> = useSuspenseFragment.Options<TData, TVariables>;\n\n/** @deprecated Use `useSuspenseFragment.Result` instead */\nexport type UseSuspenseFragmentResult<TData> =\n useSuspenseFragment.Result<TData>;\n\n/** @deprecated Use `useLoadableQuery.LoadQueryFunction` instead */\nexport type LoadQueryFunction<TVariables extends OperationVariables> =\n useLoadableQuery.LoadQueryFunction<TVariables>;\n\n/** @deprecated Use `useLoadableQuery.FetchPolicy` instead */\nexport type LoadableQueryFetchPolicy = useLoadableQuery.FetchPolicy;\n\n/** @deprecated Use `useLoadableQuery.Options` instead */\nexport type LoadableQueryHookOptions = useLoadableQuery.Options;\n\n/** @deprecated Use `useLoadableQuery.Result` instead */\nexport type UseLoadableQueryResult<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n> = useLoadableQuery.Result<TData, TVariables>;\n\n/** @deprecated Use `useQueryRefHandlers.Result` instead */\nexport type UseQueryRefHandlersResult<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n> = useQueryRefHandlers.Result<TData, TVariables>;\n\n/** @deprecated Use `useReadQuery.Result` instead */\nexport type UseReadQueryResult<TData = unknown> = useReadQuery.Result<TData>;\n"]}
|
|
@@ -187,7 +187,7 @@ export interface QueryResultDocumentation {
|
|
|
187
187
|
*/
|
|
188
188
|
error: unknown;
|
|
189
189
|
/**
|
|
190
|
-
* If `true`, the query is still in flight
|
|
190
|
+
* If `true`, the query is still in flight.
|
|
191
191
|
*
|
|
192
192
|
* @docGroup 2. Network info
|
|
193
193
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.documentation.js","sourceRoot":"","sources":["../../../src/react/types/types.documentation.ts"],"names":[],"mappings":"","sourcesContent":["export interface QueryOptionsDocumentation {\n /**\n * A GraphQL query string parsed into an AST with the gql template literal.\n *\n * @docGroup 1. Operation options\n */\n query: unknown;\n\n /**\n * An object containing all of the GraphQL variables your query requires to execute.\n *\n * Each key in the object corresponds to a variable name, and that key's value corresponds to the variable value.\n *\n * @docGroup 1. Operation options\n */\n variables: unknown;\n\n /**\n * Specifies how the query handles a response that returns both GraphQL errors and partial results.\n *\n * For details, see [GraphQL error policies](https://www.apollographql.com/docs/react/data/error-handling/#graphql-error-policies).\n *\n * The default value is `none`, meaning that the query result includes error details but not partial results.\n *\n * @docGroup 1. Operation options\n */\n errorPolicy: unknown;\n\n /**\n * If you're using [Apollo Link](https://www.apollographql.com/docs/react/api/link/introduction/), this object is the initial value of the `context` object that's passed along your link chain.\n *\n * @docGroup 2. Networking options\n */\n context: unknown;\n\n /**\n * Specifies how the query interacts with the Apollo Client cache during execution (for example, whether it checks the cache for results before sending a request to the server).\n *\n * For details, see [Setting a fetch policy](https://www.apollographql.com/docs/react/data/queries/#setting-a-fetch-policy).\n *\n * The default value is `cache-first`.\n *\n * @docGroup 3. Caching options\n */\n fetchPolicy: unknown;\n\n /**\n * Specifies the `FetchPolicy` to be used after this query has completed.\n *\n * @docGroup 3. Caching options\n */\n nextFetchPolicy: unknown;\n\n /**\n * Defaults to the initial value of options.fetchPolicy, but can be explicitly\n * configured to specify the WatchQueryFetchPolicy to revert back to whenever\n * variables change (unless nextFetchPolicy intervenes).\n *\n * @docGroup 3. Caching options\n */\n initialFetchPolicy: unknown;\n\n /**\n * Specifies the interval (in milliseconds) at which the query polls for updated results.\n *\n * The default value is `0` (no polling).\n *\n * @docGroup 2. Networking options\n */\n pollInterval: unknown;\n\n /**\n * If `true`, the in-progress query's associated component re-renders whenever the network status changes or a network error occurs.\n *\n * The default value is `true`.\n *\n * @docGroup 2. Networking options\n */\n notifyOnNetworkStatusChange: unknown;\n\n /**\n * If `true`, the query can return partial results from the cache if the cache doesn't contain results for all queried fields.\n *\n * The default value is `false`.\n *\n * @docGroup 3. Caching options\n */\n returnPartialData: unknown;\n\n /**\n * Specifies whether a `NetworkStatus.refetch` operation should merge\n * incoming field data with existing data, or overwrite the existing data.\n * Overwriting is probably preferable, but merging is currently the default\n * behavior, for backwards compatibility with Apollo Client 3.x.\n *\n * @docGroup 3. Caching options\n */\n refetchWritePolicy: unknown;\n\n /**\n * Watched queries must opt into overwriting existing data on refetch, by passing refetchWritePolicy: \"overwrite\" in their WatchQueryOptions.\n *\n * The default value is \"overwrite\".\n *\n * @docGroup 3. Caching options\n */\n refetchWritePolicy_suspense: unknown;\n\n /**\n * If true, the query is not executed.\n *\n * The default value is `false`.\n *\n * @docGroup 1. Operation options\n */\n skip: unknown;\n\n /**\n * If `true`, the query is not executed. The default value is `false`.\n *\n * @deprecated We recommend using `skipToken` in place of the `skip` option as\n * it is more type-safe.\n *\n * This option is deprecated and only supported to ease the migration from `useQuery`. It will be removed in a future release.\n * Please use [`skipToken`](https://www.apollographql.com/docs/react/api/react/hooks#skiptoken) instead of the `skip` option as it is more type-safe.\n *\n * @docGroup 1. Operation options\n */\n skip_deprecated: unknown;\n\n /**\n * The instance of `ApolloClient` to use to execute the query.\n *\n * By default, the instance that's passed down via context is used, but you\n * can provide a different instance here.\n *\n * @docGroup 1. Operation options\n */\n client: unknown;\n\n /**\n * A unique identifier for the query. Each item in the array must be a stable\n * identifier to prevent infinite fetches.\n *\n * This is useful when using the same query and variables combination in more\n * than one component, otherwise the components may clobber each other. This\n * can also be used to force the query to re-evaluate fresh.\n *\n * @docGroup 1. Operation options\n */\n queryKey: unknown;\n\n /**\n * Pass `false` to skip executing the query during [server-side rendering](https://www.apollographql.com/docs/react/performance/server-side-rendering/).\n *\n * @docGroup 2. Networking options\n */\n ssr: unknown;\n\n /**\n * A callback function that's called whenever a refetch attempt occurs\n * while polling. If the function returns `true`, the refetch is\n * skipped and not reattempted until the next poll interval.\n *\n * @docGroup 2. Networking options\n */\n skipPollAttempt: unknown;\n}\n\nexport interface QueryResultDocumentation {\n /**\n * The instance of Apollo Client that executed the query.\n * Can be useful for manually executing followup queries or writing data to the cache.\n *\n * @docGroup 2. Network info\n */\n client: unknown;\n /**\n * A reference to the internal `ObservableQuery` used by the hook.\n */\n observable: unknown;\n /**\n * An object containing the result of your GraphQL query after it completes.\n *\n * This value might be `undefined` if a query results in one or more errors (depending on the query's `errorPolicy`).\n *\n * @docGroup 1. Operation data\n */\n data: unknown;\n /**\n * An object containing the result from the most recent _previous_ execution of this query.\n *\n * This value is `undefined` if this is the query's first execution.\n *\n * @docGroup 1. Operation data\n */\n previousData: unknown;\n /**\n * A single ErrorLike object describing the error that occured during the latest\n * query execution.\n *\n * For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).\n *\n * @docGroup 1. Operation data\n */\n error: unknown;\n /**\n * If `true`, the query is still in flight and results have not yet been returned.\n *\n * @docGroup 2. Network info\n */\n loading: unknown;\n /**\n * A number indicating the current network state of the query's associated request. [See possible values.](https://github.com/apollographql/apollo-client/blob/d96f4578f89b933c281bb775a39503f6cdb59ee8/src/core/networkStatus.ts#L4)\n *\n * Used in conjunction with the [`notifyOnNetworkStatusChange`](#notifyonnetworkstatuschange) option.\n *\n * @docGroup 2. Network info\n */\n networkStatus: unknown;\n /**\n * An object containing the variables that were provided for the query.\n *\n * @docGroup 1. Operation data\n */\n variables: unknown;\n\n /**\n * A function that enables you to re-execute the query, optionally passing in new `variables`.\n *\n * To guarantee that the refetch performs a network request, its `fetchPolicy` is set to `network-only` (unless the original query's `fetchPolicy` is `no-cache` or `cache-and-network`, which also guarantee a network request).\n *\n * See also [Refetching](https://www.apollographql.com/docs/react/data/queries/#refetching).\n *\n * Returns a `ResultPromise` with an additional `.retain()` method. Calling\n * `.retain()` keeps the network operation running even if the `ObservableQuery`\n * no longer requires the result.\n *\n * @docGroup 3. Helper functions\n */\n refetch: unknown;\n /**\n * {@inheritDoc @apollo/client!ObservableQuery#fetchMore:member(1)}\n *\n * @docGroup 3. Helper functions\n */\n fetchMore: unknown;\n /**\n * {@inheritDoc @apollo/client!ObservableQuery#startPolling:member(1)}\n *\n * @docGroup 3. Helper functions\n */\n startPolling: unknown;\n /**\n * {@inheritDoc @apollo/client!ObservableQuery#stopPolling:member(1)}\n *\n * @docGroup 3. Helper functions\n */\n stopPolling: unknown;\n /**\n * {@inheritDoc @apollo/client!ObservableQuery#subscribeToMore:member(1)}\n *\n * @docGroup 3. Helper functions\n */\n subscribeToMore: unknown;\n /**\n * {@inheritDoc @apollo/client!ObservableQuery#updateQuery:member(1)}\n *\n * @docGroup 3. Helper functions\n */\n updateQuery: unknown;\n\n /**\n * Describes the completeness of `data`.\n *\n * - `empty`: No data could be fulfilled from the cache or the result is\n * incomplete. `data` is `undefined`.\n * - `partial`: Some data could be fulfilled from the cache but `data` is\n * incomplete. This is only possible when `returnPartialData` is `true`.\n * - `streaming`: `data` is incomplete as a result of a deferred query and\n * the result is still streaming in.\n * - `complete`: `data` is a fully satisfied query result fulfilled\n * either from the cache or network.\n *\n * @docGroup 1. Operation data\n */\n dataState: unknown;\n\n /**\n * Describes whether `data` is a complete or partial result. This flag is only\n * set when `returnPartialData` is `true` in query options.\n *\n * @deprecated This field will be removed in a future version of Apollo Client.\n * @docGroup 1. Operation data\n */\n partial: boolean;\n}\n\nexport interface MutationOptionsDocumentation {\n /**\n * A GraphQL document, often created with `gql` from the `graphql-tag`\n * package, that contains a single mutation inside of it.\n *\n * @docGroup 1. Operation options\n */\n mutation: unknown;\n\n /**\n * Provide `no-cache` if the mutation's result should _not_ be written to the Apollo Client cache.\n *\n * The default value is `network-only` (which means the result _is_ written to the cache).\n *\n * Unlike queries, mutations _do not_ support [fetch policies](https://www.apollographql.com/docs/react/data/queries/#setting-a-fetch-policy) besides `network-only` and `no-cache`.\n *\n * @docGroup 3. Caching options\n */\n fetchPolicy: unknown;\n\n /**\n * To avoid retaining sensitive information from mutation root field\n * arguments, Apollo Client v3.4+ automatically clears any `ROOT_MUTATION`\n * fields from the cache after each mutation finishes. If you need this\n * information to remain in the cache, you can prevent the removal by passing\n * `keepRootFields: true` to the mutation. `ROOT_MUTATION` result data are\n * also passed to the mutation `update` function, so we recommend obtaining\n * the results that way, rather than using this option, if possible.\n */\n keepRootFields: unknown;\n\n /**\n * By providing either an object or a callback function that, when invoked after\n * a mutation, allows you to return optimistic data and optionally skip updates\n * via the `IGNORE` sentinel object, Apollo Client caches this temporary\n * (and potentially incorrect) response until the mutation completes, enabling\n * more responsive UI updates.\n *\n * For more information, see [Optimistic mutation results](https://www.apollographql.com/docs/react/performance/optimistic-ui/).\n *\n * @docGroup 3. Caching options\n */\n optimisticResponse: unknown;\n\n /**\n * A `MutationQueryReducersMap`, which is map from query names to\n * mutation query reducers. Briefly, this map defines how to incorporate the\n * results of the mutation into the results of queries that are currently\n * being watched by your application.\n */\n updateQueries: unknown;\n\n /**\n * An array (or a function that _returns_ an array) that specifies which queries you want to refetch after the mutation occurs.\n *\n * Each array value can be either:\n *\n * - An object containing the `query` to execute, along with any `variables`\n *\n * - A string indicating the operation name of the query to refetch\n *\n * @docGroup 1. Operation options\n */\n refetchQueries: unknown;\n\n /**\n * If `true`, makes sure all queries included in `refetchQueries` are completed before the mutation is considered complete.\n *\n * The default value is `false` (queries are refetched asynchronously).\n *\n * @docGroup 1. Operation options\n */\n awaitRefetchQueries: unknown;\n\n /**\n * A function used to update the Apollo Client cache after the mutation completes.\n *\n * For more information, see [Updating the cache after a mutation](https://www.apollographql.com/docs/react/data/mutations#updating-the-cache-after-a-mutation).\n *\n * @docGroup 3. Caching options\n */\n update: unknown;\n\n /**\n * Optional callback for intercepting queries whose cache data has been updated by the mutation, as well as any queries specified in the `refetchQueries: [...]` list passed to `client.mutate`.\n *\n * Returning a `Promise` from `onQueryUpdated` will cause the final mutation `Promise` to await the returned `Promise`. Returning `false` causes the query to be ignored.\n *\n * @docGroup 1. Operation options\n */\n onQueryUpdated: unknown;\n\n /**\n * Specifies how the mutation handles a response that returns both GraphQL errors and partial results.\n *\n * For details, see [GraphQL error policies](https://www.apollographql.com/docs/react/data/error-handling/#graphql-error-policies).\n *\n * The default value is `none`, meaning that the mutation result includes error details but _not_ partial results.\n *\n * @docGroup 1. Operation options\n */\n errorPolicy: unknown;\n\n /**\n * An object containing all of the GraphQL variables your mutation requires to execute.\n *\n * Each key in the object corresponds to a variable name, and that key's value corresponds to the variable value.\n *\n * @docGroup 1. Operation options\n */\n variables: unknown;\n\n /**\n * If you're using [Apollo Link](https://www.apollographql.com/docs/react/api/link/introduction/), this object is the initial value of the `context` object that's passed along your link chain.\n *\n * @docGroup 2. Networking options\n */\n context: unknown;\n\n /**\n * The instance of `ApolloClient` to use to execute the mutation.\n *\n * By default, the instance that's passed down via context is used, but you can provide a different instance here.\n *\n * @docGroup 2. Networking options\n */\n client: unknown;\n /**\n * If `true`, the in-progress mutation's associated component re-renders whenever the network status changes or a network error occurs.\n *\n * The default value is `true`.\n *\n * @docGroup 2. Networking options\n */\n notifyOnNetworkStatusChange: unknown;\n /**\n * A callback function that's called when your mutation successfully completes with zero errors (or if `errorPolicy` is `ignore` and partial data is returned).\n *\n * This function is passed the mutation's result `data` and any options passed to the mutation.\n *\n * @docGroup 1. Operation options\n */\n onCompleted: unknown;\n /**\n * A callback function that's called when the mutation encounters one or more errors (unless `errorPolicy` is `ignore`).\n *\n * This function is passed an [`ApolloError`](https://github.com/apollographql/apollo-client/blob/d96f4578f89b933c281bb775a39503f6cdb59ee8/src/errors/index.ts#L36-L39) object that contains either a `networkError` object or a `graphQLErrors` array, depending on the error(s) that occurred, as well as any options passed the mutation.\n *\n * @docGroup 1. Operation options\n */\n onError: unknown;\n /**\n * If `true`:\n *\n * - The initial state update (setting loading to true) is skipped\n * - The success state update (setting data and setting loading to false) is skipped\n * - Error updates will still occur\n *\n * The default value is `false`.\n *\n * This option is useful when you want to execute a mutation but don't need to track its progress or result in the UI, potentially improving performance by reducing re-renders.\n *\n * @docGroup 1. Operation options\n */\n ignoreResults: unknown;\n}\n\nexport interface MutationResultDocumentation {\n /**\n * The data returned from your mutation. Can be `undefined` if `ignoreResults` is `true`.\n */\n data: unknown;\n /**\n * If the mutation produces one or more errors, this object contains either an array of `graphQLErrors` or a single `networkError`. Otherwise, this value is `undefined`.\n *\n * For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).\n */\n error: unknown;\n /**\n * If `true`, the mutation is currently in flight.\n */\n loading: unknown;\n /**\n * If `true`, the mutation's mutate function has been called.\n */\n called: unknown;\n /**\n * The instance of Apollo Client that executed the mutation.\n *\n * Can be useful for manually executing followup operations or writing data to the cache.\n */\n client: unknown;\n /**\n * A function that you can call to reset the mutation's result to its initial, uncalled state.\n */\n reset: unknown;\n /**\n * Custom extensions returned from the GraphQL server\n */\n extensions: unknown;\n}\n\nexport interface SubscriptionOptionsDocumentation {\n /**\n * A GraphQL document, often created with `gql` from the `graphql-tag`\n * package, that contains a single subscription inside of it.\n */\n query: unknown;\n /**\n * An object containing all of the variables your subscription needs to execute\n */\n variables: unknown;\n\n /**\n * Specifies the `ErrorPolicy` to be used for this operation\n */\n errorPolicy: unknown;\n\n /**\n * How you want your component to interact with the Apollo cache. For details, see [Setting a fetch policy](https://www.apollographql.com/docs/react/data/queries/#setting-a-fetch-policy).\n */\n fetchPolicy: unknown;\n\n /**\n * Determines if your subscription should be unsubscribed and subscribed again when an input to the hook (such as `subscription` or `variables`) changes.\n */\n shouldResubscribe: unknown;\n\n /**\n * If `true`, the hook will not cause the component to rerender. This is useful when you want to control the rendering of your component yourself with logic in the `onData` and `onError` callbacks.\n *\n * Changing this to `true` when the hook already has `data` will reset the `data` to `undefined`.\n */\n ignoreResults: unknown;\n /**\n * An `ApolloClient` instance. By default `useSubscription` / `Subscription` uses the client passed down via context, but a different client can be passed in.\n */\n client: unknown;\n\n /**\n * Determines if the current subscription should be skipped. Useful if, for example, variables depend on previous queries and are not ready yet.\n */\n skip: unknown;\n\n /**\n * Shared context between your component and your network interface (Apollo Link).\n */\n context: unknown;\n\n /**\n * Shared context between your component and your network interface (Apollo Link).\n */\n extensions: unknown;\n\n /**\n * Allows the registration of a callback function that will be triggered each time the `useSubscription` Hook / `Subscription` component completes the subscription.\n */\n onComplete: unknown;\n\n /**\n * Allows the registration of a callback function that will be triggered each time the `useSubscription` Hook / `Subscription` component receives data. The callback `options` object param consists of the current Apollo Client instance in `client`, and the received subscription data in `data`.\n */\n onData: unknown;\n\n /**\n * Allows the registration of a callback function that will be triggered each time the `useSubscription` Hook / `Subscription` component receives an error.\n */\n onError: unknown;\n}\n\nexport interface SubscriptionResultDocumentation {\n /**\n * A boolean that indicates whether any initial data has been returned\n */\n loading: unknown;\n /**\n * An object containing the result of your GraphQL subscription. Defaults to an empty object.\n */\n data: unknown;\n /**\n * A runtime error with `graphQLErrors` and `networkError` properties\n */\n error: unknown;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.documentation.js","sourceRoot":"","sources":["../../../src/react/types/types.documentation.ts"],"names":[],"mappings":"","sourcesContent":["export interface QueryOptionsDocumentation {\n /**\n * A GraphQL query string parsed into an AST with the gql template literal.\n *\n * @docGroup 1. Operation options\n */\n query: unknown;\n\n /**\n * An object containing all of the GraphQL variables your query requires to execute.\n *\n * Each key in the object corresponds to a variable name, and that key's value corresponds to the variable value.\n *\n * @docGroup 1. Operation options\n */\n variables: unknown;\n\n /**\n * Specifies how the query handles a response that returns both GraphQL errors and partial results.\n *\n * For details, see [GraphQL error policies](https://www.apollographql.com/docs/react/data/error-handling/#graphql-error-policies).\n *\n * The default value is `none`, meaning that the query result includes error details but not partial results.\n *\n * @docGroup 1. Operation options\n */\n errorPolicy: unknown;\n\n /**\n * If you're using [Apollo Link](https://www.apollographql.com/docs/react/api/link/introduction/), this object is the initial value of the `context` object that's passed along your link chain.\n *\n * @docGroup 2. Networking options\n */\n context: unknown;\n\n /**\n * Specifies how the query interacts with the Apollo Client cache during execution (for example, whether it checks the cache for results before sending a request to the server).\n *\n * For details, see [Setting a fetch policy](https://www.apollographql.com/docs/react/data/queries/#setting-a-fetch-policy).\n *\n * The default value is `cache-first`.\n *\n * @docGroup 3. Caching options\n */\n fetchPolicy: unknown;\n\n /**\n * Specifies the `FetchPolicy` to be used after this query has completed.\n *\n * @docGroup 3. Caching options\n */\n nextFetchPolicy: unknown;\n\n /**\n * Defaults to the initial value of options.fetchPolicy, but can be explicitly\n * configured to specify the WatchQueryFetchPolicy to revert back to whenever\n * variables change (unless nextFetchPolicy intervenes).\n *\n * @docGroup 3. Caching options\n */\n initialFetchPolicy: unknown;\n\n /**\n * Specifies the interval (in milliseconds) at which the query polls for updated results.\n *\n * The default value is `0` (no polling).\n *\n * @docGroup 2. Networking options\n */\n pollInterval: unknown;\n\n /**\n * If `true`, the in-progress query's associated component re-renders whenever the network status changes or a network error occurs.\n *\n * The default value is `true`.\n *\n * @docGroup 2. Networking options\n */\n notifyOnNetworkStatusChange: unknown;\n\n /**\n * If `true`, the query can return partial results from the cache if the cache doesn't contain results for all queried fields.\n *\n * The default value is `false`.\n *\n * @docGroup 3. Caching options\n */\n returnPartialData: unknown;\n\n /**\n * Specifies whether a `NetworkStatus.refetch` operation should merge\n * incoming field data with existing data, or overwrite the existing data.\n * Overwriting is probably preferable, but merging is currently the default\n * behavior, for backwards compatibility with Apollo Client 3.x.\n *\n * @docGroup 3. Caching options\n */\n refetchWritePolicy: unknown;\n\n /**\n * Watched queries must opt into overwriting existing data on refetch, by passing refetchWritePolicy: \"overwrite\" in their WatchQueryOptions.\n *\n * The default value is \"overwrite\".\n *\n * @docGroup 3. Caching options\n */\n refetchWritePolicy_suspense: unknown;\n\n /**\n * If true, the query is not executed.\n *\n * The default value is `false`.\n *\n * @docGroup 1. Operation options\n */\n skip: unknown;\n\n /**\n * If `true`, the query is not executed. The default value is `false`.\n *\n * @deprecated We recommend using `skipToken` in place of the `skip` option as\n * it is more type-safe.\n *\n * This option is deprecated and only supported to ease the migration from `useQuery`. It will be removed in a future release.\n * Please use [`skipToken`](https://www.apollographql.com/docs/react/api/react/hooks#skiptoken) instead of the `skip` option as it is more type-safe.\n *\n * @docGroup 1. Operation options\n */\n skip_deprecated: unknown;\n\n /**\n * The instance of `ApolloClient` to use to execute the query.\n *\n * By default, the instance that's passed down via context is used, but you\n * can provide a different instance here.\n *\n * @docGroup 1. Operation options\n */\n client: unknown;\n\n /**\n * A unique identifier for the query. Each item in the array must be a stable\n * identifier to prevent infinite fetches.\n *\n * This is useful when using the same query and variables combination in more\n * than one component, otherwise the components may clobber each other. This\n * can also be used to force the query to re-evaluate fresh.\n *\n * @docGroup 1. Operation options\n */\n queryKey: unknown;\n\n /**\n * Pass `false` to skip executing the query during [server-side rendering](https://www.apollographql.com/docs/react/performance/server-side-rendering/).\n *\n * @docGroup 2. Networking options\n */\n ssr: unknown;\n\n /**\n * A callback function that's called whenever a refetch attempt occurs\n * while polling. If the function returns `true`, the refetch is\n * skipped and not reattempted until the next poll interval.\n *\n * @docGroup 2. Networking options\n */\n skipPollAttempt: unknown;\n}\n\nexport interface QueryResultDocumentation {\n /**\n * The instance of Apollo Client that executed the query.\n * Can be useful for manually executing followup queries or writing data to the cache.\n *\n * @docGroup 2. Network info\n */\n client: unknown;\n /**\n * A reference to the internal `ObservableQuery` used by the hook.\n */\n observable: unknown;\n /**\n * An object containing the result of your GraphQL query after it completes.\n *\n * This value might be `undefined` if a query results in one or more errors (depending on the query's `errorPolicy`).\n *\n * @docGroup 1. Operation data\n */\n data: unknown;\n /**\n * An object containing the result from the most recent _previous_ execution of this query.\n *\n * This value is `undefined` if this is the query's first execution.\n *\n * @docGroup 1. Operation data\n */\n previousData: unknown;\n /**\n * A single ErrorLike object describing the error that occured during the latest\n * query execution.\n *\n * For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).\n *\n * @docGroup 1. Operation data\n */\n error: unknown;\n /**\n * If `true`, the query is still in flight.\n *\n * @docGroup 2. Network info\n */\n loading: unknown;\n /**\n * A number indicating the current network state of the query's associated request. [See possible values.](https://github.com/apollographql/apollo-client/blob/d96f4578f89b933c281bb775a39503f6cdb59ee8/src/core/networkStatus.ts#L4)\n *\n * Used in conjunction with the [`notifyOnNetworkStatusChange`](#notifyonnetworkstatuschange) option.\n *\n * @docGroup 2. Network info\n */\n networkStatus: unknown;\n /**\n * An object containing the variables that were provided for the query.\n *\n * @docGroup 1. Operation data\n */\n variables: unknown;\n\n /**\n * A function that enables you to re-execute the query, optionally passing in new `variables`.\n *\n * To guarantee that the refetch performs a network request, its `fetchPolicy` is set to `network-only` (unless the original query's `fetchPolicy` is `no-cache` or `cache-and-network`, which also guarantee a network request).\n *\n * See also [Refetching](https://www.apollographql.com/docs/react/data/queries/#refetching).\n *\n * Returns a `ResultPromise` with an additional `.retain()` method. Calling\n * `.retain()` keeps the network operation running even if the `ObservableQuery`\n * no longer requires the result.\n *\n * @docGroup 3. Helper functions\n */\n refetch: unknown;\n /**\n * {@inheritDoc @apollo/client!ObservableQuery#fetchMore:member(1)}\n *\n * @docGroup 3. Helper functions\n */\n fetchMore: unknown;\n /**\n * {@inheritDoc @apollo/client!ObservableQuery#startPolling:member(1)}\n *\n * @docGroup 3. Helper functions\n */\n startPolling: unknown;\n /**\n * {@inheritDoc @apollo/client!ObservableQuery#stopPolling:member(1)}\n *\n * @docGroup 3. Helper functions\n */\n stopPolling: unknown;\n /**\n * {@inheritDoc @apollo/client!ObservableQuery#subscribeToMore:member(1)}\n *\n * @docGroup 3. Helper functions\n */\n subscribeToMore: unknown;\n /**\n * {@inheritDoc @apollo/client!ObservableQuery#updateQuery:member(1)}\n *\n * @docGroup 3. Helper functions\n */\n updateQuery: unknown;\n\n /**\n * Describes the completeness of `data`.\n *\n * - `empty`: No data could be fulfilled from the cache or the result is\n * incomplete. `data` is `undefined`.\n * - `partial`: Some data could be fulfilled from the cache but `data` is\n * incomplete. This is only possible when `returnPartialData` is `true`.\n * - `streaming`: `data` is incomplete as a result of a deferred query and\n * the result is still streaming in.\n * - `complete`: `data` is a fully satisfied query result fulfilled\n * either from the cache or network.\n *\n * @docGroup 1. Operation data\n */\n dataState: unknown;\n\n /**\n * Describes whether `data` is a complete or partial result. This flag is only\n * set when `returnPartialData` is `true` in query options.\n *\n * @deprecated This field will be removed in a future version of Apollo Client.\n * @docGroup 1. Operation data\n */\n partial: boolean;\n}\n\nexport interface MutationOptionsDocumentation {\n /**\n * A GraphQL document, often created with `gql` from the `graphql-tag`\n * package, that contains a single mutation inside of it.\n *\n * @docGroup 1. Operation options\n */\n mutation: unknown;\n\n /**\n * Provide `no-cache` if the mutation's result should _not_ be written to the Apollo Client cache.\n *\n * The default value is `network-only` (which means the result _is_ written to the cache).\n *\n * Unlike queries, mutations _do not_ support [fetch policies](https://www.apollographql.com/docs/react/data/queries/#setting-a-fetch-policy) besides `network-only` and `no-cache`.\n *\n * @docGroup 3. Caching options\n */\n fetchPolicy: unknown;\n\n /**\n * To avoid retaining sensitive information from mutation root field\n * arguments, Apollo Client v3.4+ automatically clears any `ROOT_MUTATION`\n * fields from the cache after each mutation finishes. If you need this\n * information to remain in the cache, you can prevent the removal by passing\n * `keepRootFields: true` to the mutation. `ROOT_MUTATION` result data are\n * also passed to the mutation `update` function, so we recommend obtaining\n * the results that way, rather than using this option, if possible.\n */\n keepRootFields: unknown;\n\n /**\n * By providing either an object or a callback function that, when invoked after\n * a mutation, allows you to return optimistic data and optionally skip updates\n * via the `IGNORE` sentinel object, Apollo Client caches this temporary\n * (and potentially incorrect) response until the mutation completes, enabling\n * more responsive UI updates.\n *\n * For more information, see [Optimistic mutation results](https://www.apollographql.com/docs/react/performance/optimistic-ui/).\n *\n * @docGroup 3. Caching options\n */\n optimisticResponse: unknown;\n\n /**\n * A `MutationQueryReducersMap`, which is map from query names to\n * mutation query reducers. Briefly, this map defines how to incorporate the\n * results of the mutation into the results of queries that are currently\n * being watched by your application.\n */\n updateQueries: unknown;\n\n /**\n * An array (or a function that _returns_ an array) that specifies which queries you want to refetch after the mutation occurs.\n *\n * Each array value can be either:\n *\n * - An object containing the `query` to execute, along with any `variables`\n *\n * - A string indicating the operation name of the query to refetch\n *\n * @docGroup 1. Operation options\n */\n refetchQueries: unknown;\n\n /**\n * If `true`, makes sure all queries included in `refetchQueries` are completed before the mutation is considered complete.\n *\n * The default value is `false` (queries are refetched asynchronously).\n *\n * @docGroup 1. Operation options\n */\n awaitRefetchQueries: unknown;\n\n /**\n * A function used to update the Apollo Client cache after the mutation completes.\n *\n * For more information, see [Updating the cache after a mutation](https://www.apollographql.com/docs/react/data/mutations#updating-the-cache-after-a-mutation).\n *\n * @docGroup 3. Caching options\n */\n update: unknown;\n\n /**\n * Optional callback for intercepting queries whose cache data has been updated by the mutation, as well as any queries specified in the `refetchQueries: [...]` list passed to `client.mutate`.\n *\n * Returning a `Promise` from `onQueryUpdated` will cause the final mutation `Promise` to await the returned `Promise`. Returning `false` causes the query to be ignored.\n *\n * @docGroup 1. Operation options\n */\n onQueryUpdated: unknown;\n\n /**\n * Specifies how the mutation handles a response that returns both GraphQL errors and partial results.\n *\n * For details, see [GraphQL error policies](https://www.apollographql.com/docs/react/data/error-handling/#graphql-error-policies).\n *\n * The default value is `none`, meaning that the mutation result includes error details but _not_ partial results.\n *\n * @docGroup 1. Operation options\n */\n errorPolicy: unknown;\n\n /**\n * An object containing all of the GraphQL variables your mutation requires to execute.\n *\n * Each key in the object corresponds to a variable name, and that key's value corresponds to the variable value.\n *\n * @docGroup 1. Operation options\n */\n variables: unknown;\n\n /**\n * If you're using [Apollo Link](https://www.apollographql.com/docs/react/api/link/introduction/), this object is the initial value of the `context` object that's passed along your link chain.\n *\n * @docGroup 2. Networking options\n */\n context: unknown;\n\n /**\n * The instance of `ApolloClient` to use to execute the mutation.\n *\n * By default, the instance that's passed down via context is used, but you can provide a different instance here.\n *\n * @docGroup 2. Networking options\n */\n client: unknown;\n /**\n * If `true`, the in-progress mutation's associated component re-renders whenever the network status changes or a network error occurs.\n *\n * The default value is `true`.\n *\n * @docGroup 2. Networking options\n */\n notifyOnNetworkStatusChange: unknown;\n /**\n * A callback function that's called when your mutation successfully completes with zero errors (or if `errorPolicy` is `ignore` and partial data is returned).\n *\n * This function is passed the mutation's result `data` and any options passed to the mutation.\n *\n * @docGroup 1. Operation options\n */\n onCompleted: unknown;\n /**\n * A callback function that's called when the mutation encounters one or more errors (unless `errorPolicy` is `ignore`).\n *\n * This function is passed an [`ApolloError`](https://github.com/apollographql/apollo-client/blob/d96f4578f89b933c281bb775a39503f6cdb59ee8/src/errors/index.ts#L36-L39) object that contains either a `networkError` object or a `graphQLErrors` array, depending on the error(s) that occurred, as well as any options passed the mutation.\n *\n * @docGroup 1. Operation options\n */\n onError: unknown;\n /**\n * If `true`:\n *\n * - The initial state update (setting loading to true) is skipped\n * - The success state update (setting data and setting loading to false) is skipped\n * - Error updates will still occur\n *\n * The default value is `false`.\n *\n * This option is useful when you want to execute a mutation but don't need to track its progress or result in the UI, potentially improving performance by reducing re-renders.\n *\n * @docGroup 1. Operation options\n */\n ignoreResults: unknown;\n}\n\nexport interface MutationResultDocumentation {\n /**\n * The data returned from your mutation. Can be `undefined` if `ignoreResults` is `true`.\n */\n data: unknown;\n /**\n * If the mutation produces one or more errors, this object contains either an array of `graphQLErrors` or a single `networkError`. Otherwise, this value is `undefined`.\n *\n * For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).\n */\n error: unknown;\n /**\n * If `true`, the mutation is currently in flight.\n */\n loading: unknown;\n /**\n * If `true`, the mutation's mutate function has been called.\n */\n called: unknown;\n /**\n * The instance of Apollo Client that executed the mutation.\n *\n * Can be useful for manually executing followup operations or writing data to the cache.\n */\n client: unknown;\n /**\n * A function that you can call to reset the mutation's result to its initial, uncalled state.\n */\n reset: unknown;\n /**\n * Custom extensions returned from the GraphQL server\n */\n extensions: unknown;\n}\n\nexport interface SubscriptionOptionsDocumentation {\n /**\n * A GraphQL document, often created with `gql` from the `graphql-tag`\n * package, that contains a single subscription inside of it.\n */\n query: unknown;\n /**\n * An object containing all of the variables your subscription needs to execute\n */\n variables: unknown;\n\n /**\n * Specifies the `ErrorPolicy` to be used for this operation\n */\n errorPolicy: unknown;\n\n /**\n * How you want your component to interact with the Apollo cache. For details, see [Setting a fetch policy](https://www.apollographql.com/docs/react/data/queries/#setting-a-fetch-policy).\n */\n fetchPolicy: unknown;\n\n /**\n * Determines if your subscription should be unsubscribed and subscribed again when an input to the hook (such as `subscription` or `variables`) changes.\n */\n shouldResubscribe: unknown;\n\n /**\n * If `true`, the hook will not cause the component to rerender. This is useful when you want to control the rendering of your component yourself with logic in the `onData` and `onError` callbacks.\n *\n * Changing this to `true` when the hook already has `data` will reset the `data` to `undefined`.\n */\n ignoreResults: unknown;\n /**\n * An `ApolloClient` instance. By default `useSubscription` / `Subscription` uses the client passed down via context, but a different client can be passed in.\n */\n client: unknown;\n\n /**\n * Determines if the current subscription should be skipped. Useful if, for example, variables depend on previous queries and are not ready yet.\n */\n skip: unknown;\n\n /**\n * Shared context between your component and your network interface (Apollo Link).\n */\n context: unknown;\n\n /**\n * Shared context between your component and your network interface (Apollo Link).\n */\n extensions: unknown;\n\n /**\n * Allows the registration of a callback function that will be triggered each time the `useSubscription` Hook / `Subscription` component completes the subscription.\n */\n onComplete: unknown;\n\n /**\n * Allows the registration of a callback function that will be triggered each time the `useSubscription` Hook / `Subscription` component receives data. The callback `options` object param consists of the current Apollo Client instance in `client`, and the received subscription data in `data`.\n */\n onData: unknown;\n\n /**\n * Allows the registration of a callback function that will be triggered each time the `useSubscription` Hook / `Subscription` component receives an error.\n */\n onError: unknown;\n}\n\nexport interface SubscriptionResultDocumentation {\n /**\n * A boolean that indicates whether any initial data has been returned\n */\n loading: unknown;\n /**\n * An object containing the result of your GraphQL subscription. Defaults to an empty object.\n */\n data: unknown;\n /**\n * A runtime error with `graphQLErrors` and `networkError` properties\n */\n error: unknown;\n}\n"]}
|