@apollo/client 4.0.0-rc.6 → 4.0.0-rc.8
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 +159 -0
- package/__cjs/cache/core/cache.cjs +12 -7
- package/__cjs/cache/core/cache.cjs.map +1 -1
- package/__cjs/cache/core/cache.d.cts +12 -7
- package/__cjs/core/ApolloClient.cjs +2 -2
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +80 -98
- package/__cjs/core/ObservableQuery.d.cts +41 -74
- package/__cjs/core/QueryInfo.cjs.map +1 -1
- package/__cjs/core/QueryInfo.d.cts +3 -3
- package/__cjs/core/QueryManager.cjs +0 -2
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/QueryManager.d.cts +3 -3
- package/__cjs/core/index.cjs +1 -2
- package/__cjs/core/index.cjs.map +1 -1
- package/__cjs/core/index.d.cts +2 -3
- package/__cjs/core/types.d.cts +40 -28
- package/__cjs/errors/CombinedGraphQLErrors.cjs +22 -17
- package/__cjs/errors/CombinedGraphQLErrors.cjs.map +1 -1
- package/__cjs/errors/CombinedGraphQLErrors.d.cts +39 -20
- package/__cjs/errors/CombinedProtocolErrors.cjs +12 -6
- package/__cjs/errors/CombinedProtocolErrors.cjs.map +1 -1
- package/__cjs/errors/CombinedProtocolErrors.d.cts +12 -6
- package/__cjs/errors/ServerError.cjs +2 -1
- package/__cjs/errors/ServerError.cjs.map +1 -1
- package/__cjs/errors/ServerError.d.cts +2 -1
- package/__cjs/errors/ServerParseError.cjs +2 -1
- package/__cjs/errors/ServerParseError.cjs.map +1 -1
- package/__cjs/errors/ServerParseError.d.cts +2 -1
- package/__cjs/incremental/handlers/defer20220824.cjs.map +1 -1
- package/__cjs/incremental/handlers/defer20220824.d.cts +4 -4
- package/__cjs/incremental/handlers/notImplemented.cjs.map +1 -1
- package/__cjs/incremental/handlers/notImplemented.d.cts +2 -2
- package/__cjs/incremental/types.d.cts +4 -4
- package/__cjs/invariantErrorCodes.cjs +15 -11
- package/__cjs/link/batch/batchLink.cjs +4 -12
- package/__cjs/link/batch/batchLink.cjs.map +1 -1
- package/__cjs/link/batch/batchLink.d.cts +36 -28
- package/__cjs/link/batch/batching.cjs +1 -1
- package/__cjs/link/batch/batching.cjs.map +1 -1
- package/__cjs/link/batch/batching.d.cts +8 -8
- package/__cjs/link/batch/index.cjs +1 -2
- package/__cjs/link/batch/index.cjs.map +1 -1
- package/__cjs/link/batch/index.d.cts +1 -2
- package/__cjs/link/batch-http/batchHttpLink.cjs +29 -6
- package/__cjs/link/batch-http/batchHttpLink.cjs.map +1 -1
- package/__cjs/link/batch-http/batchHttpLink.d.cts +45 -6
- package/__cjs/link/client-awareness/ClientAwarenessLink.cjs +33 -0
- package/__cjs/link/client-awareness/ClientAwarenessLink.cjs.map +1 -1
- package/__cjs/link/client-awareness/ClientAwarenessLink.d.cts +35 -2
- package/__cjs/link/context/index.cjs.map +1 -1
- package/__cjs/link/context/index.d.cts +3 -4
- package/__cjs/link/core/ApolloLink.cjs +226 -54
- package/__cjs/link/core/ApolloLink.cjs.map +1 -1
- package/__cjs/link/core/ApolloLink.d.cts +355 -9
- package/__cjs/link/core/concat.cjs +4 -0
- package/__cjs/link/core/concat.cjs.map +1 -1
- package/__cjs/link/core/concat.d.cts +4 -0
- package/__cjs/link/core/deprecated.cjs +3 -0
- package/__cjs/link/core/deprecated.cjs.map +1 -0
- package/__cjs/link/core/deprecated.d.cts +10 -0
- package/__cjs/link/core/empty.cjs +4 -0
- package/__cjs/link/core/empty.cjs.map +1 -1
- package/__cjs/link/core/empty.d.cts +4 -0
- package/__cjs/link/core/from.cjs +4 -0
- package/__cjs/link/core/from.cjs.map +1 -1
- package/__cjs/link/core/from.d.cts +4 -0
- package/__cjs/link/core/split.cjs +4 -0
- package/__cjs/link/core/split.cjs.map +1 -1
- package/__cjs/link/core/split.d.cts +4 -0
- package/__cjs/link/core/types.d.cts +2 -33
- package/__cjs/link/error/index.cjs +44 -0
- package/__cjs/link/error/index.cjs.map +1 -1
- package/__cjs/link/error/index.d.cts +68 -9
- package/__cjs/link/http/BaseHttpLink.cjs +3 -4
- package/__cjs/link/http/BaseHttpLink.cjs.map +1 -1
- package/__cjs/link/http/HttpLink.cjs +26 -1
- package/__cjs/link/http/HttpLink.cjs.map +1 -1
- package/__cjs/link/http/HttpLink.d.cts +191 -89
- package/__cjs/link/http/index.cjs +1 -3
- package/__cjs/link/http/index.cjs.map +1 -1
- package/__cjs/link/http/index.d.cts +0 -2
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs +40 -25
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs.map +1 -1
- package/__cjs/link/http/parseAndCheckHttpResponse.d.cts +2 -2
- package/__cjs/link/http/rewriteURIForGET.cjs +2 -3
- package/__cjs/link/http/rewriteURIForGET.cjs.map +1 -1
- package/__cjs/link/http/selectHttpOptionsAndBody.cjs.map +1 -1
- package/__cjs/link/http/selectHttpOptionsAndBody.d.cts +3 -3
- package/__cjs/link/http/selectURI.cjs.map +1 -1
- package/__cjs/link/http/selectURI.d.cts +2 -2
- package/__cjs/link/index.cjs.map +1 -1
- package/__cjs/link/index.d.cts +2 -1
- package/__cjs/link/persisted-queries/index.cjs.map +1 -1
- package/__cjs/link/persisted-queries/index.d.cts +23 -25
- package/__cjs/link/remove-typename/index.cjs.map +1 -1
- package/__cjs/link/remove-typename/index.d.cts +0 -1
- package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs.map +1 -1
- package/__cjs/link/remove-typename/removeTypenameFromVariables.d.cts +9 -8
- package/__cjs/link/retry/delayFunction.cjs.map +1 -1
- package/__cjs/link/retry/delayFunction.d.cts +2 -39
- package/__cjs/link/retry/retryFunction.cjs.map +1 -1
- package/__cjs/link/retry/retryFunction.d.cts +2 -29
- package/__cjs/link/retry/retryLink.cjs +12 -9
- package/__cjs/link/retry/retryLink.cjs.map +1 -1
- package/__cjs/link/retry/retryLink.d.cts +57 -6
- package/__cjs/link/schema/index.cjs.map +1 -1
- package/__cjs/link/schema/index.d.cts +3 -4
- package/__cjs/link/subscriptions/index.cjs +23 -0
- package/__cjs/link/subscriptions/index.cjs.map +1 -1
- package/__cjs/link/subscriptions/index.d.cts +24 -2
- package/__cjs/link/utils/createOperation.cjs +12 -4
- package/__cjs/link/utils/createOperation.cjs.map +1 -1
- package/__cjs/link/utils/createOperation.d.cts +2 -2
- package/__cjs/link/utils/index.cjs +1 -5
- package/__cjs/link/utils/index.cjs.map +1 -1
- package/__cjs/link/utils/index.d.cts +0 -2
- package/__cjs/link/ws/index.cjs +17 -1
- package/__cjs/link/ws/index.cjs.map +1 -1
- package/__cjs/link/ws/index.d.cts +8 -2
- package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useBackgroundQuery.d.cts +125 -93
- package/__cjs/react/hooks/useFragment.cjs.map +1 -1
- package/__cjs/react/hooks/useFragment.d.cts +2 -2
- package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLazyQuery.d.cts +70 -108
- package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLoadableQuery.d.cts +52 -61
- package/__cjs/react/hooks/useMutation.cjs.map +1 -1
- package/__cjs/react/hooks/useMutation.d.cts +36 -54
- package/__cjs/react/hooks/useQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useQuery.d.cts +64 -105
- package/__cjs/react/hooks/useQueryRefHandlers.cjs.map +1 -1
- package/__cjs/react/hooks/useQueryRefHandlers.d.cts +17 -8
- package/__cjs/react/hooks/useReadQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useReadQuery.d.cts +6 -9
- package/__cjs/react/hooks/useSubscription.cjs.map +1 -1
- package/__cjs/react/hooks/useSubscription.d.cts +32 -24
- package/__cjs/react/hooks/useSuspenseFragment.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.d.cts +75 -94
- package/__cjs/react/internal/cache/QueryReference.cjs.map +1 -1
- package/__cjs/react/internal/cache/QueryReference.d.cts +3 -1
- package/__cjs/react/query-preloader/createQueryPreloader.cjs.map +1 -1
- package/__cjs/react/query-preloader/createQueryPreloader.d.cts +29 -20
- package/__cjs/react/types/types.documentation.d.cts +5 -5
- package/__cjs/testing/core/mocking/mockLink.cjs.map +1 -1
- package/__cjs/testing/core/mocking/mockLink.d.cts +5 -6
- package/__cjs/testing/core/mocking/mockSubscriptionLink.cjs.map +1 -1
- package/__cjs/testing/core/mocking/mockSubscriptionLink.d.cts +3 -4
- package/__cjs/utilities/internal/types/DocumentationTypes.d.cts +20 -28
- package/__cjs/utilities/internal/types/VariablesOption.d.cts +2 -6
- package/__cjs/utilities/subscriptions/relay/index.cjs +1 -2
- package/__cjs/utilities/subscriptions/relay/index.cjs.map +1 -1
- package/__cjs/version.cjs +1 -1
- package/cache/core/cache.d.ts +12 -7
- package/cache/core/cache.js +12 -7
- package/cache/core/cache.js.map +1 -1
- package/core/ApolloClient.d.ts +80 -98
- package/core/ApolloClient.js +2 -2
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.d.ts +41 -74
- package/core/QueryInfo.d.ts +3 -3
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +3 -3
- package/core/QueryManager.js +0 -2
- package/core/QueryManager.js.map +1 -1
- package/core/index.d.ts +2 -3
- package/core/index.js +1 -1
- package/core/index.js.map +1 -1
- package/core/types.d.ts +40 -28
- package/errors/CombinedGraphQLErrors.d.ts +39 -20
- package/errors/CombinedGraphQLErrors.js +22 -17
- package/errors/CombinedGraphQLErrors.js.map +1 -1
- package/errors/CombinedProtocolErrors.d.ts +12 -6
- package/errors/CombinedProtocolErrors.js +12 -6
- package/errors/CombinedProtocolErrors.js.map +1 -1
- package/errors/ServerError.d.ts +2 -1
- package/errors/ServerError.js +2 -1
- package/errors/ServerError.js.map +1 -1
- package/errors/ServerParseError.d.ts +2 -1
- package/errors/ServerParseError.js +2 -1
- package/errors/ServerParseError.js.map +1 -1
- package/incremental/handlers/defer20220824.d.ts +4 -4
- package/incremental/handlers/defer20220824.js.map +1 -1
- package/incremental/handlers/notImplemented.d.ts +2 -2
- package/incremental/handlers/notImplemented.js.map +1 -1
- package/incremental/types.d.ts +4 -4
- package/incremental/types.js.map +1 -1
- package/invariantErrorCodes.js +15 -11
- package/link/batch/batchLink.d.ts +37 -29
- package/link/batch/batchLink.js +3 -10
- package/link/batch/batchLink.js.map +1 -1
- package/link/batch/batching.d.ts +8 -8
- package/link/batch/batching.js +2 -2
- package/link/batch/batching.js.map +1 -1
- package/link/batch/index.d.ts +1 -2
- package/link/batch/index.js +1 -1
- package/link/batch/index.js.map +1 -1
- package/link/batch-http/batchHttpLink.d.ts +46 -7
- package/link/batch-http/batchHttpLink.js +30 -7
- package/link/batch-http/batchHttpLink.js.map +1 -1
- package/link/client-awareness/ClientAwarenessLink.d.ts +35 -2
- package/link/client-awareness/ClientAwarenessLink.js +33 -0
- package/link/client-awareness/ClientAwarenessLink.js.map +1 -1
- package/link/context/index.d.ts +3 -4
- package/link/context/index.js.map +1 -1
- package/link/core/ApolloLink.d.ts +355 -9
- package/link/core/ApolloLink.js +227 -56
- package/link/core/ApolloLink.js.map +1 -1
- package/link/core/concat.d.ts +4 -0
- package/link/core/concat.js +4 -0
- package/link/core/concat.js.map +1 -1
- package/link/core/deprecated.d.ts +10 -0
- package/link/core/deprecated.js +2 -0
- package/link/core/deprecated.js.map +1 -0
- package/link/core/empty.d.ts +4 -0
- package/link/core/empty.js +4 -0
- package/link/core/empty.js.map +1 -1
- package/link/core/from.d.ts +4 -0
- package/link/core/from.js +4 -0
- package/link/core/from.js.map +1 -1
- package/link/core/split.d.ts +4 -0
- package/link/core/split.js +4 -0
- package/link/core/split.js.map +1 -1
- package/link/core/types.d.ts +2 -33
- package/link/core/types.js.map +1 -1
- package/link/error/index.d.ts +69 -10
- package/link/error/index.js +44 -0
- package/link/error/index.js.map +1 -1
- package/link/http/BaseHttpLink.js +3 -4
- package/link/http/BaseHttpLink.js.map +1 -1
- package/link/http/HttpLink.d.ts +192 -90
- package/link/http/HttpLink.js +26 -1
- package/link/http/HttpLink.js.map +1 -1
- package/link/http/index.d.ts +0 -2
- package/link/http/index.js +0 -1
- package/link/http/index.js.map +1 -1
- package/link/http/parseAndCheckHttpResponse.d.ts +2 -2
- package/link/http/parseAndCheckHttpResponse.js +40 -25
- package/link/http/parseAndCheckHttpResponse.js.map +1 -1
- package/link/http/rewriteURIForGET.js +2 -3
- package/link/http/rewriteURIForGET.js.map +1 -1
- package/link/http/selectHttpOptionsAndBody.d.ts +3 -3
- package/link/http/selectHttpOptionsAndBody.js.map +1 -1
- package/link/http/selectURI.d.ts +2 -2
- package/link/http/selectURI.js.map +1 -1
- package/link/index.d.ts +2 -1
- package/link/index.js.map +1 -1
- package/link/persisted-queries/index.d.ts +23 -25
- package/link/persisted-queries/index.js.map +1 -1
- package/link/remove-typename/index.d.ts +0 -1
- package/link/remove-typename/index.js.map +1 -1
- package/link/remove-typename/removeTypenameFromVariables.d.ts +9 -8
- package/link/remove-typename/removeTypenameFromVariables.js.map +1 -1
- package/link/retry/delayFunction.d.ts +2 -39
- package/link/retry/delayFunction.js.map +1 -1
- package/link/retry/retryFunction.d.ts +2 -29
- package/link/retry/retryFunction.js.map +1 -1
- package/link/retry/retryLink.d.ts +57 -6
- package/link/retry/retryLink.js +13 -10
- package/link/retry/retryLink.js.map +1 -1
- package/link/schema/index.d.ts +3 -4
- package/link/schema/index.js.map +1 -1
- package/link/subscriptions/index.d.ts +24 -2
- package/link/subscriptions/index.js +23 -0
- package/link/subscriptions/index.js.map +1 -1
- package/link/utils/createOperation.d.ts +2 -2
- package/link/utils/createOperation.js +12 -4
- package/link/utils/createOperation.js.map +1 -1
- package/link/utils/index.d.ts +0 -2
- package/link/utils/index.js +0 -2
- package/link/utils/index.js.map +1 -1
- package/link/ws/index.d.ts +8 -2
- package/link/ws/index.js +13 -1
- package/link/ws/index.js.map +1 -1
- package/package.json +1 -1
- package/react/hooks/useBackgroundQuery.d.ts +125 -93
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useFragment.d.ts +2 -2
- package/react/hooks/useFragment.js.map +1 -1
- package/react/hooks/useLazyQuery.d.ts +70 -108
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useLoadableQuery.d.ts +52 -61
- package/react/hooks/useLoadableQuery.js.map +1 -1
- package/react/hooks/useMutation.d.ts +36 -54
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +64 -105
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useQueryRefHandlers.d.ts +17 -8
- package/react/hooks/useQueryRefHandlers.js.map +1 -1
- package/react/hooks/useReadQuery.d.ts +6 -9
- package/react/hooks/useReadQuery.js.map +1 -1
- package/react/hooks/useSubscription.d.ts +32 -24
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/useSuspenseFragment.js.map +1 -1
- package/react/hooks/useSuspenseQuery.d.ts +75 -94
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks-compiled/useBackgroundQuery.d.ts +125 -93
- package/react/hooks-compiled/useBackgroundQuery.js.map +1 -1
- package/react/hooks-compiled/useFragment.d.ts +2 -2
- package/react/hooks-compiled/useFragment.js.map +1 -1
- package/react/hooks-compiled/useLazyQuery.d.ts +70 -108
- package/react/hooks-compiled/useLazyQuery.js.map +1 -1
- package/react/hooks-compiled/useLoadableQuery.d.ts +52 -61
- package/react/hooks-compiled/useLoadableQuery.js.map +1 -1
- package/react/hooks-compiled/useMutation.d.ts +36 -54
- package/react/hooks-compiled/useMutation.js.map +1 -1
- package/react/hooks-compiled/useQuery.d.ts +64 -105
- package/react/hooks-compiled/useQuery.js.map +1 -1
- package/react/hooks-compiled/useQueryRefHandlers.d.ts +17 -8
- package/react/hooks-compiled/useQueryRefHandlers.js.map +1 -1
- package/react/hooks-compiled/useReadQuery.d.ts +6 -9
- package/react/hooks-compiled/useReadQuery.js.map +1 -1
- package/react/hooks-compiled/useSubscription.d.ts +32 -24
- package/react/hooks-compiled/useSubscription.js.map +1 -1
- package/react/hooks-compiled/useSuspenseFragment.js.map +1 -1
- package/react/hooks-compiled/useSuspenseQuery.d.ts +75 -94
- package/react/hooks-compiled/useSuspenseQuery.js.map +1 -1
- package/react/internal/cache/QueryReference.d.ts +3 -1
- package/react/internal/cache/QueryReference.js.map +1 -1
- package/react/query-preloader/createQueryPreloader.d.ts +29 -20
- package/react/query-preloader/createQueryPreloader.js.map +1 -1
- package/react/types/types.documentation.d.ts +5 -5
- package/testing/core/mocking/mockLink.d.ts +5 -6
- package/testing/core/mocking/mockLink.js.map +1 -1
- package/testing/core/mocking/mockSubscriptionLink.d.ts +3 -4
- package/testing/core/mocking/mockSubscriptionLink.js.map +1 -1
- package/utilities/internal/types/DocumentationTypes.d.ts +20 -28
- package/utilities/internal/types/VariablesOption.d.ts +2 -6
- package/utilities/subscriptions/relay/index.js +1 -2
- package/utilities/subscriptions/relay/index.js.map +1 -1
- package/version.js +1 -1
- package/__cjs/link/http/serializeFetchParameter.cjs +0 -18
- package/__cjs/link/http/serializeFetchParameter.cjs.map +0 -1
- package/__cjs/link/http/serializeFetchParameter.d.cts +0 -6
- package/__cjs/link/utils/transformOperation.cjs +0 -22
- package/__cjs/link/utils/transformOperation.cjs.map +0 -1
- package/__cjs/link/utils/transformOperation.d.cts +0 -3
- package/__cjs/link/utils/validateOperation.cjs +0 -21
- package/__cjs/link/utils/validateOperation.cjs.map +0 -1
- package/__cjs/link/utils/validateOperation.d.cts +0 -3
- package/link/http/serializeFetchParameter.d.ts +0 -6
- package/link/http/serializeFetchParameter.js +0 -14
- package/link/http/serializeFetchParameter.js.map +0 -1
- package/link/utils/transformOperation.d.ts +0 -3
- package/link/utils/transformOperation.js +0 -19
- package/link/utils/transformOperation.js.map +0 -1
- package/link/utils/validateOperation.d.ts +0 -3
- package/link/utils/validateOperation.js +0 -18
- package/link/utils/validateOperation.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFragment.js","sourceRoot":"","sources":["../../../src/react/hooks/useFragment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,eAAe,CAAC;AAClC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAmB/B,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AA4GjE;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAGzB,OAA+C;IAC/C,aAAa,CAAC;IACd,OAAO,QAAQ,CACb,aAAa;IACb,yDAAyD;IACzD,YAAY,EACZ,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,CAChC,CAAC,OAAO,CAAC,CAAC;AACb,CAAC;AAED,SAAS,YAAY,CACnB,OAA+C;IAE/C,MAAM,MAAM,GAAG,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/C,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;IACzB,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAElC,6EAA6E;IAC7E,kEAAkE;IAClE,0EAA0E;IAC1E,8EAA8E;IAC9E,MAAM,EAAE,GAAG,KAAK,CAAC,OAAO,CACtB,GAAG,EAAE,CACH,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI;QAC/B,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI;YACtB,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EACxB,CAAC,KAAK,EAAE,IAAI,CAAC,CACd,CAAC;IAEF,MAAM,aAAa,GAAG,WAAW,CAAC,GAAG,EAA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,OAAO,EAAE,CAAC;QACjB,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IACxC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import equal from \"@wry/equality\";\nimport * as React from \"react\";\n\nimport type {\n ApolloClient,\n DataValue,\n DocumentNode,\n GetDataState,\n OperationVariables,\n TypedDocumentNode,\n} from \"@apollo/client\";\nimport type {\n Cache,\n MissingTree,\n Reference,\n StoreObject,\n} from \"@apollo/client/cache\";\nimport type { FragmentType, MaybeMasked } from \"@apollo/client/masking\";\nimport type { NoInfer } from \"@apollo/client/utilities/internal\";\n\nimport { useDeepMemo, wrapHook } from \"./internal/index.js\";\nimport { useApolloClient } from \"./useApolloClient.js\";\nimport { useSyncExternalStore } from \"./useSyncExternalStore.js\";\n\nexport declare namespace useFragment {\n import _self = useFragment;\n export interface Options<TData, TVariables extends OperationVariables> {\n /**\n * A GraphQL document created using the `gql` template string tag from\n * `graphql-tag` with one or more fragments which will be used to determine\n * the shape of data to read. If you provide more than one fragment in this\n * document then you must also specify `fragmentName` to select a single.\n */\n fragment: DocumentNode | TypedDocumentNode<TData, TVariables>;\n\n /**\n * The name of the fragment in your GraphQL document to be used. If you do\n * not provide a `fragmentName` and there is only one fragment in your\n * `fragment` document then that fragment will be used.\n */\n fragmentName?: string;\n\n /**\n * Any variables that the GraphQL query may depend on.\n */\n variables?: NoInfer<TVariables>;\n\n /**\n * An object containing a `__typename` and primary key fields (such as `id`) identifying the entity object from which the fragment will be retrieved, or a `{ __ref: \"...\" }` reference, or a `string` ID (uncommon).\n */\n from:\n | StoreObject\n | Reference\n | FragmentType<NoInfer<TData>>\n | string\n | null;\n\n /**\n * Whether to read from optimistic or non-optimistic cache data. If\n * this named option is provided, the optimistic parameter of the\n * readQuery method can be omitted.\n *\n * @defaultValue true\n */\n optimistic?: boolean;\n\n /**\n * The instance of `ApolloClient` to use to look up the fragment.\n *\n * By default, the instance that's passed down via context is used, but you\n * can provide a different instance here.\n *\n * @docGroup 1. Operation options\n */\n client?: ApolloClient;\n }\n\n namespace DocumentationTypes {\n namespace useFragment {\n export interface Options<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n > extends _self.Options<TData, TVariables> {}\n }\n }\n\n // TODO: Update this to return `null` when there is no data returned from the\n // fragment.\n export type Result<TData> =\n | ({\n /** {@inheritDoc @apollo/client!useFragment.DocumentationTypes.useFragment.Result#complete:member} */\n complete: true;\n /** {@inheritDoc @apollo/client!useFragment.DocumentationTypes.useFragment.Result#missing:member} */\n missing?: never;\n } & GetDataState<MaybeMasked<TData>, \"complete\">)\n | ({\n /** {@inheritDoc @apollo/client!useFragment.DocumentationTypes.useFragment.Result#complete:member} */\n complete: false;\n /** {@inheritDoc @apollo/client!useFragment.DocumentationTypes.useFragment.Result#missing:member} */\n missing?: MissingTree;\n } & GetDataState<MaybeMasked<TData>, \"partial\">);\n\n export namespace DocumentationTypes {\n namespace useFragment {\n export interface Result<TData> {\n data: MaybeMasked<TData> | DataValue.Partial<MaybeMasked<TData>>;\n complete: boolean;\n /**\n * A tree of all `MissingFieldError` messages reported during fragment reading, where the branches of the tree indicate the paths of the errors within the query result.\n */\n missing?: MissingTree;\n }\n }\n }\n export namespace DocumentationTypes {\n /** {@inheritDoc @apollo/client!useFragment:function(1)} */\n export function useFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n >({\n fragment,\n from,\n fragmentName,\n variables,\n optimistic,\n client,\n }: useFragment.Options<TData, TVariables>): useFragment.Result<TData>;\n }\n}\n\n/**\n * `useFragment` represents a lightweight live binding into the Apollo Client Cache and enables Apollo Client to broadcast very specific fragment results to individual components. This hook returns an always-up-to-date view of whatever data the cache currently contains for a given fragment. `useFragment` never triggers network requests of its own.\n *\n * Note that the `useQuery` hook remains the primary hook responsible for querying and populating data in the cache ([see the API reference](./hooks#usequery)). As a result, the component reading the fragment data via `useFragment` is still subscribed to all changes in the query data, but receives updates only when that fragment's specific data change.\n *\n * To view a `useFragment` example, see the [Fragments](https://www.apollographql.com/docs/react/data/fragments#usefragment) page.\n */\nexport function useFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(options: useFragment.Options<TData, TVariables>): useFragment.Result<TData> {\n \"use no memo\";\n return wrapHook(\n \"useFragment\",\n // eslint-disable-next-line react-compiler/react-compiler\n useFragment_,\n useApolloClient(options.client)\n )(options);\n}\n\nfunction useFragment_<TData, TVariables extends OperationVariables>(\n options: useFragment.Options<TData, TVariables>\n): useFragment.Result<TData> {\n const client = useApolloClient(options.client);\n const { cache } = client;\n const { from, ...rest } = options;\n\n // We calculate the cache id seperately from `stableOptions` because we don't\n // want changes to non key fields in the `from` property to affect\n // `stableOptions` and retrigger our subscription. If the cache identifier\n // stays the same between renders, we want to reuse the existing subscription.\n const id = React.useMemo(\n () =>\n typeof from === \"string\" ? from\n : from === null ? null\n : cache.identify(from),\n [cache, from]\n );\n\n const stableOptions = useDeepMemo(() => ({ ...rest, from: id! }), [rest, id]);\n\n // Since .next is async, we need to make sure that we\n // get the correct diff on the next render given new diffOptions\n const diff = React.useMemo(() => {\n const { fragment, fragmentName, from, optimistic = true } = stableOptions;\n\n if (from === null) {\n return {\n result: diffToResult({\n result: {},\n complete: false,\n } as Cache.DiffResult<TData>),\n };\n }\n\n const { cache } = client;\n const diff = cache.diff<TData, TVariables>({\n ...stableOptions,\n returnPartialData: true,\n id: from,\n query: cache[\"getFragmentDoc\"](\n client[\"transform\"](fragment),\n fragmentName\n ),\n optimistic,\n });\n\n return {\n result: diffToResult<TData>({\n ...diff,\n result: client[\"queryManager\"].maskFragment({\n fragment,\n fragmentName,\n // TODO: Revert to `diff.result` once `useFragment` supports `null` as\n // valid return value\n data: diff.result === null ? {} : diff.result,\n }) as any,\n }),\n };\n }, [client, stableOptions]);\n\n // Used for both getSnapshot and getServerSnapshot\n const getSnapshot = React.useCallback(() => diff.result, [diff]);\n\n return useSyncExternalStore(\n React.useCallback(\n (forceUpdate) => {\n let lastTimeout = 0;\n\n const subscription =\n stableOptions.from === null ?\n null\n : client.watchFragment(stableOptions).subscribe({\n next: (result) => {\n // Avoid unnecessarily rerendering this hook for the initial result\n // emitted from watchFragment which should be equal to\n // `diff.result`.\n if (equal(result, diff.result)) return;\n diff.result = result;\n // If we get another update before we've re-rendered, bail out of\n // the update and try again. This ensures that the relative timing\n // between useQuery and useFragment stays roughly the same as\n // fixed in https://github.com/apollographql/apollo-client/pull/11083\n clearTimeout(lastTimeout);\n lastTimeout = setTimeout(forceUpdate) as any;\n },\n });\n return () => {\n subscription?.unsubscribe();\n clearTimeout(lastTimeout);\n };\n },\n [client, stableOptions, diff]\n ),\n getSnapshot,\n getSnapshot\n );\n}\n\nfunction diffToResult<TData>(\n diff: Cache.DiffResult<TData>\n): useFragment.Result<TData> {\n const result = {\n data: diff.result,\n complete: !!diff.complete,\n dataState: diff.complete ? \"complete\" : \"partial\",\n } as useFragment.Result<TData>; // TODO: Remove assertion once useFragment returns null\n\n if (diff.missing) {\n result.missing = diff.missing.missing;\n }\n\n return result;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"useFragment.js","sourceRoot":"","sources":["../../../src/react/hooks/useFragment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,eAAe,CAAC;AAClC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAmB/B,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AA4GjE;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAGzB,OAA+C;IAC/C,aAAa,CAAC;IACd,OAAO,QAAQ,CACb,aAAa;IACb,yDAAyD;IACzD,YAAY,EACZ,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,CAChC,CAAC,OAAO,CAAC,CAAC;AACb,CAAC;AAED,SAAS,YAAY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C1B,WAAW,GAAG,UAAU,CAAC,WAAW,CAAQ,CAAC;gBAC/C,CAAC;aACF,CAAC,CAAC;QACP,OAAO,GAAG,EAAE;YACV,YAAY,EAAE,WAAW,EAAE,CAAC;YAC5B,YAAY,CAAC,WAAW,CAAC,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC,EACD,CAAC,MAAM,EAAE,aAAa,EAAE,IAAI,CAAC,CAC9B,EACD,WAAW,EACX,WAAW,CACZ,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CACnB,IAA6B;IAE7B,MAAM,MAAM,GAAG;QACb,IAAI,EAAE,IAAI,CAAC,MAAM;QACjB,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ;QACzB,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS;KACrB,CAAC,CAAC,uDAAuD;IAEvF,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QACjB,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IACxC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import equal from \"@wry/equality\";\nimport * as React from \"react\";\n\nimport type {\n ApolloClient,\n DataValue,\n DocumentNode,\n GetDataState,\n OperationVariables,\n TypedDocumentNode,\n} from \"@apollo/client\";\nimport type {\n Cache,\n MissingTree,\n Reference,\n StoreObject,\n} from \"@apollo/client/cache\";\nimport type { FragmentType, MaybeMasked } from \"@apollo/client/masking\";\nimport type { NoInfer } from \"@apollo/client/utilities/internal\";\n\nimport { useDeepMemo, wrapHook } from \"./internal/index.js\";\nimport { useApolloClient } from \"./useApolloClient.js\";\nimport { useSyncExternalStore } from \"./useSyncExternalStore.js\";\n\nexport declare namespace useFragment {\n import _self = useFragment;\n export interface Options<TData, TVariables extends OperationVariables> {\n /**\n * A GraphQL document created using the `gql` template string tag from\n * `graphql-tag` with one or more fragments which will be used to determine\n * the shape of data to read. If you provide more than one fragment in this\n * document then you must also specify `fragmentName` to select a single.\n */\n fragment: DocumentNode | TypedDocumentNode<TData, TVariables>;\n\n /**\n * The name of the fragment in your GraphQL document to be used. If you do\n * not provide a `fragmentName` and there is only one fragment in your\n * `fragment` document then that fragment will be used.\n */\n fragmentName?: string;\n\n /**\n * Any variables that the GraphQL query may depend on.\n */\n variables?: NoInfer<TVariables>;\n\n /**\n * An object containing a `__typename` and primary key fields (such as `id`) identifying the entity object from which the fragment will be retrieved, or a `{ __ref: \"...\" }` reference, or a `string` ID (uncommon).\n */\n from:\n | StoreObject\n | Reference\n | FragmentType<NoInfer<TData>>\n | string\n | null;\n\n /**\n * Whether to read from optimistic or non-optimistic cache data. If\n * this named option is provided, the optimistic parameter of the\n * readQuery method can be omitted.\n *\n * @defaultValue true\n */\n optimistic?: boolean;\n\n /**\n * The instance of `ApolloClient` to use to look up the fragment.\n *\n * By default, the instance that's passed down via context is used, but you\n * can provide a different instance here.\n *\n * @docGroup 1. Operation options\n */\n client?: ApolloClient;\n }\n\n namespace DocumentationTypes {\n namespace useFragment {\n export interface Options<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n > extends _self.Options<TData, TVariables> {}\n }\n }\n\n // TODO: Update this to return `null` when there is no data returned from the\n // fragment.\n export type Result<TData> =\n | ({\n /** {@inheritDoc @apollo/client/react!useFragment.DocumentationTypes.useFragment.Result#complete:member} */\n complete: true;\n /** {@inheritDoc @apollo/client/react!useFragment.DocumentationTypes.useFragment.Result#missing:member} */\n missing?: never;\n } & GetDataState<MaybeMasked<TData>, \"complete\">)\n | ({\n /** {@inheritDoc @apollo/client/react!useFragment.DocumentationTypes.useFragment.Result#complete:member} */\n complete: false;\n /** {@inheritDoc @apollo/client/react!useFragment.DocumentationTypes.useFragment.Result#missing:member} */\n missing?: MissingTree;\n } & GetDataState<MaybeMasked<TData>, \"partial\">);\n\n export namespace DocumentationTypes {\n namespace useFragment {\n export interface Result<TData> {\n data: MaybeMasked<TData> | DataValue.Partial<MaybeMasked<TData>>;\n complete: boolean;\n /**\n * A tree of all `MissingFieldError` messages reported during fragment reading, where the branches of the tree indicate the paths of the errors within the query result.\n */\n missing?: MissingTree;\n }\n }\n }\n export namespace DocumentationTypes {\n /** {@inheritDoc @apollo/client/react!useFragment:function(1)} */\n export function useFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n >({\n fragment,\n from,\n fragmentName,\n variables,\n optimistic,\n client,\n }: useFragment.Options<TData, TVariables>): useFragment.Result<TData>;\n }\n}\n\n/**\n * `useFragment` represents a lightweight live binding into the Apollo Client Cache and enables Apollo Client to broadcast very specific fragment results to individual components. This hook returns an always-up-to-date view of whatever data the cache currently contains for a given fragment. `useFragment` never triggers network requests of its own.\n *\n * Note that the `useQuery` hook remains the primary hook responsible for querying and populating data in the cache ([see the API reference](./hooks#usequery)). As a result, the component reading the fragment data via `useFragment` is still subscribed to all changes in the query data, but receives updates only when that fragment's specific data change.\n *\n * To view a `useFragment` example, see the [Fragments](https://www.apollographql.com/docs/react/data/fragments#usefragment) page.\n */\nexport function useFragment<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(options: useFragment.Options<TData, TVariables>): useFragment.Result<TData> {\n \"use no memo\";\n return wrapHook(\n \"useFragment\",\n // eslint-disable-next-line react-compiler/react-compiler\n useFragment_,\n useApolloClient(options.client)\n )(options);\n}\n\nfunction useFragment_<TData, TVariables extends OperationVariables>(\n options: useFragment.Options<TData, TVariables>\n): useFragment.Result<TData> {\n const client = useApolloClient(options.client);\n const { cache } = client;\n const { from, ...rest } = options;\n\n // We calculate the cache id seperately from `stableOptions` because we don't\n // want changes to non key fields in the `from` property to affect\n // `stableOptions` and retrigger our subscription. If the cache identifier\n // stays the same between renders, we want to reuse the existing subscription.\n const id = React.useMemo(\n () =>\n typeof from === \"string\" ? from\n : from === null ? null\n : cache.identify(from),\n [cache, from]\n );\n\n const stableOptions = useDeepMemo(() => ({ ...rest, from: id! }), [rest, id]);\n\n // Since .next is async, we need to make sure that we\n // get the correct diff on the next render given new diffOptions\n const diff = React.useMemo(() => {\n const { fragment, fragmentName, from, optimistic = true } = stableOptions;\n\n if (from === null) {\n return {\n result: diffToResult({\n result: {},\n complete: false,\n } as Cache.DiffResult<TData>),\n };\n }\n\n const { cache } = client;\n const diff = cache.diff<TData, TVariables>({\n ...stableOptions,\n returnPartialData: true,\n id: from,\n query: cache[\"getFragmentDoc\"](\n client[\"transform\"](fragment),\n fragmentName\n ),\n optimistic,\n });\n\n return {\n result: diffToResult<TData>({\n ...diff,\n result: client[\"queryManager\"].maskFragment({\n fragment,\n fragmentName,\n // TODO: Revert to `diff.result` once `useFragment` supports `null` as\n // valid return value\n data: diff.result === null ? {} : diff.result,\n }) as any,\n }),\n };\n }, [client, stableOptions]);\n\n // Used for both getSnapshot and getServerSnapshot\n const getSnapshot = React.useCallback(() => diff.result, [diff]);\n\n return useSyncExternalStore(\n React.useCallback(\n (forceUpdate) => {\n let lastTimeout = 0;\n\n const subscription =\n stableOptions.from === null ?\n null\n : client.watchFragment(stableOptions).subscribe({\n next: (result) => {\n // Avoid unnecessarily rerendering this hook for the initial result\n // emitted from watchFragment which should be equal to\n // `diff.result`.\n if (equal(result, diff.result)) return;\n diff.result = result;\n // If we get another update before we've re-rendered, bail out of\n // the update and try again. This ensures that the relative timing\n // between useQuery and useFragment stays roughly the same as\n // fixed in https://github.com/apollographql/apollo-client/pull/11083\n clearTimeout(lastTimeout);\n lastTimeout = setTimeout(forceUpdate) as any;\n },\n });\n return () => {\n subscription?.unsubscribe();\n clearTimeout(lastTimeout);\n };\n },\n [client, stableOptions, diff]\n ),\n getSnapshot,\n getSnapshot\n );\n}\n\nfunction diffToResult<TData>(\n diff: Cache.DiffResult<TData>\n): useFragment.Result<TData> {\n const result = {\n data: diff.result,\n complete: !!diff.complete,\n dataState: diff.complete ? \"complete\" : \"partial\",\n } as useFragment.Result<TData>; // TODO: Remove assertion once useFragment returns null\n\n if (diff.missing) {\n result.missing = diff.missing.missing;\n }\n\n return result;\n}\n"]}
|
|
@@ -13,25 +13,22 @@ export declare namespace useLazyQuery {
|
|
|
13
13
|
*
|
|
14
14
|
* The default value is `cache-first`.
|
|
15
15
|
*
|
|
16
|
-
* @docGroup
|
|
17
|
-
*
|
|
18
|
-
* 3. Caching options
|
|
16
|
+
* @docGroup 3. Caching options
|
|
19
17
|
*/
|
|
20
18
|
fetchPolicy?: WatchQueryFetchPolicy;
|
|
21
19
|
/**
|
|
22
20
|
* Specifies the `FetchPolicy` to be used after this query has completed.
|
|
23
21
|
*
|
|
24
|
-
* @docGroup
|
|
25
|
-
*
|
|
26
|
-
* 3. Caching options
|
|
22
|
+
* @docGroup 3. Caching options
|
|
27
23
|
*/
|
|
28
24
|
nextFetchPolicy?: WatchQueryFetchPolicy | ((this: ApolloClient.WatchQueryOptions<TData, TVariables>, currentFetchPolicy: WatchQueryFetchPolicy, context: InternalTypes.NextFetchPolicyContext<TData, TVariables>) => WatchQueryFetchPolicy);
|
|
29
25
|
/**
|
|
30
|
-
* Specifies whether a `NetworkStatus.refetch` operation should merge
|
|
26
|
+
* Specifies whether a `NetworkStatus.refetch` operation should merge
|
|
27
|
+
* incoming field data with existing data, or overwrite the existing data.
|
|
28
|
+
* Overwriting is probably preferable, but merging is currently the default
|
|
29
|
+
* behavior, for backwards compatibility with Apollo Client 3.x.
|
|
31
30
|
*
|
|
32
|
-
* @docGroup
|
|
33
|
-
*
|
|
34
|
-
* 3. Caching options
|
|
31
|
+
* @docGroup 3. Caching options
|
|
35
32
|
*/
|
|
36
33
|
refetchWritePolicy?: RefetchWritePolicy;
|
|
37
34
|
/**
|
|
@@ -41,9 +38,7 @@ export declare namespace useLazyQuery {
|
|
|
41
38
|
*
|
|
42
39
|
* The default value is `none`, meaning that the query result includes error details but not partial results.
|
|
43
40
|
*
|
|
44
|
-
* @docGroup
|
|
45
|
-
*
|
|
46
|
-
* 1. Operation options
|
|
41
|
+
* @docGroup 1. Operation options
|
|
47
42
|
*/
|
|
48
43
|
errorPolicy?: ErrorPolicy;
|
|
49
44
|
/**
|
|
@@ -51,9 +46,7 @@ export declare namespace useLazyQuery {
|
|
|
51
46
|
*
|
|
52
47
|
* The default value is `0` (no polling).
|
|
53
48
|
*
|
|
54
|
-
* @docGroup
|
|
55
|
-
*
|
|
56
|
-
* 2. Networking options
|
|
49
|
+
* @docGroup 2. Networking options
|
|
57
50
|
*/
|
|
58
51
|
pollInterval?: number;
|
|
59
52
|
/**
|
|
@@ -61,9 +54,7 @@ export declare namespace useLazyQuery {
|
|
|
61
54
|
*
|
|
62
55
|
* The default value is `true`.
|
|
63
56
|
*
|
|
64
|
-
* @docGroup
|
|
65
|
-
*
|
|
66
|
-
* 2. Networking options
|
|
57
|
+
* @docGroup 2. Networking options
|
|
67
58
|
*/
|
|
68
59
|
notifyOnNetworkStatusChange?: boolean;
|
|
69
60
|
/**
|
|
@@ -71,27 +62,24 @@ export declare namespace useLazyQuery {
|
|
|
71
62
|
*
|
|
72
63
|
* The default value is `false`.
|
|
73
64
|
*
|
|
74
|
-
* @docGroup
|
|
75
|
-
*
|
|
76
|
-
* 3. Caching options
|
|
65
|
+
* @docGroup 3. Caching options
|
|
77
66
|
*/
|
|
78
67
|
returnPartialData?: boolean;
|
|
79
68
|
/**
|
|
80
|
-
* A callback function that's called whenever a refetch attempt occurs
|
|
81
|
-
*
|
|
82
|
-
*
|
|
69
|
+
* A callback function that's called whenever a refetch attempt occurs
|
|
70
|
+
* while polling. If the function returns `true`, the refetch is
|
|
71
|
+
* skipped and not reattempted until the next poll interval.
|
|
83
72
|
*
|
|
84
|
-
* 2. Networking options
|
|
73
|
+
* @docGroup 2. Networking options
|
|
85
74
|
*/
|
|
86
75
|
skipPollAttempt?: () => boolean;
|
|
87
76
|
/**
|
|
88
77
|
* The instance of `ApolloClient` to use to execute the query.
|
|
89
78
|
*
|
|
90
|
-
* By default, the instance that's passed down via context is used, but you
|
|
79
|
+
* By default, the instance that's passed down via context is used, but you
|
|
80
|
+
* can provide a different instance here.
|
|
91
81
|
*
|
|
92
|
-
* @docGroup
|
|
93
|
-
*
|
|
94
|
-
* 1. Operation options
|
|
82
|
+
* @docGroup 1. Operation options
|
|
95
83
|
*/
|
|
96
84
|
client?: ApolloClient;
|
|
97
85
|
}
|
|
@@ -105,42 +93,34 @@ export declare namespace useLazyQuery {
|
|
|
105
93
|
interface Result<TData, TVariables extends OperationVariables> {
|
|
106
94
|
/**
|
|
107
95
|
* A function that instructs the query to begin re-executing at a specified interval (in milliseconds).
|
|
96
|
+
*
|
|
108
97
|
*
|
|
109
|
-
*
|
|
110
|
-
* @docGroup
|
|
111
|
-
*
|
|
112
|
-
* 3. Helper functions
|
|
98
|
+
* @docGroup 3. Helper functions
|
|
113
99
|
*/
|
|
114
100
|
startPolling: (pollInterval: number) => void;
|
|
115
101
|
/**
|
|
116
102
|
* A function that instructs the query to stop polling after a previous call to `startPolling`.
|
|
103
|
+
*
|
|
117
104
|
*
|
|
118
|
-
*
|
|
119
|
-
* @docGroup
|
|
120
|
-
*
|
|
121
|
-
* 3. Helper functions
|
|
105
|
+
* @docGroup 3. Helper functions
|
|
122
106
|
*/
|
|
123
107
|
stopPolling: () => void;
|
|
124
108
|
/**
|
|
125
109
|
* A function that enables you to execute a [subscription](https://www.apollographql.com/docs/react/data/subscriptions/), usually to subscribe to specific fields that were included in the query.
|
|
126
110
|
*
|
|
127
111
|
* This function returns _another_ function that you can call to terminate the subscription.
|
|
112
|
+
*
|
|
128
113
|
*
|
|
129
|
-
*
|
|
130
|
-
* @docGroup
|
|
131
|
-
*
|
|
132
|
-
* 3. Helper functions
|
|
114
|
+
* @docGroup 3. Helper functions
|
|
133
115
|
*/
|
|
134
116
|
subscribeToMore: SubscribeToMoreFunction<TData, TVariables>;
|
|
135
117
|
/**
|
|
136
118
|
* A function that enables you to update the query's cached result without executing a followup GraphQL operation.
|
|
137
119
|
*
|
|
138
120
|
* See [using updateQuery and updateFragment](https://www.apollographql.com/docs/react/caching/cache-interaction/#using-updatequery-and-updatefragment) for additional information.
|
|
121
|
+
*
|
|
139
122
|
*
|
|
140
|
-
*
|
|
141
|
-
* @docGroup
|
|
142
|
-
*
|
|
143
|
-
* 3. Helper functions
|
|
123
|
+
* @docGroup 3. Helper functions
|
|
144
124
|
*/
|
|
145
125
|
updateQuery: (mapFn: UpdateQueryMapFn<TData, TVariables>) => void;
|
|
146
126
|
/**
|
|
@@ -150,28 +130,25 @@ export declare namespace useLazyQuery {
|
|
|
150
130
|
*
|
|
151
131
|
* See also [Refetching](https://www.apollographql.com/docs/react/data/queries/#refetching).
|
|
152
132
|
*
|
|
153
|
-
* Returns a `ResultPromise` with an additional `.retain()` method. Calling
|
|
154
|
-
*
|
|
155
|
-
*
|
|
133
|
+
* Returns a `ResultPromise` with an additional `.retain()` method. Calling
|
|
134
|
+
* `.retain()` keeps the network operation running even if the `ObservableQuery`
|
|
135
|
+
* no longer requires the result.
|
|
156
136
|
*
|
|
157
|
-
* 3. Helper functions
|
|
137
|
+
* @docGroup 3. Helper functions
|
|
158
138
|
*/
|
|
159
139
|
refetch: (variables?: Partial<TVariables>) => Promise<ApolloClient.QueryResult<MaybeMasked<TData>>>;
|
|
160
140
|
/**
|
|
161
141
|
* A function that helps you fetch the next set of results for a [paginated list field](https://www.apollographql.com/docs/react/pagination/core-api/).
|
|
142
|
+
*
|
|
162
143
|
*
|
|
163
|
-
*
|
|
164
|
-
* @docGroup
|
|
165
|
-
*
|
|
166
|
-
* 3. Helper functions
|
|
144
|
+
* @docGroup 3. Helper functions
|
|
167
145
|
*/
|
|
168
146
|
fetchMore: <TFetchData = TData, TFetchVars extends OperationVariables = TVariables>(fetchMoreOptions: ObservableQuery.FetchMoreOptions<TData, TVariables, TFetchData, TFetchVars>) => Promise<ApolloClient.QueryResult<MaybeMasked<TFetchData>>>;
|
|
169
147
|
/**
|
|
170
|
-
* The instance of Apollo Client that executed the query.
|
|
148
|
+
* The instance of Apollo Client that executed the query.
|
|
149
|
+
* Can be useful for manually executing followup queries or writing data to the cache.
|
|
171
150
|
*
|
|
172
|
-
* @docGroup
|
|
173
|
-
*
|
|
174
|
-
* 2. Network info
|
|
151
|
+
* @docGroup 2. Network info
|
|
175
152
|
*/
|
|
176
153
|
client: ApolloClient;
|
|
177
154
|
/**
|
|
@@ -183,27 +160,22 @@ export declare namespace useLazyQuery {
|
|
|
183
160
|
*
|
|
184
161
|
* This value is `undefined` if this is the query's first execution.
|
|
185
162
|
*
|
|
186
|
-
* @docGroup
|
|
187
|
-
*
|
|
188
|
-
* 1. Operation data
|
|
163
|
+
* @docGroup 1. Operation data
|
|
189
164
|
*/
|
|
190
165
|
previousData?: MaybeMasked<TData>;
|
|
191
166
|
/**
|
|
192
|
-
* A single ErrorLike object describing the error that occured during the latest
|
|
167
|
+
* A single ErrorLike object describing the error that occured during the latest
|
|
168
|
+
* query execution.
|
|
193
169
|
*
|
|
194
170
|
* For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).
|
|
195
171
|
*
|
|
196
|
-
* @docGroup
|
|
197
|
-
*
|
|
198
|
-
* 1. Operation data
|
|
172
|
+
* @docGroup 1. Operation data
|
|
199
173
|
*/
|
|
200
174
|
error?: ErrorLike;
|
|
201
175
|
/**
|
|
202
176
|
* If `true`, the query is still in flight and results have not yet been returned.
|
|
203
177
|
*
|
|
204
|
-
* @docGroup
|
|
205
|
-
*
|
|
206
|
-
* 2. Network info
|
|
178
|
+
* @docGroup 2. Network info
|
|
207
179
|
*/
|
|
208
180
|
loading: boolean;
|
|
209
181
|
/**
|
|
@@ -211,9 +183,7 @@ export declare namespace useLazyQuery {
|
|
|
211
183
|
*
|
|
212
184
|
* Used in conjunction with the [`notifyOnNetworkStatusChange`](#notifyonnetworkstatuschange) option.
|
|
213
185
|
*
|
|
214
|
-
* @docGroup
|
|
215
|
-
*
|
|
216
|
-
* 2. Network info
|
|
186
|
+
* @docGroup 2. Network info
|
|
217
187
|
*/
|
|
218
188
|
networkStatus: NetworkStatus;
|
|
219
189
|
}
|
|
@@ -228,9 +198,7 @@ export declare namespace useLazyQuery {
|
|
|
228
198
|
/**
|
|
229
199
|
* An object containing the variables that were provided for the query.
|
|
230
200
|
*
|
|
231
|
-
* @docGroup
|
|
232
|
-
*
|
|
233
|
-
* 1. Operation data
|
|
201
|
+
* @docGroup 1. Operation data
|
|
234
202
|
*/
|
|
235
203
|
variables: TVariables;
|
|
236
204
|
} & GetDataState<MaybeMasked<TData>, TStates>) | {
|
|
@@ -243,9 +211,7 @@ export declare namespace useLazyQuery {
|
|
|
243
211
|
/**
|
|
244
212
|
* An object containing the variables that were provided for the query.
|
|
245
213
|
*
|
|
246
|
-
* @docGroup
|
|
247
|
-
*
|
|
248
|
-
* 1. Operation data
|
|
214
|
+
* @docGroup 1. Operation data
|
|
249
215
|
*/
|
|
250
216
|
variables: Partial<TVariables>;
|
|
251
217
|
/**
|
|
@@ -253,19 +219,22 @@ export declare namespace useLazyQuery {
|
|
|
253
219
|
*
|
|
254
220
|
* This value might be `undefined` if a query results in one or more errors (depending on the query's `errorPolicy`).
|
|
255
221
|
*
|
|
256
|
-
* @docGroup
|
|
257
|
-
*
|
|
258
|
-
* 1. Operation data
|
|
222
|
+
* @docGroup 1. Operation data
|
|
259
223
|
*/
|
|
260
224
|
data: undefined;
|
|
261
225
|
/**
|
|
262
226
|
* Describes the completeness of `data`.
|
|
263
227
|
*
|
|
264
|
-
* - `empty`: No data could be fulfilled from the cache or the result is
|
|
228
|
+
* - `empty`: No data could be fulfilled from the cache or the result is
|
|
229
|
+
* incomplete. `data` is `undefined`.
|
|
230
|
+
* - `partial`: Some data could be fulfilled from the cache but `data` is
|
|
231
|
+
* incomplete. This is only possible when `returnPartialData` is `true`.
|
|
232
|
+
* - `streaming`: `data` is incomplete as a result of a deferred query and
|
|
233
|
+
* the result is still streaming in.
|
|
234
|
+
* - `complete`: `data` is a fully satisfied query result fulfilled
|
|
235
|
+
* either from the cache or network.
|
|
265
236
|
*
|
|
266
|
-
* @docGroup
|
|
267
|
-
*
|
|
268
|
-
* 1. Operation data
|
|
237
|
+
* @docGroup 1. Operation data
|
|
269
238
|
*/
|
|
270
239
|
dataState: "empty";
|
|
271
240
|
});
|
|
@@ -285,9 +254,7 @@ export declare namespace useLazyQuery {
|
|
|
285
254
|
/**
|
|
286
255
|
* 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.
|
|
287
256
|
*
|
|
288
|
-
* @docGroup
|
|
289
|
-
*
|
|
290
|
-
* 2. Networking options
|
|
257
|
+
* @docGroup 2. Networking options
|
|
291
258
|
*/
|
|
292
259
|
context?: DefaultContext;
|
|
293
260
|
} & VariablesOption<TVariables>;
|
|
@@ -297,9 +264,7 @@ export declare namespace useLazyQuery {
|
|
|
297
264
|
/**
|
|
298
265
|
* 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.
|
|
299
266
|
*
|
|
300
|
-
* @docGroup
|
|
301
|
-
*
|
|
302
|
-
* 2. Networking options
|
|
267
|
+
* @docGroup 2. Networking options
|
|
303
268
|
*/
|
|
304
269
|
context?: DefaultContext;
|
|
305
270
|
}
|
|
@@ -323,13 +288,8 @@ export declare namespace useLazyQuery {
|
|
|
323
288
|
*
|
|
324
289
|
* > Refer to the [Queries - Manual execution with useLazyQuery](https://www.apollographql.com/docs/react/data/queries#manual-execution-with-uselazyquery) section for a more in-depth overview of `useLazyQuery`.
|
|
325
290
|
*
|
|
326
|
-
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
327
|
-
*
|
|
328
|
-
* @param options - Default options to control how the query is executed.
|
|
329
|
-
*
|
|
330
|
-
* @returns A tuple in the form of `[execute, result]`
|
|
331
|
-
*
|
|
332
291
|
* @example
|
|
292
|
+
*
|
|
333
293
|
* ```jsx
|
|
334
294
|
* import { gql } from "@apollo/client";
|
|
335
295
|
* import { useLazyQuery } from "@apollo/client/react";
|
|
@@ -353,6 +313,10 @@ export declare namespace useLazyQuery {
|
|
|
353
313
|
* return <h1>Hello {data.greeting.message}!</h1>;
|
|
354
314
|
* }
|
|
355
315
|
* ```
|
|
316
|
+
*
|
|
317
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
318
|
+
* @param options - Default options to control how the query is executed.
|
|
319
|
+
* @returns A tuple in the form of `[execute, result]`
|
|
356
320
|
*/
|
|
357
321
|
function useLazyQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useLazyQuery.Options<TData, TVariables>): useLazyQuery.ResultTuple<TData, TVariables>;
|
|
358
322
|
}
|
|
@@ -400,13 +364,8 @@ export declare function useLazyQuery<TData = unknown, TVariables extends Operati
|
|
|
400
364
|
*
|
|
401
365
|
* > Refer to the [Queries - Manual execution with useLazyQuery](https://www.apollographql.com/docs/react/data/queries#manual-execution-with-uselazyquery) section for a more in-depth overview of `useLazyQuery`.
|
|
402
366
|
*
|
|
403
|
-
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
404
|
-
*
|
|
405
|
-
* @param options - Default options to control how the query is executed.
|
|
406
|
-
*
|
|
407
|
-
* @returns A tuple in the form of `[execute, result]`
|
|
408
|
-
*
|
|
409
367
|
* @example
|
|
368
|
+
*
|
|
410
369
|
* ```jsx
|
|
411
370
|
* import { gql } from "@apollo/client";
|
|
412
371
|
* import { useLazyQuery } from "@apollo/client/react";
|
|
@@ -430,6 +389,10 @@ export declare function useLazyQuery<TData = unknown, TVariables extends Operati
|
|
|
430
389
|
* return <h1>Hello {data.greeting.message}!</h1>;
|
|
431
390
|
* }
|
|
432
391
|
* ```
|
|
392
|
+
*
|
|
393
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
394
|
+
* @param options - Default options to control how the query is executed.
|
|
395
|
+
* @returns A tuple in the form of `[execute, result]`
|
|
433
396
|
*/
|
|
434
397
|
export declare function useLazyQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useLazyQuery.Options<NoInfer<TData>, NoInfer<TVariables>> & {
|
|
435
398
|
returnPartialData: boolean;
|
|
@@ -439,13 +402,8 @@ export declare function useLazyQuery<TData = unknown, TVariables extends Operati
|
|
|
439
402
|
*
|
|
440
403
|
* > Refer to the [Queries - Manual execution with useLazyQuery](https://www.apollographql.com/docs/react/data/queries#manual-execution-with-uselazyquery) section for a more in-depth overview of `useLazyQuery`.
|
|
441
404
|
*
|
|
442
|
-
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
443
|
-
*
|
|
444
|
-
* @param options - Default options to control how the query is executed.
|
|
445
|
-
*
|
|
446
|
-
* @returns A tuple in the form of `[execute, result]`
|
|
447
|
-
*
|
|
448
405
|
* @example
|
|
406
|
+
*
|
|
449
407
|
* ```jsx
|
|
450
408
|
* import { gql } from "@apollo/client";
|
|
451
409
|
* import { useLazyQuery } from "@apollo/client/react";
|
|
@@ -469,6 +427,10 @@ export declare function useLazyQuery<TData = unknown, TVariables extends Operati
|
|
|
469
427
|
* return <h1>Hello {data.greeting.message}!</h1>;
|
|
470
428
|
* }
|
|
471
429
|
* ```
|
|
430
|
+
*
|
|
431
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
432
|
+
* @param options - Default options to control how the query is executed.
|
|
433
|
+
* @returns A tuple in the form of `[execute, result]`
|
|
472
434
|
*/
|
|
473
435
|
export declare function useLazyQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: useLazyQuery.Options<NoInfer<TData>, NoInfer<TVariables>>): useLazyQuery.ResultTuple<TData, TVariables, "empty" | "complete" | "streaming">;
|
|
474
436
|
//# sourceMappingURL=useLazyQuery.d.ts.map
|