@apollo/client 4.0.0-alpha.21 → 4.0.0-alpha.23
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 +341 -2
- package/__cjs/cache/core/cache.cjs +1 -1
- package/__cjs/cache/inmemory/entityStore.cjs +3 -3
- package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
- package/__cjs/cache/inmemory/key-extractor.cjs.map +1 -1
- package/__cjs/cache/inmemory/policies.cjs +4 -4
- package/__cjs/cache/inmemory/policies.cjs.map +1 -1
- package/__cjs/cache/inmemory/readFromStore.cjs +2 -2
- package/__cjs/cache/inmemory/writeToStore.cjs +4 -4
- package/__cjs/core/ApolloClient.cjs +24 -19
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +15 -11
- package/__cjs/core/ObservableQuery.cjs +52 -48
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/ObservableQuery.d.cts +48 -14
- package/__cjs/core/QueryInfo.cjs +146 -168
- package/__cjs/core/QueryInfo.cjs.map +1 -1
- package/__cjs/core/QueryInfo.d.cts +14 -11
- package/__cjs/core/QueryManager.cjs +138 -123
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/QueryManager.d.cts +17 -6
- package/__cjs/core/index.cjs +2 -1
- package/__cjs/core/index.cjs.map +1 -1
- package/__cjs/core/index.d.cts +4 -4
- package/__cjs/core/types.d.cts +72 -18
- package/__cjs/core/watchQueryOptions.d.cts +2 -24
- package/__cjs/dev/setErrorMessageHandler.cjs.map +1 -1
- package/__cjs/errors/CombinedGraphQLErrors.cjs +6 -3
- package/__cjs/errors/CombinedGraphQLErrors.cjs.map +1 -1
- package/__cjs/errors/CombinedGraphQLErrors.d.cts +7 -2
- package/__cjs/errors/index.cjs +1 -1
- package/__cjs/errors/index.cjs.map +1 -1
- package/__cjs/errors/index.d.cts +1 -3
- package/__cjs/incremental/handlers/defer20220824.cjs +102 -0
- package/__cjs/incremental/handlers/defer20220824.cjs.map +1 -0
- package/__cjs/incremental/handlers/defer20220824.d.cts +55 -0
- package/__cjs/incremental/handlers/notImplemented.cjs +19 -0
- package/__cjs/incremental/handlers/notImplemented.cjs.map +1 -0
- package/__cjs/incremental/handlers/notImplemented.d.cts +9 -0
- package/__cjs/incremental/index.cjs +9 -0
- package/__cjs/incremental/index.cjs.map +1 -0
- package/__cjs/incremental/index.d.cts +4 -0
- package/__cjs/incremental/types.cjs +3 -0
- package/__cjs/incremental/types.cjs.map +1 -0
- package/__cjs/incremental/types.d.cts +24 -0
- package/__cjs/invariantErrorCodes.cjs +131 -114
- package/__cjs/link/batch-http/batchHttpLink.cjs +14 -14
- package/__cjs/link/batch-http/batchHttpLink.cjs.map +1 -1
- package/__cjs/link/batch-http/batchHttpLink.d.cts +4 -0
- package/__cjs/link/batch-http/index.cjs +2 -1
- package/__cjs/link/batch-http/index.cjs.map +1 -1
- package/__cjs/link/batch-http/index.d.cts +1 -1
- package/__cjs/link/client-awareness/ClientAwarenessLink.cjs +45 -0
- package/__cjs/link/client-awareness/ClientAwarenessLink.cjs.map +1 -0
- package/__cjs/link/client-awareness/ClientAwarenessLink.d.cts +62 -0
- package/__cjs/link/client-awareness/index.cjs +6 -0
- package/__cjs/link/client-awareness/index.cjs.map +1 -0
- package/__cjs/link/client-awareness/index.d.cts +2 -0
- package/__cjs/link/context/index.cjs +36 -25
- package/__cjs/link/context/index.cjs.map +1 -1
- package/__cjs/link/context/index.d.cts +8 -1
- package/__cjs/link/core/types.d.cts +5 -38
- package/__cjs/link/error/index.cjs +68 -65
- package/__cjs/link/error/index.cjs.map +1 -1
- package/__cjs/link/error/index.d.cts +15 -14
- package/__cjs/link/http/BaseHttpLink.cjs +111 -0
- package/__cjs/link/http/BaseHttpLink.cjs.map +1 -0
- package/__cjs/link/http/BaseHttpLink.d.cts +6 -0
- package/__cjs/link/http/HttpLink.cjs +12 -5
- package/__cjs/link/http/HttpLink.cjs.map +1 -1
- package/__cjs/link/http/HttpLink.d.cts +20 -4
- package/__cjs/link/http/checkFetcher.cjs +1 -1
- package/__cjs/link/http/index.cjs +4 -3
- package/__cjs/link/http/index.cjs.map +1 -1
- package/__cjs/link/http/index.d.cts +2 -2
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs +45 -57
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs.map +1 -1
- package/__cjs/link/http/selectHttpOptionsAndBody.cjs +6 -5
- package/__cjs/link/http/selectHttpOptionsAndBody.cjs.map +1 -1
- package/__cjs/link/index.cjs.map +1 -1
- package/__cjs/link/index.d.cts +1 -1
- package/__cjs/link/persisted-queries/index.cjs +159 -141
- package/__cjs/link/persisted-queries/index.cjs.map +1 -1
- package/__cjs/link/persisted-queries/index.d.cts +19 -19
- package/__cjs/link/remove-typename/index.cjs +2 -1
- package/__cjs/link/remove-typename/index.cjs.map +1 -1
- package/__cjs/link/remove-typename/index.d.cts +1 -1
- package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs +34 -23
- package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs.map +1 -1
- package/__cjs/link/remove-typename/removeTypenameFromVariables.d.cts +8 -9
- package/__cjs/link/utils/validateOperation.cjs +1 -1
- package/__cjs/local-state/LocalState.cjs +10 -18
- package/__cjs/local-state/LocalState.cjs.map +1 -1
- package/__cjs/local-state/LocalState.d.cts +3 -4
- package/__cjs/masking/maskDefinition.cjs +2 -2
- package/__cjs/masking/maskFragment.cjs +2 -2
- package/__cjs/masking/maskOperation.cjs +1 -1
- package/__cjs/masking/types.d.cts +6 -5
- package/__cjs/masking/utils.cjs +3 -3
- package/__cjs/react/context/ApolloConsumer.cjs +1 -1
- package/__cjs/react/context/ApolloContext.cjs +1 -1
- package/__cjs/react/context/ApolloProvider.cjs +1 -1
- package/__cjs/react/hooks/internal/validateSuspenseHookOptions.cjs +2 -2
- package/__cjs/react/hooks/useApolloClient.cjs +1 -1
- package/__cjs/react/hooks/useBackgroundQuery.cjs +1 -0
- package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useFragment.cjs +1 -0
- package/__cjs/react/hooks/useFragment.cjs.map +1 -1
- package/__cjs/react/hooks/useLazyQuery.cjs +4 -4
- package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLazyQuery.d.cts +2 -7
- package/__cjs/react/hooks/useLoadableQuery.cjs +2 -2
- package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useMutation.cjs.map +1 -1
- package/__cjs/react/hooks/useMutation.d.cts +2 -2
- package/__cjs/react/hooks/useQuery.cjs +23 -21
- package/__cjs/react/hooks/useQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useQuery.d.cts +3 -8
- package/__cjs/react/hooks/useQueryRefHandlers.cjs +1 -0
- package/__cjs/react/hooks/useQueryRefHandlers.cjs.map +1 -1
- package/__cjs/react/hooks/useReadQuery.cjs +1 -0
- package/__cjs/react/hooks/useReadQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useSubscription.cjs +1 -1
- package/__cjs/react/hooks/useSuspenseFragment.cjs +1 -0
- package/__cjs/react/hooks/useSuspenseFragment.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.cjs +1 -0
- package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useSyncExternalStore.cjs +1 -1
- package/__cjs/react/internal/cache/QueryReference.cjs +5 -5
- package/__cjs/react/internal/cache/QueryReference.cjs.map +1 -1
- package/__cjs/react/internal/cache/QueryReference.d.cts +2 -3
- package/__cjs/react/internal/types.d.cts +2 -7
- package/__cjs/react/ssr/prerenderStatic.cjs +2 -2
- package/__cjs/testing/core/mocking/mockLink.cjs +4 -4
- package/__cjs/utilities/caching/sizes.cjs.map +1 -1
- package/__cjs/utilities/caching/sizes.d.cts +6 -0
- package/__cjs/utilities/graphql/DocumentTransform.cjs +1 -1
- package/__cjs/utilities/graphql/isFormattedExecutionResult.cjs +9 -0
- package/__cjs/utilities/graphql/isFormattedExecutionResult.cjs.map +1 -0
- package/__cjs/utilities/graphql/isFormattedExecutionResult.d.cts +3 -0
- package/__cjs/utilities/index.cjs +3 -1
- package/__cjs/utilities/index.cjs.map +1 -1
- package/__cjs/utilities/index.d.cts +1 -0
- package/__cjs/utilities/internal/checkDocument.cjs +47 -13
- package/__cjs/utilities/internal/checkDocument.cjs.map +1 -1
- package/__cjs/utilities/internal/checkDocument.d.cts +1 -1
- package/__cjs/utilities/internal/getFragmentDefinition.cjs +3 -3
- package/__cjs/utilities/internal/getFragmentFromSelection.cjs +1 -1
- package/__cjs/utilities/internal/getFragmentQueryDocument.cjs +2 -2
- package/__cjs/utilities/internal/getGraphQLErrorsFromResult.cjs +1 -12
- package/__cjs/utilities/internal/getGraphQLErrorsFromResult.cjs.map +1 -1
- package/__cjs/utilities/internal/getGraphQLErrorsFromResult.d.cts +4 -2
- package/__cjs/utilities/internal/getMainDefinition.cjs +1 -1
- package/__cjs/utilities/internal/getMemoryInternals.cjs +1 -0
- package/__cjs/utilities/internal/getMemoryInternals.cjs.map +1 -1
- package/__cjs/utilities/internal/getMemoryInternals.d.cts +0 -1
- package/__cjs/utilities/internal/getQueryDefinition.cjs +1 -1
- package/__cjs/utilities/internal/graphQLResultHasError.cjs +1 -4
- package/__cjs/utilities/internal/graphQLResultHasError.cjs.map +1 -1
- package/__cjs/utilities/internal/graphQLResultHasError.d.cts +2 -2
- package/__cjs/utilities/internal/index.cjs +2 -10
- package/__cjs/utilities/internal/index.cjs.map +1 -1
- package/__cjs/utilities/internal/index.d.cts +0 -4
- package/__cjs/utilities/internal/removeDirectivesFromDocument.cjs +1 -1
- package/__cjs/utilities/internal/shouldInclude.cjs +4 -4
- package/__cjs/utilities/internal/valueToObjectRepresentation.cjs +1 -1
- package/__cjs/version.cjs +3 -2
- package/__cjs/version.cjs.map +1 -1
- package/__cjs/version.d.cts +1 -0
- package/cache/core/cache.js +1 -1
- package/cache/inmemory/entityStore.js +3 -3
- package/cache/inmemory/key-extractor.js +1 -1
- package/cache/inmemory/key-extractor.js.map +1 -1
- package/cache/inmemory/policies.js +4 -4
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/readFromStore.js +2 -2
- package/cache/inmemory/writeToStore.js +4 -4
- package/core/ApolloClient.d.ts +15 -11
- package/core/ApolloClient.js +25 -20
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.d.ts +48 -14
- package/core/ObservableQuery.js +53 -49
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +14 -11
- package/core/QueryInfo.js +147 -169
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +17 -6
- package/core/QueryManager.js +140 -125
- package/core/QueryManager.js.map +1 -1
- package/core/index.d.ts +4 -4
- package/core/index.js +1 -1
- package/core/index.js.map +1 -1
- package/core/types.d.ts +72 -18
- package/core/watchQueryOptions.d.ts +2 -24
- package/dev/setErrorMessageHandler.js.map +1 -1
- package/errors/CombinedGraphQLErrors.d.ts +7 -2
- package/errors/CombinedGraphQLErrors.js +6 -3
- package/errors/CombinedGraphQLErrors.js.map +1 -1
- package/errors/index.d.ts +1 -3
- package/errors/index.js +1 -1
- package/errors/index.js.map +1 -1
- package/incremental/handlers/defer20220824.d.ts +55 -0
- package/incremental/handlers/defer20220824.js +97 -0
- package/incremental/handlers/defer20220824.js.map +1 -0
- package/incremental/handlers/notImplemented.d.ts +9 -0
- package/incremental/handlers/notImplemented.js +15 -0
- package/incremental/handlers/notImplemented.js.map +1 -0
- package/incremental/index.d.ts +4 -0
- package/incremental/index.js +3 -0
- package/incremental/index.js.map +1 -0
- package/incremental/types.d.ts +24 -0
- package/incremental/types.js +2 -0
- package/incremental/types.js.map +1 -0
- package/invariantErrorCodes.js +132 -118
- package/legacyEntryPoints/incremental/incremental.cjs +1 -0
- package/legacyEntryPoints/incremental/incremental.d.cts +1 -0
- package/legacyEntryPoints/incremental/index.d.ts +1 -0
- package/legacyEntryPoints/incremental/index.js +1 -0
- package/legacyEntryPoints/link/client-awareness/client-awareness.cjs +1 -0
- package/legacyEntryPoints/link/client-awareness/client-awareness.d.cts +1 -0
- package/legacyEntryPoints/link/client-awareness/index.d.ts +1 -0
- package/legacyEntryPoints/link/client-awareness/index.js +1 -0
- package/link/batch-http/batchHttpLink.d.ts +4 -0
- package/link/batch-http/batchHttpLink.js +11 -12
- package/link/batch-http/batchHttpLink.js.map +1 -1
- package/link/batch-http/index.d.ts +1 -1
- package/link/batch-http/index.js +1 -1
- package/link/batch-http/index.js.map +1 -1
- package/link/client-awareness/ClientAwarenessLink.d.ts +62 -0
- package/link/client-awareness/ClientAwarenessLink.js +41 -0
- package/link/client-awareness/ClientAwarenessLink.js.map +1 -0
- package/link/client-awareness/index.d.ts +2 -0
- package/link/client-awareness/index.js +2 -0
- package/link/client-awareness/index.js.map +1 -0
- package/link/context/index.d.ts +8 -1
- package/link/context/index.js +34 -25
- package/link/context/index.js.map +1 -1
- package/link/core/types.d.ts +5 -38
- package/link/error/index.d.ts +15 -14
- package/link/error/index.js +68 -65
- package/link/error/index.js.map +1 -1
- package/link/http/BaseHttpLink.d.ts +6 -0
- package/link/http/BaseHttpLink.js +107 -0
- package/link/http/BaseHttpLink.js.map +1 -0
- package/link/http/HttpLink.d.ts +20 -4
- package/link/http/HttpLink.js +10 -4
- package/link/http/HttpLink.js.map +1 -1
- package/link/http/checkFetcher.js +1 -1
- package/link/http/index.d.ts +2 -2
- package/link/http/index.js +2 -2
- package/link/http/index.js.map +1 -1
- package/link/http/parseAndCheckHttpResponse.js +45 -57
- package/link/http/parseAndCheckHttpResponse.js.map +1 -1
- package/link/http/selectHttpOptionsAndBody.js +6 -5
- package/link/http/selectHttpOptionsAndBody.js.map +1 -1
- package/link/index.d.ts +1 -1
- package/link/index.js.map +1 -1
- package/link/persisted-queries/index.d.ts +19 -19
- package/link/persisted-queries/index.js +157 -140
- package/link/persisted-queries/index.js.map +1 -1
- package/link/remove-typename/index.d.ts +1 -1
- package/link/remove-typename/index.js +1 -1
- package/link/remove-typename/index.js.map +1 -1
- package/link/remove-typename/removeTypenameFromVariables.d.ts +8 -9
- package/link/remove-typename/removeTypenameFromVariables.js +32 -22
- package/link/remove-typename/removeTypenameFromVariables.js.map +1 -1
- package/link/utils/validateOperation.js +1 -1
- package/local-state/LocalState.d.ts +3 -4
- package/local-state/LocalState.js +10 -18
- package/local-state/LocalState.js.map +1 -1
- package/masking/maskDefinition.js +2 -2
- package/masking/maskFragment.js +2 -2
- package/masking/maskOperation.js +1 -1
- package/masking/types.d.ts +6 -5
- package/masking/utils.js +3 -3
- package/package.json +15 -2
- package/react/context/ApolloConsumer.js +1 -1
- package/react/context/ApolloContext.js +1 -1
- package/react/context/ApolloProvider.js +1 -1
- package/react/hooks/internal/validateSuspenseHookOptions.js +2 -2
- package/react/hooks/useApolloClient.js +15 -2
- package/react/hooks/useApolloClient.js.map +1 -1
- package/react/hooks/useBackgroundQuery.js +7 -6
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useFragment.js +12 -11
- package/react/hooks/useFragment.js.map +1 -1
- package/react/hooks/useLazyQuery.d.ts +2 -7
- package/react/hooks/useLazyQuery.js +17 -17
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useLoadableQuery.js +229 -69
- package/react/hooks/useLoadableQuery.js.map +1 -1
- package/react/hooks/useMutation.d.ts +2 -2
- package/react/hooks/useMutation.js +191 -81
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +3 -8
- package/react/hooks/useQuery.js +243 -70
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useQueryRefHandlers.js +64 -23
- package/react/hooks/useQueryRefHandlers.js.map +1 -1
- package/react/hooks/useReadQuery.js +3 -2
- package/react/hooks/useReadQuery.js.map +1 -1
- package/react/hooks/useSubscription.js +5 -5
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/useSuspenseFragment.js +1 -0
- package/react/hooks/useSuspenseFragment.js.map +1 -1
- package/react/hooks/useSuspenseQuery.js +59 -33
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks/useSyncExternalStore.js +1 -1
- package/react/internal/cache/QueryReference.d.ts +2 -3
- package/react/internal/cache/QueryReference.js +5 -5
- package/react/internal/cache/QueryReference.js.map +1 -1
- package/react/internal/types.d.ts +2 -7
- package/react/ssr/prerenderStatic.js +2 -2
- package/testing/core/mocking/mockLink.js +4 -4
- package/utilities/caching/sizes.d.ts +6 -0
- package/utilities/caching/sizes.js.map +1 -1
- package/utilities/graphql/DocumentTransform.js +1 -1
- package/utilities/graphql/isFormattedExecutionResult.d.ts +3 -0
- package/utilities/graphql/isFormattedExecutionResult.js +6 -0
- package/utilities/graphql/isFormattedExecutionResult.js.map +1 -0
- package/utilities/index.d.ts +1 -0
- package/utilities/index.js +1 -0
- package/utilities/index.js.map +1 -1
- package/utilities/internal/checkDocument.d.ts +1 -1
- package/utilities/internal/checkDocument.js +46 -12
- package/utilities/internal/checkDocument.js.map +1 -1
- package/utilities/internal/getFragmentDefinition.js +3 -3
- package/utilities/internal/getFragmentFromSelection.js +1 -1
- package/utilities/internal/getFragmentQueryDocument.js +2 -2
- package/utilities/internal/getGraphQLErrorsFromResult.d.ts +4 -2
- package/utilities/internal/getGraphQLErrorsFromResult.js +1 -12
- package/utilities/internal/getGraphQLErrorsFromResult.js.map +1 -1
- package/utilities/internal/getMainDefinition.js +1 -1
- package/utilities/internal/getMemoryInternals.d.ts +0 -1
- package/utilities/internal/getMemoryInternals.js +1 -0
- package/utilities/internal/getMemoryInternals.js.map +1 -1
- package/utilities/internal/getQueryDefinition.js +1 -1
- package/utilities/internal/graphQLResultHasError.d.ts +2 -2
- package/utilities/internal/graphQLResultHasError.js +1 -4
- package/utilities/internal/graphQLResultHasError.js.map +1 -1
- package/utilities/internal/index.d.ts +0 -4
- package/utilities/internal/index.js +0 -4
- package/utilities/internal/index.js.map +1 -1
- package/utilities/internal/removeDirectivesFromDocument.js +1 -1
- package/utilities/internal/shouldInclude.js +4 -4
- package/utilities/internal/valueToObjectRepresentation.js +1 -1
- package/version.d.ts +1 -0
- package/version.js +2 -1
- package/version.js.map +1 -1
- package/__cjs/link/http/createHttpLink.cjs +0 -151
- package/__cjs/link/http/createHttpLink.cjs.map +0 -1
- package/__cjs/link/http/createHttpLink.d.cts +0 -4
- package/__cjs/utilities/internal/isExecutionPatchIncrementalResult.cjs +0 -12
- package/__cjs/utilities/internal/isExecutionPatchIncrementalResult.cjs.map +0 -1
- package/__cjs/utilities/internal/isExecutionPatchIncrementalResult.d.cts +0 -8
- package/__cjs/utilities/internal/isExecutionPatchIninitialResult.cjs +0 -12
- package/__cjs/utilities/internal/isExecutionPatchIninitialResult.cjs.map +0 -1
- package/__cjs/utilities/internal/isExecutionPatchIninitialResult.d.cts +0 -8
- package/__cjs/utilities/internal/isExecutionPatchResult.cjs +0 -15
- package/__cjs/utilities/internal/isExecutionPatchResult.cjs.map +0 -1
- package/__cjs/utilities/internal/isExecutionPatchResult.d.cts +0 -8
- package/__cjs/utilities/internal/mergeIncrementalData.cjs +0 -30
- package/__cjs/utilities/internal/mergeIncrementalData.cjs.map +0 -1
- package/__cjs/utilities/internal/mergeIncrementalData.d.cts +0 -8
- package/link/http/createHttpLink.d.ts +0 -4
- package/link/http/createHttpLink.js +0 -143
- package/link/http/createHttpLink.js.map +0 -1
- package/utilities/internal/isExecutionPatchIncrementalResult.d.ts +0 -8
- package/utilities/internal/isExecutionPatchIncrementalResult.js +0 -9
- package/utilities/internal/isExecutionPatchIncrementalResult.js.map +0 -1
- package/utilities/internal/isExecutionPatchIninitialResult.d.ts +0 -8
- package/utilities/internal/isExecutionPatchIninitialResult.js +0 -9
- package/utilities/internal/isExecutionPatchIninitialResult.js.map +0 -1
- package/utilities/internal/isExecutionPatchResult.d.ts +0 -8
- package/utilities/internal/isExecutionPatchResult.js +0 -12
- package/utilities/internal/isExecutionPatchResult.js.map +0 -1
- package/utilities/internal/mergeIncrementalData.d.ts +0 -8
- package/utilities/internal/mergeIncrementalData.js +0 -27
- package/utilities/internal/mergeIncrementalData.js.map +0 -1
package/core/QueryManager.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Trie } from "@wry/trie";
|
|
2
2
|
import { BREAK, Kind, OperationTypeNode, visit } from "graphql";
|
|
3
|
-
import { Observable } from "rxjs";
|
|
3
|
+
import { Observable, throwError } from "rxjs";
|
|
4
4
|
import { catchError, concat, EMPTY, filter, finalize, from, lastValueFrom, map, materialize, mergeMap, of, share, shareReplay, Subject, tap, } from "rxjs";
|
|
5
5
|
import { canonicalStringify } from "@apollo/client/cache";
|
|
6
6
|
import { CombinedGraphQLErrors, graphQLResultHasProtocolErrors, registerLinkError, toErrorLike, } from "@apollo/client/errors";
|
|
@@ -9,7 +9,7 @@ import { execute } from "@apollo/client/link";
|
|
|
9
9
|
import { maskFragment, maskOperation } from "@apollo/client/masking";
|
|
10
10
|
import { cacheSizes, DocumentTransform, print } from "@apollo/client/utilities";
|
|
11
11
|
import { __DEV__ } from "@apollo/client/utilities/environment";
|
|
12
|
-
import { AutoCleanedWeakCache, checkDocument, filterMap, getDefaultValues,
|
|
12
|
+
import { AutoCleanedWeakCache, checkDocument, filterMap, getDefaultValues, getOperationDefinition, getOperationName, graphQLResultHasError, hasDirectives, hasForcedResolvers, isDocumentNode, isNonNullObject, makeUniqueId, removeDirectivesFromDocument, toQueryResult, } from "@apollo/client/utilities/internal";
|
|
13
13
|
import { invariant, newInvariantError, } from "@apollo/client/utilities/invariant";
|
|
14
14
|
import { isNetworkRequestInFlight, NetworkStatus } from "./networkStatus.js";
|
|
15
15
|
import { logMissingFieldErrors, ObservableQuery } from "./ObservableQuery.js";
|
|
@@ -17,14 +17,18 @@ import { QueryInfo } from "./QueryInfo.js";
|
|
|
17
17
|
export class QueryManager {
|
|
18
18
|
defaultOptions;
|
|
19
19
|
client;
|
|
20
|
+
/**
|
|
21
|
+
* The options that were passed to the ApolloClient constructor.
|
|
22
|
+
*/
|
|
23
|
+
clientOptions;
|
|
20
24
|
assumeImmutableResults;
|
|
21
25
|
documentTransform;
|
|
22
26
|
ssrMode;
|
|
23
27
|
defaultContext;
|
|
24
28
|
dataMasking;
|
|
29
|
+
incrementalHandler;
|
|
25
30
|
localState;
|
|
26
31
|
queryDeduplication;
|
|
27
|
-
clientAwareness = {};
|
|
28
32
|
/**
|
|
29
33
|
* Whether to prioritize cache values over network results when
|
|
30
34
|
* `fetchObservableWithInfo` is called.
|
|
@@ -54,11 +58,12 @@ export class QueryManager {
|
|
|
54
58
|
this.client = options.client;
|
|
55
59
|
this.defaultOptions = options.defaultOptions;
|
|
56
60
|
this.queryDeduplication = options.queryDeduplication;
|
|
57
|
-
this.
|
|
61
|
+
this.clientOptions = options.clientOptions;
|
|
58
62
|
this.ssrMode = options.ssrMode;
|
|
59
63
|
this.assumeImmutableResults = options.assumeImmutableResults;
|
|
60
64
|
this.dataMasking = options.dataMasking;
|
|
61
65
|
this.localState = options.localState;
|
|
66
|
+
this.incrementalHandler = options.incrementalHandler;
|
|
62
67
|
const documentTransform = options.documentTransform;
|
|
63
68
|
this.documentTransform =
|
|
64
69
|
documentTransform ?
|
|
@@ -87,23 +92,20 @@ export class QueryManager {
|
|
|
87
92
|
*/
|
|
88
93
|
stop() {
|
|
89
94
|
this.obsQueries.forEach((oq) => oq.stop());
|
|
90
|
-
this.cancelPendingFetches(newInvariantError(
|
|
95
|
+
this.cancelPendingFetches(newInvariantError(85));
|
|
91
96
|
}
|
|
92
97
|
cancelPendingFetches(error) {
|
|
93
98
|
this.fetchCancelFns.forEach((cancel) => cancel(error));
|
|
94
99
|
this.fetchCancelFns.clear();
|
|
95
100
|
}
|
|
96
|
-
async mutate({ mutation, variables, optimisticResponse, updateQueries, refetchQueries = [], awaitRefetchQueries = false, update: updateWithProxyFn, onQueryUpdated, fetchPolicy
|
|
97
|
-
invariant(mutation, 82);
|
|
98
|
-
checkDocument(mutation, OperationTypeNode.MUTATION);
|
|
99
|
-
invariant(fetchPolicy === "network-only" || fetchPolicy === "no-cache", 83);
|
|
101
|
+
async mutate({ mutation, variables, optimisticResponse, updateQueries, refetchQueries = [], awaitRefetchQueries = false, update: updateWithProxyFn, onQueryUpdated, fetchPolicy, errorPolicy, keepRootFields, context, }) {
|
|
100
102
|
const queryInfo = new QueryInfo(this);
|
|
101
103
|
mutation = this.cache.transformForLink(this.transform(mutation));
|
|
102
104
|
const { hasClientExports } = this.getDocumentInfo(mutation);
|
|
103
105
|
variables = this.getVariables(mutation, variables);
|
|
104
106
|
if (hasClientExports) {
|
|
105
107
|
if (__DEV__) {
|
|
106
|
-
invariant(this.localState,
|
|
108
|
+
invariant(this.localState, 86, getOperationName(mutation, "(anonymous)"));
|
|
107
109
|
}
|
|
108
110
|
variables = await this.localState.getExportedVariables({
|
|
109
111
|
client: this.client,
|
|
@@ -140,21 +142,7 @@ export class QueryManager {
|
|
|
140
142
|
optimisticResponse: isOptimistic ? optimisticResponse : void 0,
|
|
141
143
|
}, variables, {}, false)
|
|
142
144
|
.observable.pipe(validateDidEmitValue(), mergeMap((result) => {
|
|
143
|
-
const hasErrors = graphQLResultHasError(result);
|
|
144
|
-
if (hasErrors && errorPolicy === "none") {
|
|
145
|
-
throw new CombinedGraphQLErrors(result);
|
|
146
|
-
}
|
|
147
|
-
if (mutationStoreValue) {
|
|
148
|
-
mutationStoreValue.loading = false;
|
|
149
|
-
mutationStoreValue.error = null;
|
|
150
|
-
}
|
|
151
145
|
const storeResult = { ...result };
|
|
152
|
-
if (typeof refetchQueries === "function") {
|
|
153
|
-
refetchQueries = refetchQueries(storeResult);
|
|
154
|
-
}
|
|
155
|
-
if (errorPolicy === "ignore" && hasErrors) {
|
|
156
|
-
delete storeResult.errors;
|
|
157
|
-
}
|
|
158
146
|
return from(queryInfo.markMutationResult(storeResult, {
|
|
159
147
|
document: mutation,
|
|
160
148
|
variables,
|
|
@@ -171,6 +159,17 @@ export class QueryManager {
|
|
|
171
159
|
onQueryUpdated,
|
|
172
160
|
keepRootFields,
|
|
173
161
|
}));
|
|
162
|
+
}))
|
|
163
|
+
.pipe(map((storeResult) => {
|
|
164
|
+
const hasErrors = graphQLResultHasError(storeResult);
|
|
165
|
+
if (hasErrors && errorPolicy === "none") {
|
|
166
|
+
throw new CombinedGraphQLErrors(storeResult);
|
|
167
|
+
}
|
|
168
|
+
if (mutationStoreValue) {
|
|
169
|
+
mutationStoreValue.loading = false;
|
|
170
|
+
mutationStoreValue.error = null;
|
|
171
|
+
}
|
|
172
|
+
return storeResult;
|
|
174
173
|
}))
|
|
175
174
|
.subscribe({
|
|
176
175
|
next: (storeResult) => {
|
|
@@ -180,7 +179,7 @@ export class QueryManager {
|
|
|
180
179
|
// we resolve with a SingleExecutionResult or after the final
|
|
181
180
|
// ExecutionPatchResult has arrived and we have assembled the
|
|
182
181
|
// multipart response into a single result.
|
|
183
|
-
if (!
|
|
182
|
+
if (!queryInfo.hasNext) {
|
|
184
183
|
const result = {
|
|
185
184
|
data: this.maskOperation({
|
|
186
185
|
document: mutation,
|
|
@@ -192,7 +191,7 @@ export class QueryManager {
|
|
|
192
191
|
if (graphQLResultHasError(storeResult)) {
|
|
193
192
|
result.error = new CombinedGraphQLErrors(storeResult);
|
|
194
193
|
}
|
|
195
|
-
if (storeResult.extensions) {
|
|
194
|
+
if (Object.keys(storeResult.extensions || {}).length) {
|
|
196
195
|
result.extensions = storeResult.extensions;
|
|
197
196
|
}
|
|
198
197
|
resolve(result);
|
|
@@ -219,7 +218,10 @@ export class QueryManager {
|
|
|
219
218
|
});
|
|
220
219
|
}
|
|
221
220
|
fetchQuery(options, networkStatus) {
|
|
222
|
-
|
|
221
|
+
checkDocument(options.query, OperationTypeNode.QUERY);
|
|
222
|
+
// do the rest asynchronously to keep the same rejection timing as
|
|
223
|
+
// checks further in `.mutate`
|
|
224
|
+
return (async () => lastValueFrom(this.fetchObservableWithInfo(options, {
|
|
223
225
|
networkStatus,
|
|
224
226
|
}).observable.pipe(filterMap((value) => {
|
|
225
227
|
switch (value.kind) {
|
|
@@ -234,7 +236,7 @@ export class QueryManager {
|
|
|
234
236
|
// This default is needed when a `standby` fetch policy is used to avoid
|
|
235
237
|
// an EmptyError from rejecting this promise.
|
|
236
238
|
defaultValue: { data: undefined },
|
|
237
|
-
});
|
|
239
|
+
}))();
|
|
238
240
|
}
|
|
239
241
|
transform(document) {
|
|
240
242
|
return this.documentTransform.transformDocument(document);
|
|
@@ -254,6 +256,7 @@ export class QueryManager {
|
|
|
254
256
|
hasClientExports: hasDirectives(["client", "export"], document, true),
|
|
255
257
|
hasForcedResolvers: hasForcedResolvers(document),
|
|
256
258
|
hasNonreactiveDirective: hasDirectives(["nonreactive"], document),
|
|
259
|
+
hasIncrementalDirective: hasDirectives(["defer"], document),
|
|
257
260
|
nonReactiveQuery: addNonReactiveToNamedFragments(document),
|
|
258
261
|
clientQuery: hasDirectives(["client"], document) ? document : null,
|
|
259
262
|
serverQuery: removeDirectivesFromDocument([
|
|
@@ -279,7 +282,11 @@ export class QueryManager {
|
|
|
279
282
|
};
|
|
280
283
|
transformCache.set(document, cacheEntry);
|
|
281
284
|
}
|
|
282
|
-
|
|
285
|
+
const entry = transformCache.get(document);
|
|
286
|
+
if (entry.violation) {
|
|
287
|
+
throw entry.violation;
|
|
288
|
+
}
|
|
289
|
+
return entry;
|
|
283
290
|
}
|
|
284
291
|
getVariables(document, variables) {
|
|
285
292
|
const defaultVars = this.getDocumentInfo(document).defaultVars;
|
|
@@ -309,7 +316,7 @@ export class QueryManager {
|
|
|
309
316
|
});
|
|
310
317
|
return observable;
|
|
311
318
|
}
|
|
312
|
-
|
|
319
|
+
query(options) {
|
|
313
320
|
const query = this.transform(options.query);
|
|
314
321
|
return this.fetchQuery({
|
|
315
322
|
...options,
|
|
@@ -335,7 +342,7 @@ export class QueryManager {
|
|
|
335
342
|
// depend on values that previously existed in the data portion of the
|
|
336
343
|
// store. So, we cancel the promises and observers that we have issued
|
|
337
344
|
// so far and not yet resolved (in the case of queries).
|
|
338
|
-
this.cancelPendingFetches(newInvariantError(
|
|
345
|
+
this.cancelPendingFetches(newInvariantError(87));
|
|
339
346
|
this.obsQueries.forEach((observableQuery) => {
|
|
340
347
|
// Set loading to true so listeners don't trigger unless they want
|
|
341
348
|
// results with partial data.
|
|
@@ -405,10 +412,10 @@ export class QueryManager {
|
|
|
405
412
|
if (!included) {
|
|
406
413
|
const queryName = queryNames.get(nameOrQueryString);
|
|
407
414
|
if (queryName) {
|
|
408
|
-
__DEV__ && invariant.warn(
|
|
415
|
+
__DEV__ && invariant.warn(88, queryName);
|
|
409
416
|
}
|
|
410
417
|
else {
|
|
411
|
-
__DEV__ && invariant.warn(
|
|
418
|
+
__DEV__ && invariant.warn(89);
|
|
412
419
|
}
|
|
413
420
|
}
|
|
414
421
|
});
|
|
@@ -419,8 +426,8 @@ export class QueryManager {
|
|
|
419
426
|
const observableQueryPromises = [];
|
|
420
427
|
this.getObservableQueries(includeStandby ? "all" : "active").forEach((observableQuery) => {
|
|
421
428
|
const { fetchPolicy } = observableQuery.options;
|
|
422
|
-
if (includeStandby ||
|
|
423
|
-
|
|
429
|
+
if ((includeStandby || fetchPolicy !== "standby") &&
|
|
430
|
+
fetchPolicy !== "cache-only") {
|
|
424
431
|
observableQueryPromises.push(observableQuery.refetch());
|
|
425
432
|
}
|
|
426
433
|
});
|
|
@@ -437,7 +444,7 @@ export class QueryManager {
|
|
|
437
444
|
if (__DEV__) {
|
|
438
445
|
invariant(
|
|
439
446
|
!this.getDocumentInfo(query).hasClientExports || this.localState,
|
|
440
|
-
|
|
447
|
+
90,
|
|
441
448
|
getOperationName(query, "(anonymous)")
|
|
442
449
|
);
|
|
443
450
|
}
|
|
@@ -505,82 +512,92 @@ export class QueryManager {
|
|
|
505
512
|
deduplication = context?.queryDeduplication ??
|
|
506
513
|
this.queryDeduplication) {
|
|
507
514
|
let entry = {};
|
|
508
|
-
const { serverQuery, clientQuery, operationType } = this.getDocumentInfo(query);
|
|
515
|
+
const { serverQuery, clientQuery, operationType, hasIncrementalDirective } = this.getDocumentInfo(query);
|
|
509
516
|
const operationName = getOperationName(query);
|
|
510
517
|
const executeContext = {
|
|
511
518
|
client: this.client,
|
|
512
519
|
};
|
|
513
520
|
if (serverQuery) {
|
|
514
521
|
const { inFlightLinkObservables, link } = this;
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
};
|
|
527
|
-
context = operation.context;
|
|
528
|
-
function withRestart(source) {
|
|
529
|
-
return new Observable((observer) => {
|
|
530
|
-
function subscribe() {
|
|
531
|
-
return source.subscribe({
|
|
532
|
-
next: observer.next.bind(observer),
|
|
533
|
-
complete: observer.complete.bind(observer),
|
|
534
|
-
error: observer.error.bind(observer),
|
|
535
|
-
});
|
|
536
|
-
}
|
|
537
|
-
let subscription = subscribe();
|
|
538
|
-
entry.restart ||= () => {
|
|
539
|
-
subscription.unsubscribe();
|
|
540
|
-
subscription = subscribe();
|
|
541
|
-
};
|
|
542
|
-
return () => {
|
|
543
|
-
subscription.unsubscribe();
|
|
544
|
-
entry.restart = undefined;
|
|
545
|
-
};
|
|
522
|
+
try {
|
|
523
|
+
const operation = this.incrementalHandler.prepareRequest({
|
|
524
|
+
query: serverQuery,
|
|
525
|
+
variables,
|
|
526
|
+
operationName,
|
|
527
|
+
context: {
|
|
528
|
+
...this.defaultContext,
|
|
529
|
+
...context,
|
|
530
|
+
queryDeduplication: deduplication,
|
|
531
|
+
},
|
|
532
|
+
extensions,
|
|
546
533
|
});
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
inFlightLinkObservables.remove(printedServerQuery, varJson);
|
|
534
|
+
context = operation.context;
|
|
535
|
+
function withRestart(source) {
|
|
536
|
+
return new Observable((observer) => {
|
|
537
|
+
function subscribe() {
|
|
538
|
+
return source.subscribe({
|
|
539
|
+
next: observer.next.bind(observer),
|
|
540
|
+
complete: observer.complete.bind(observer),
|
|
541
|
+
error: observer.error.bind(observer),
|
|
542
|
+
});
|
|
557
543
|
}
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
544
|
+
let subscription = subscribe();
|
|
545
|
+
entry.restart ||= () => {
|
|
546
|
+
subscription.unsubscribe();
|
|
547
|
+
subscription = subscribe();
|
|
548
|
+
};
|
|
549
|
+
return () => {
|
|
550
|
+
subscription.unsubscribe();
|
|
551
|
+
entry.restart = undefined;
|
|
552
|
+
};
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
if (deduplication) {
|
|
556
|
+
const printedServerQuery = print(serverQuery);
|
|
557
|
+
const varJson = canonicalStringify(variables);
|
|
558
|
+
entry = inFlightLinkObservables.lookup(printedServerQuery, varJson);
|
|
559
|
+
if (!entry.observable) {
|
|
560
|
+
entry.observable = execute(link, operation, executeContext).pipe(withRestart, finalize(() => {
|
|
561
|
+
if (inFlightLinkObservables.peek(printedServerQuery, varJson) ===
|
|
562
|
+
entry) {
|
|
563
|
+
inFlightLinkObservables.remove(printedServerQuery, varJson);
|
|
564
|
+
}
|
|
565
|
+
}),
|
|
566
|
+
// We don't want to replay the last emitted value for
|
|
567
|
+
// subscriptions and instead opt to wait to receive updates until
|
|
568
|
+
// the subscription emits new values.
|
|
569
|
+
operationType === OperationTypeNode.SUBSCRIPTION ?
|
|
570
|
+
share()
|
|
571
|
+
: shareReplay({ refCount: true }));
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
else {
|
|
575
|
+
entry.observable = execute(link, operation, executeContext).pipe(withRestart);
|
|
565
576
|
}
|
|
566
577
|
}
|
|
567
|
-
|
|
568
|
-
entry.observable =
|
|
578
|
+
catch (error) {
|
|
579
|
+
entry.observable = throwError(() => error);
|
|
569
580
|
}
|
|
570
581
|
}
|
|
571
582
|
else {
|
|
572
583
|
entry.observable = of({ data: {} });
|
|
573
584
|
}
|
|
574
585
|
if (clientQuery) {
|
|
586
|
+
const { operation } = getOperationDefinition(query);
|
|
575
587
|
if (__DEV__) {
|
|
576
|
-
const { operation } = getOperationDefinition(query);
|
|
577
588
|
invariant(
|
|
578
589
|
this.localState,
|
|
579
|
-
|
|
590
|
+
91,
|
|
580
591
|
operation[0].toUpperCase() + operation.slice(1),
|
|
581
592
|
operationName ?? "(anonymous)"
|
|
582
593
|
);
|
|
583
594
|
}
|
|
595
|
+
invariant(
|
|
596
|
+
!hasIncrementalDirective,
|
|
597
|
+
92,
|
|
598
|
+
operation[0].toUpperCase() + operation.slice(1),
|
|
599
|
+
operationName ?? "(anonymous)"
|
|
600
|
+
);
|
|
584
601
|
entry.observable = entry.observable.pipe(mergeMap((result) => {
|
|
585
602
|
return from(this.localState.execute({
|
|
586
603
|
client: this.client,
|
|
@@ -607,30 +624,24 @@ export class QueryManager {
|
|
|
607
624
|
// missing fragment definitions (for example) before sending this document
|
|
608
625
|
// through the link chain.
|
|
609
626
|
const linkDocument = this.cache.transformForLink(options.query);
|
|
610
|
-
return this.getObservableFromLink(linkDocument, options.context, options.variables).observable.pipe(map((
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
//
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
// ones used to obtain it from the link.
|
|
625
|
-
queryInfo.markQueryResult(result, {
|
|
626
|
-
...options,
|
|
627
|
-
document: linkDocument,
|
|
628
|
-
cacheWriteBehavior,
|
|
629
|
-
});
|
|
627
|
+
return this.getObservableFromLink(linkDocument, options.context, options.variables).observable.pipe(map((incoming) => {
|
|
628
|
+
// Use linkDocument rather than queryInfo.document so the
|
|
629
|
+
// operation/fragments used to write the result are the same as the
|
|
630
|
+
// ones used to obtain it from the link.
|
|
631
|
+
const result = queryInfo.markQueryResult(incoming, {
|
|
632
|
+
...options,
|
|
633
|
+
document: linkDocument,
|
|
634
|
+
cacheWriteBehavior,
|
|
635
|
+
});
|
|
636
|
+
const hasErrors = graphQLResultHasError(result);
|
|
637
|
+
if (hasErrors && errorPolicy === "none") {
|
|
638
|
+
queryInfo.resetLastWrite();
|
|
639
|
+
observableQuery?.["resetNotifications"]();
|
|
640
|
+
throw new CombinedGraphQLErrors(result);
|
|
630
641
|
}
|
|
631
642
|
const aqr = {
|
|
632
643
|
data: result.data,
|
|
633
|
-
...(
|
|
644
|
+
...(queryInfo.hasNext ?
|
|
634
645
|
{
|
|
635
646
|
loading: true,
|
|
636
647
|
networkStatus: NetworkStatus.streaming,
|
|
@@ -648,15 +659,16 @@ export class QueryManager {
|
|
|
648
659
|
// want to ensure we properly set `data` if we're reporting on an old
|
|
649
660
|
// result which will not be caught by the conditional above that ends up
|
|
650
661
|
// throwing the markError result.
|
|
651
|
-
if (hasErrors
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
662
|
+
if (hasErrors) {
|
|
663
|
+
if (errorPolicy === "none") {
|
|
664
|
+
aqr.data = void 0;
|
|
665
|
+
aqr.dataState = "empty";
|
|
666
|
+
}
|
|
667
|
+
if (errorPolicy !== "ignore") {
|
|
668
|
+
aqr.error = new CombinedGraphQLErrors(result);
|
|
669
|
+
if (aqr.dataState !== "streaming") {
|
|
670
|
+
aqr.networkStatus = NetworkStatus.error;
|
|
671
|
+
}
|
|
660
672
|
}
|
|
661
673
|
}
|
|
662
674
|
return aqr;
|
|
@@ -749,7 +761,7 @@ export class QueryManager {
|
|
|
749
761
|
// we deprecated and removed LocalState.
|
|
750
762
|
if (this.getDocumentInfo(normalized.query).hasClientExports) {
|
|
751
763
|
if (__DEV__) {
|
|
752
|
-
invariant(this.localState,
|
|
764
|
+
invariant(this.localState, 93, getOperationName(normalized.query, "(anonymous)"));
|
|
753
765
|
}
|
|
754
766
|
observable = from(this.localState.getExportedVariables({
|
|
755
767
|
client: this.client,
|
|
@@ -784,6 +796,9 @@ export class QueryManager {
|
|
|
784
796
|
const includedQueriesByOq = new Map();
|
|
785
797
|
if (include) {
|
|
786
798
|
this.getObservableQueries(include).forEach((oq) => {
|
|
799
|
+
if (oq.options.fetchPolicy === "cache-only") {
|
|
800
|
+
return;
|
|
801
|
+
}
|
|
787
802
|
const current = oq.getCurrentResult();
|
|
788
803
|
includedQueriesByOq.set(oq, {
|
|
789
804
|
oq,
|
|
@@ -863,7 +878,8 @@ export class QueryManager {
|
|
|
863
878
|
// onQueryUpdated returns false.
|
|
864
879
|
return result;
|
|
865
880
|
}
|
|
866
|
-
if (onQueryUpdated !== null
|
|
881
|
+
if (onQueryUpdated !== null &&
|
|
882
|
+
oq.options.fetchPolicy !== "cache-only") {
|
|
867
883
|
// If we don't have an onQueryUpdated function, and onQueryUpdated
|
|
868
884
|
// was not disabled by passing null, make sure this query is
|
|
869
885
|
// "included" like any other options.include-specified query.
|
|
@@ -918,7 +934,7 @@ export class QueryManager {
|
|
|
918
934
|
!isFullyUnmaskedOperation(document) &&
|
|
919
935
|
!this.noCacheWarningsByCause.has(cause)) {
|
|
920
936
|
this.noCacheWarningsByCause.add(cause);
|
|
921
|
-
__DEV__ && invariant.warn(
|
|
937
|
+
__DEV__ && invariant.warn(94, getOperationName(document, `Unnamed ${operationType ?? "operation"}`));
|
|
922
938
|
}
|
|
923
939
|
}
|
|
924
940
|
return (this.dataMasking ?
|
|
@@ -976,7 +992,7 @@ export class QueryManager {
|
|
|
976
992
|
(diff.complete || returnPartialData) &&
|
|
977
993
|
this.getDocumentInfo(query).hasForcedResolvers) {
|
|
978
994
|
if (__DEV__) {
|
|
979
|
-
invariant(this.localState,
|
|
995
|
+
invariant(this.localState, 95, getOperationName(query, "(anonymous)"));
|
|
980
996
|
}
|
|
981
997
|
onCacheHit();
|
|
982
998
|
return from(this.localState.execute({
|
|
@@ -1067,7 +1083,7 @@ function validateDidEmitValue() {
|
|
|
1067
1083
|
didEmitValue = true;
|
|
1068
1084
|
},
|
|
1069
1085
|
complete() {
|
|
1070
|
-
invariant(didEmitValue,
|
|
1086
|
+
invariant(didEmitValue, 96);
|
|
1071
1087
|
},
|
|
1072
1088
|
});
|
|
1073
1089
|
}
|
|
@@ -1086,7 +1102,6 @@ function isFullyUnmaskedOperation(document) {
|
|
|
1086
1102
|
return isUnmasked;
|
|
1087
1103
|
}
|
|
1088
1104
|
function addNonReactiveToNamedFragments(document) {
|
|
1089
|
-
checkDocument(document);
|
|
1090
1105
|
return visit(document, {
|
|
1091
1106
|
FragmentSpread: (node) => {
|
|
1092
1107
|
// Do not add `@nonreactive` if the fragment is marked with `@unmask`
|