@apollo/client 3.4.17 → 3.5.6
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/README.md +1 -1
- package/{apollo-client.cjs.js → apollo-client.cjs} +1219 -1280
- package/apollo-client.cjs.map +1 -0
- package/apollo-client.min.cjs +1 -0
- package/cache/{cache.cjs.js → cache.cjs} +757 -601
- package/cache/cache.cjs.map +1 -0
- package/cache/core/cache.d.ts +6 -4
- package/cache/core/cache.d.ts.map +1 -1
- package/cache/core/cache.js +28 -1
- package/cache/core/cache.js.map +1 -1
- package/cache/core/types/Cache.d.ts +12 -10
- package/cache/core/types/Cache.d.ts.map +1 -1
- package/cache/core/types/Cache.js.map +1 -1
- package/cache/core/types/DataProxy.d.ts +4 -0
- package/cache/core/types/DataProxy.d.ts.map +1 -1
- package/cache/core/types/DataProxy.js.map +1 -1
- package/cache/core/types/common.d.ts +8 -5
- package/cache/core/types/common.d.ts.map +1 -1
- package/cache/core/types/common.js +6 -11
- package/cache/core/types/common.js.map +1 -1
- package/cache/inmemory/helpers.js +1 -1
- package/cache/inmemory/helpers.js.map +1 -1
- package/cache/inmemory/inMemoryCache.d.ts +4 -4
- package/cache/inmemory/inMemoryCache.d.ts.map +1 -1
- package/cache/inmemory/inMemoryCache.js +12 -3
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/key-extractor.d.ts +9 -0
- package/cache/inmemory/key-extractor.d.ts.map +1 -0
- package/cache/inmemory/key-extractor.js +118 -0
- package/cache/inmemory/key-extractor.js.map +1 -0
- package/cache/inmemory/policies.d.ts +7 -3
- package/cache/inmemory/policies.d.ts.map +1 -1
- package/cache/inmemory/policies.js +47 -118
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/readFromStore.d.ts +2 -2
- package/cache/inmemory/readFromStore.d.ts.map +1 -1
- package/cache/inmemory/readFromStore.js +54 -42
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/writeToStore.d.ts +8 -3
- package/cache/inmemory/writeToStore.d.ts.map +1 -1
- package/cache/inmemory/writeToStore.js +166 -95
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/cache/package.json +2 -1
- package/core/ApolloClient.d.ts +0 -1
- package/core/ApolloClient.d.ts.map +1 -1
- package/core/ApolloClient.js +3 -3
- package/core/ApolloClient.js.map +1 -1
- package/core/LocalState.js +1 -1
- package/core/LocalState.js.map +1 -1
- package/core/ObservableQuery.d.ts +2 -2
- package/core/ObservableQuery.d.ts.map +1 -1
- package/core/ObservableQuery.js +19 -14
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +2 -2
- package/core/QueryInfo.d.ts.map +1 -1
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +0 -1
- package/core/QueryManager.d.ts.map +1 -1
- package/core/QueryManager.js +10 -10
- package/core/QueryManager.js.map +1 -1
- package/core/{core.cjs.js → core.cjs} +38 -34
- package/core/core.cjs.map +1 -0
- package/core/package.json +2 -1
- package/errors/{errors.cjs.js → errors.cjs} +3 -3
- package/errors/errors.cjs.map +1 -0
- package/errors/index.d.ts +3 -1
- package/errors/index.d.ts.map +1 -1
- package/errors/index.js +2 -2
- package/errors/index.js.map +1 -1
- package/errors/package.json +2 -1
- package/invariantErrorCodes.js +84 -104
- package/link/batch/{batch.cjs.js → batch.cjs} +2 -2
- package/link/batch/batch.cjs.map +1 -0
- package/link/batch/batchLink.d.ts +0 -1
- package/link/batch/batchLink.d.ts.map +1 -1
- package/link/batch/batching.d.ts +0 -1
- package/link/batch/batching.d.ts.map +1 -1
- package/link/batch/batching.js +1 -1
- package/link/batch/batching.js.map +1 -1
- package/link/batch/package.json +2 -1
- package/link/batch-http/{batch-http.cjs.js → batch-http.cjs} +3 -3
- package/link/batch-http/batch-http.cjs.map +1 -0
- package/link/batch-http/batchHttpLink.d.ts +0 -1
- package/link/batch-http/batchHttpLink.d.ts.map +1 -1
- package/link/batch-http/batchHttpLink.js +3 -3
- package/link/batch-http/batchHttpLink.js.map +1 -1
- package/link/batch-http/package.json +2 -1
- package/link/context/{context.cjs.js → context.cjs} +1 -1
- package/link/context/context.cjs.map +1 -0
- package/link/context/index.js.map +1 -1
- package/link/context/package.json +2 -1
- package/link/core/ApolloLink.d.ts +2 -3
- package/link/core/ApolloLink.d.ts.map +1 -1
- package/link/core/ApolloLink.js +1 -1
- package/link/core/ApolloLink.js.map +1 -1
- package/link/core/{core.cjs.js → core.cjs} +2 -2
- package/link/core/core.cjs.map +1 -0
- package/link/core/package.json +2 -1
- package/link/core/types.d.ts +4 -7
- package/link/core/types.d.ts.map +1 -1
- package/link/core/types.js.map +1 -1
- package/link/error/{error.cjs.js → error.cjs} +2 -2
- package/link/error/error.cjs.map +1 -0
- package/link/error/index.d.ts +5 -7
- package/link/error/index.d.ts.map +1 -1
- package/link/error/index.js +1 -1
- package/link/error/index.js.map +1 -1
- package/link/error/package.json +2 -1
- package/link/http/checkFetcher.js +1 -1
- package/link/http/createHttpLink.d.ts.map +1 -1
- package/link/http/createHttpLink.js +3 -3
- package/link/http/createHttpLink.js.map +1 -1
- package/link/http/{http.cjs.js → http.cjs} +28 -15
- package/link/http/http.cjs.map +1 -0
- package/link/http/index.d.ts +1 -1
- package/link/http/index.d.ts.map +1 -1
- package/link/http/index.js +1 -1
- package/link/http/index.js.map +1 -1
- package/link/http/package.json +2 -1
- package/link/http/parseAndCheckHttpResponse.js +3 -3
- package/link/http/parseAndCheckHttpResponse.js.map +1 -1
- package/link/http/rewriteURIForGET.js +1 -1
- package/link/http/rewriteURIForGET.js.map +1 -1
- package/link/http/selectHttpOptionsAndBody.d.ts +11 -1
- package/link/http/selectHttpOptionsAndBody.d.ts.map +1 -1
- package/link/http/selectHttpOptionsAndBody.js +20 -7
- package/link/http/selectHttpOptionsAndBody.js.map +1 -1
- package/link/http/serializeFetchParameter.js +1 -1
- package/link/http/serializeFetchParameter.js.map +1 -1
- package/link/persisted-queries/index.d.ts.map +1 -1
- package/link/persisted-queries/index.js +3 -3
- package/link/persisted-queries/index.js.map +1 -1
- package/link/persisted-queries/package.json +2 -1
- package/link/persisted-queries/{persisted-queries.cjs.js → persisted-queries.cjs} +3 -3
- package/link/persisted-queries/persisted-queries.cjs.map +1 -0
- package/link/retry/package.json +2 -1
- package/link/retry/{retry.cjs.js → retry.cjs} +1 -1
- package/link/retry/retry.cjs.map +1 -0
- package/link/retry/retryLink.d.ts +0 -1
- package/link/retry/retryLink.d.ts.map +1 -1
- package/link/retry/retryLink.js.map +1 -1
- package/link/schema/index.d.ts +0 -1
- package/link/schema/index.d.ts.map +1 -1
- package/link/schema/index.js +8 -1
- package/link/schema/index.js.map +1 -1
- package/link/schema/package.json +2 -1
- package/link/schema/{schema.cjs.js → schema.cjs} +9 -2
- package/link/schema/schema.cjs.map +1 -0
- package/link/utils/fromError.d.ts +0 -1
- package/link/utils/fromError.d.ts.map +1 -1
- package/link/utils/fromPromise.d.ts +0 -1
- package/link/utils/fromPromise.d.ts.map +1 -1
- package/link/utils/package.json +2 -1
- package/link/utils/toPromise.d.ts +0 -1
- package/link/utils/toPromise.d.ts.map +1 -1
- package/link/utils/{utils.cjs.js → utils.cjs} +2 -2
- package/link/utils/utils.cjs.map +1 -0
- package/link/utils/validateOperation.js +1 -1
- package/link/utils/validateOperation.js.map +1 -1
- package/link/ws/index.d.ts +0 -1
- package/link/ws/index.d.ts.map +1 -1
- package/link/ws/package.json +2 -1
- package/link/ws/{ws.cjs.js → ws.cjs} +1 -1
- package/link/ws/ws.cjs.map +1 -0
- package/{main.cjs.js → main.cjs} +5 -5
- package/main.cjs.map +1 -0
- package/package.json +20 -19
- package/react/components/Query.js.map +1 -1
- package/react/components/{components.cjs.js → components.cjs} +4 -4
- package/react/components/components.cjs.map +1 -0
- package/react/components/package.json +2 -1
- package/react/context/ApolloConsumer.js +1 -1
- package/react/context/ApolloProvider.js +1 -1
- package/react/context/{context.cjs.js → context.cjs} +6 -6
- package/react/context/context.cjs.map +1 -0
- package/react/context/index.d.ts +3 -3
- package/react/context/index.d.ts.map +1 -1
- package/react/context/index.js +3 -3
- package/react/context/index.js.map +1 -1
- package/react/context/package.json +2 -1
- package/react/hoc/hoc-utils.js +1 -1
- package/react/hoc/{hoc.cjs.js → hoc.cjs} +12 -12
- package/react/hoc/hoc.cjs.map +1 -0
- package/react/hoc/mutation-hoc.js +2 -2
- package/react/hoc/mutation-hoc.js.map +1 -1
- package/react/hoc/package.json +2 -1
- package/react/hoc/query-hoc.js +1 -1
- package/react/hoc/query-hoc.js.map +1 -1
- package/react/hoc/subscription-hoc.js +1 -1
- package/react/hoc/subscription-hoc.js.map +1 -1
- package/react/hoc/withApollo.js +2 -2
- package/react/hoc/withApollo.js.map +1 -1
- package/react/hooks/hooks.cjs +502 -0
- package/react/hooks/hooks.cjs.map +1 -0
- package/react/hooks/package.json +2 -1
- package/react/hooks/useApolloClient.d.ts +1 -1
- package/react/hooks/useApolloClient.d.ts.map +1 -1
- package/react/hooks/useApolloClient.js +7 -5
- package/react/hooks/useApolloClient.js.map +1 -1
- package/react/hooks/useLazyQuery.d.ts.map +1 -1
- package/react/hooks/useLazyQuery.js +56 -2
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useMutation.d.ts.map +1 -1
- package/react/hooks/useMutation.js +89 -21
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +2 -3
- package/react/hooks/useQuery.d.ts.map +1 -1
- package/react/hooks/useQuery.js +224 -2
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useSubscription.d.ts +2 -7
- package/react/hooks/useSubscription.d.ts.map +1 -1
- package/react/hooks/useSubscription.js +89 -32
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/package.json +2 -1
- package/react/parser/index.d.ts +1 -0
- package/react/parser/index.d.ts.map +1 -1
- package/react/parser/index.js +16 -9
- package/react/parser/index.js.map +1 -1
- package/react/parser/package.json +2 -1
- package/react/parser/{parser.cjs.js → parser.cjs} +18 -10
- package/react/parser/parser.cjs.map +1 -0
- package/react/{react.cjs.js → react.cjs} +3 -3
- package/react/react.cjs.map +1 -0
- package/react/ssr/RenderPromises.d.ts +7 -3
- package/react/ssr/RenderPromises.d.ts.map +1 -1
- package/react/ssr/RenderPromises.js.map +1 -1
- package/react/ssr/package.json +2 -1
- package/react/ssr/{ssr.cjs.js → ssr.cjs} +4 -4
- package/react/ssr/ssr.cjs.map +1 -0
- package/react/types/types.d.ts +7 -18
- package/react/types/types.d.ts.map +1 -1
- package/react/types/types.js.map +1 -1
- package/testing/{testing.cjs.js → core/core.cjs} +10 -104
- package/testing/core/core.cjs.map +1 -0
- package/{utilities/testing → testing/core}/index.d.ts +0 -1
- package/testing/core/index.d.ts.map +1 -0
- package/{utilities/testing → testing/core}/index.js +0 -1
- package/testing/core/index.js.map +1 -0
- package/{utilities/testing → testing/core}/itAsync.d.ts +0 -0
- package/testing/core/itAsync.d.ts.map +1 -0
- package/{utilities/testing → testing/core}/itAsync.js +0 -0
- package/testing/core/itAsync.js.map +1 -0
- package/{utilities/testing → testing/core}/mocking/mockClient.d.ts +0 -0
- package/testing/core/mocking/mockClient.d.ts.map +1 -0
- package/{utilities/testing → testing/core}/mocking/mockClient.js +0 -0
- package/testing/core/mocking/mockClient.js.map +1 -0
- package/{utilities/testing → testing/core}/mocking/mockFetch.d.ts +0 -0
- package/testing/core/mocking/mockFetch.d.ts.map +1 -0
- package/{utilities/testing → testing/core}/mocking/mockFetch.js +1 -1
- package/testing/core/mocking/mockFetch.js.map +1 -0
- package/{utilities/testing → testing/core}/mocking/mockLink.d.ts +0 -1
- package/testing/core/mocking/mockLink.d.ts.map +1 -0
- package/{utilities/testing → testing/core}/mocking/mockLink.js +5 -5
- package/testing/core/mocking/mockLink.js.map +1 -0
- package/{utilities/testing → testing/core}/mocking/mockQueryManager.d.ts +1 -1
- package/testing/core/mocking/mockQueryManager.d.ts.map +1 -0
- package/{utilities/testing → testing/core}/mocking/mockQueryManager.js +1 -1
- package/testing/core/mocking/mockQueryManager.js.map +1 -0
- package/{utilities/testing → testing/core}/mocking/mockSubscriptionLink.d.ts +1 -4
- package/testing/core/mocking/mockSubscriptionLink.d.ts.map +1 -0
- package/{utilities/testing → testing/core}/mocking/mockSubscriptionLink.js +1 -1
- package/testing/core/mocking/mockSubscriptionLink.js.map +1 -0
- package/{utilities/testing → testing/core}/mocking/mockWatchQuery.d.ts +1 -1
- package/testing/core/mocking/mockWatchQuery.d.ts.map +1 -0
- package/{utilities/testing → testing/core}/mocking/mockWatchQuery.js +0 -0
- package/testing/core/mocking/mockWatchQuery.js.map +1 -0
- package/{utilities/testing → testing/core}/observableToPromise.d.ts +2 -3
- package/testing/core/observableToPromise.d.ts.map +1 -0
- package/{utilities/testing → testing/core}/observableToPromise.js +1 -1
- package/testing/core/observableToPromise.js.map +1 -0
- package/testing/core/package.json +8 -0
- package/testing/core/subscribeAndCount.d.ts +4 -0
- package/testing/core/subscribeAndCount.d.ts.map +1 -0
- package/{utilities/testing → testing/core}/subscribeAndCount.js +1 -1
- package/testing/core/subscribeAndCount.js.map +1 -0
- package/{utilities/testing → testing/core}/withConsoleSpy.d.ts +0 -0
- package/testing/core/withConsoleSpy.d.ts.map +1 -0
- package/{utilities/testing → testing/core}/withConsoleSpy.js +0 -0
- package/testing/core/withConsoleSpy.js.map +1 -0
- package/{utilities/testing → testing/core}/wrap.d.ts +0 -0
- package/testing/core/wrap.d.ts.map +1 -0
- package/{utilities/testing → testing/core}/wrap.js +0 -0
- package/testing/core/wrap.js.map +1 -0
- package/testing/index.d.ts +2 -1
- package/testing/index.d.ts.map +1 -1
- package/testing/index.js +2 -1
- package/testing/index.js.map +1 -1
- package/testing/package.json +2 -1
- package/{utilities/testing/mocking → testing/react}/MockedProvider.d.ts +5 -5
- package/testing/react/MockedProvider.d.ts.map +1 -0
- package/{utilities/testing/mocking → testing/react}/MockedProvider.js +4 -4
- package/testing/react/MockedProvider.js.map +1 -0
- package/testing/testing.cjs +58 -0
- package/testing/testing.cjs.map +1 -0
- package/utilities/common/errorHandling.d.ts +1 -1
- package/utilities/common/errorHandling.d.ts.map +1 -1
- package/utilities/common/errorHandling.js.map +1 -1
- package/utilities/common/makeUniqueId.js +1 -1
- package/utilities/common/makeUniqueId.js.map +1 -1
- package/utilities/common/mergeDeep.d.ts.map +1 -1
- package/utilities/common/mergeDeep.js +6 -1
- package/utilities/common/mergeDeep.js.map +1 -1
- package/utilities/globals/fix-graphql.js +1 -1
- package/utilities/globals/global.d.ts.map +1 -1
- package/utilities/globals/global.js +1 -1
- package/utilities/globals/global.js.map +1 -1
- package/utilities/globals/{globals.cjs.js → globals.cjs} +3 -3
- package/utilities/globals/globals.cjs.map +1 -0
- package/utilities/globals/index.js +1 -1
- package/utilities/globals/package.json +2 -1
- package/utilities/graphql/directives.js +5 -5
- package/utilities/graphql/directives.js.map +1 -1
- package/utilities/graphql/fragments.d.ts.map +1 -1
- package/utilities/graphql/fragments.js +4 -4
- package/utilities/graphql/fragments.js.map +1 -1
- package/utilities/graphql/getFromAST.js +8 -8
- package/utilities/graphql/getFromAST.js.map +1 -1
- package/utilities/graphql/storeUtils.js +6 -6
- package/utilities/graphql/storeUtils.js.map +1 -1
- package/utilities/graphql/transform.d.ts.map +1 -1
- package/utilities/graphql/transform.js.map +1 -1
- package/utilities/observables/Concast.d.ts +0 -1
- package/utilities/observables/Concast.d.ts.map +1 -1
- package/utilities/observables/asyncMap.d.ts +0 -1
- package/utilities/observables/asyncMap.d.ts.map +1 -1
- package/utilities/observables/subclassing.d.ts +0 -1
- package/utilities/observables/subclassing.d.ts.map +1 -1
- package/utilities/package.json +2 -1
- package/utilities/{utilities.cjs.js → utilities.cjs} +31 -26
- package/utilities/utilities.cjs.map +1 -0
- package/version.js +1 -1
- package/apollo-client.cjs.js.map +0 -1
- package/apollo-client.cjs.min.js +0 -1
- package/cache/cache.cjs.js.map +0 -1
- package/core/core.cjs.js.map +0 -1
- package/errors/errors.cjs.js.map +0 -1
- package/link/batch/batch.cjs.js.map +0 -1
- package/link/batch-http/batch-http.cjs.js.map +0 -1
- package/link/context/context.cjs.js.map +0 -1
- package/link/core/core.cjs.js.map +0 -1
- package/link/error/error.cjs.js.map +0 -1
- package/link/http/http.cjs.js.map +0 -1
- package/link/persisted-queries/persisted-queries.cjs.js.map +0 -1
- package/link/retry/retry.cjs.js.map +0 -1
- package/link/schema/schema.cjs.js.map +0 -1
- package/link/utils/utils.cjs.js.map +0 -1
- package/link/ws/ws.cjs.js.map +0 -1
- package/main.cjs.js.map +0 -1
- package/react/components/components.cjs.js.map +0 -1
- package/react/context/context.cjs.js.map +0 -1
- package/react/data/MutationData.d.ts +0 -29
- package/react/data/MutationData.d.ts.map +0 -1
- package/react/data/MutationData.js +0 -115
- package/react/data/MutationData.js.map +0 -1
- package/react/data/OperationData.d.ts +0 -24
- package/react/data/OperationData.d.ts.map +0 -1
- package/react/data/OperationData.js +0 -53
- package/react/data/OperationData.js.map +0 -1
- package/react/data/QueryData.d.ts +0 -44
- package/react/data/QueryData.d.ts.map +0 -1
- package/react/data/QueryData.js +0 -298
- package/react/data/QueryData.js.map +0 -1
- package/react/data/SubscriptionData.d.ts +0 -28
- package/react/data/SubscriptionData.d.ts.map +0 -1
- package/react/data/SubscriptionData.js +0 -122
- package/react/data/SubscriptionData.js.map +0 -1
- package/react/data/data.cjs.js +0 -581
- package/react/data/data.cjs.js.map +0 -1
- package/react/data/index.d.ts +0 -6
- package/react/data/index.d.ts.map +0 -1
- package/react/data/index.js +0 -6
- package/react/data/index.js.map +0 -1
- package/react/data/package.json +0 -7
- package/react/hoc/hoc.cjs.js.map +0 -1
- package/react/hooks/hooks.cjs.js +0 -195
- package/react/hooks/hooks.cjs.js.map +0 -1
- package/react/hooks/utils/useAfterFastRefresh.d.ts +0 -3
- package/react/hooks/utils/useAfterFastRefresh.d.ts.map +0 -1
- package/react/hooks/utils/useAfterFastRefresh.js +0 -19
- package/react/hooks/utils/useAfterFastRefresh.js.map +0 -1
- package/react/hooks/utils/useBaseQuery.d.ts +0 -7
- package/react/hooks/utils/useBaseQuery.d.ts.map +0 -1
- package/react/hooks/utils/useBaseQuery.js +0 -55
- package/react/hooks/utils/useBaseQuery.js.map +0 -1
- package/react/hooks/utils/useDeepMemo.d.ts +0 -2
- package/react/hooks/utils/useDeepMemo.d.ts.map +0 -1
- package/react/hooks/utils/useDeepMemo.js +0 -10
- package/react/hooks/utils/useDeepMemo.js.map +0 -1
- package/react/parser/parser.cjs.js.map +0 -1
- package/react/react.cjs.js.map +0 -1
- package/react/ssr/ssr.cjs.js.map +0 -1
- package/testing/testing.cjs.js.map +0 -1
- package/utilities/globals/globals.cjs.js.map +0 -1
- package/utilities/testing/index.d.ts.map +0 -1
- package/utilities/testing/index.js.map +0 -1
- package/utilities/testing/itAsync.d.ts.map +0 -1
- package/utilities/testing/itAsync.js.map +0 -1
- package/utilities/testing/mocking/MockedProvider.d.ts.map +0 -1
- package/utilities/testing/mocking/MockedProvider.js.map +0 -1
- package/utilities/testing/mocking/mockClient.d.ts.map +0 -1
- package/utilities/testing/mocking/mockClient.js.map +0 -1
- package/utilities/testing/mocking/mockFetch.d.ts.map +0 -1
- package/utilities/testing/mocking/mockFetch.js.map +0 -1
- package/utilities/testing/mocking/mockLink.d.ts.map +0 -1
- package/utilities/testing/mocking/mockLink.js.map +0 -1
- package/utilities/testing/mocking/mockQueryManager.d.ts.map +0 -1
- package/utilities/testing/mocking/mockQueryManager.js.map +0 -1
- package/utilities/testing/mocking/mockSubscriptionLink.d.ts.map +0 -1
- package/utilities/testing/mocking/mockSubscriptionLink.js.map +0 -1
- package/utilities/testing/mocking/mockWatchQuery.d.ts.map +0 -1
- package/utilities/testing/mocking/mockWatchQuery.js.map +0 -1
- package/utilities/testing/observableToPromise.d.ts.map +0 -1
- package/utilities/testing/observableToPromise.js.map +0 -1
- package/utilities/testing/subscribeAndCount.d.ts +0 -5
- package/utilities/testing/subscribeAndCount.d.ts.map +0 -1
- package/utilities/testing/subscribeAndCount.js.map +0 -1
- package/utilities/testing/withConsoleSpy.d.ts.map +0 -1
- package/utilities/testing/withConsoleSpy.js.map +0 -1
- package/utilities/testing/wrap.d.ts.map +0 -1
- package/utilities/testing/wrap.js.map +0 -1
- package/utilities/utilities.cjs.js.map +0 -1
|
@@ -18,11 +18,11 @@ function _interopNamespace(e) {
|
|
|
18
18
|
if (e && e.__esModule) return e;
|
|
19
19
|
var n = Object.create(null);
|
|
20
20
|
if (e) {
|
|
21
|
-
|
|
21
|
+
for (var k in e) {
|
|
22
22
|
n[k] = e[k];
|
|
23
|
-
}
|
|
23
|
+
}
|
|
24
24
|
}
|
|
25
|
-
n[
|
|
25
|
+
n["default"] = e;
|
|
26
26
|
return Object.freeze(n);
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -45,7 +45,7 @@ function shouldInclude(_a, variables) {
|
|
|
45
45
|
var evaledValue = false;
|
|
46
46
|
if (ifArgument.value.kind === 'Variable') {
|
|
47
47
|
evaledValue = variables && variables[ifArgument.value.name.value];
|
|
48
|
-
__DEV__ ? tsInvariant.invariant(evaledValue !== void 0, "Invalid variable referenced in @"
|
|
48
|
+
__DEV__ ? tsInvariant.invariant(evaledValue !== void 0, "Invalid variable referenced in @".concat(directive.name.value, " directive.")) : tsInvariant.invariant(evaledValue !== void 0, 37);
|
|
49
49
|
}
|
|
50
50
|
else {
|
|
51
51
|
evaledValue = ifArgument.value.value;
|
|
@@ -82,13 +82,13 @@ function getInclusionDirectives(directives) {
|
|
|
82
82
|
return;
|
|
83
83
|
var directiveArguments = directive.arguments;
|
|
84
84
|
var directiveName = directive.name.value;
|
|
85
|
-
__DEV__ ? tsInvariant.invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @"
|
|
85
|
+
__DEV__ ? tsInvariant.invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @".concat(directiveName, " directive.")) : tsInvariant.invariant(directiveArguments && directiveArguments.length === 1, 38);
|
|
86
86
|
var ifArgument = directiveArguments[0];
|
|
87
|
-
__DEV__ ? tsInvariant.invariant(ifArgument.name && ifArgument.name.value === 'if', "Invalid argument for the @"
|
|
87
|
+
__DEV__ ? tsInvariant.invariant(ifArgument.name && ifArgument.name.value === 'if', "Invalid argument for the @".concat(directiveName, " directive.")) : tsInvariant.invariant(ifArgument.name && ifArgument.name.value === 'if', 39);
|
|
88
88
|
var ifValue = ifArgument.value;
|
|
89
89
|
__DEV__ ? tsInvariant.invariant(ifValue &&
|
|
90
|
-
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), "Argument for the @"
|
|
91
|
-
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'),
|
|
90
|
+
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), "Argument for the @".concat(directiveName, " directive must be a variable or a boolean value.")) : tsInvariant.invariant(ifValue &&
|
|
91
|
+
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 40);
|
|
92
92
|
result.push({ directive: directive, ifArgument: ifArgument });
|
|
93
93
|
});
|
|
94
94
|
}
|
|
@@ -100,15 +100,15 @@ function getFragmentQueryDocument(document, fragmentName) {
|
|
|
100
100
|
var fragments = [];
|
|
101
101
|
document.definitions.forEach(function (definition) {
|
|
102
102
|
if (definition.kind === 'OperationDefinition') {
|
|
103
|
-
throw __DEV__ ? new tsInvariant.InvariantError("Found a "
|
|
104
|
-
'No operations are allowed when using a fragment as a query. Only fragments are allowed.') : new tsInvariant.InvariantError(
|
|
103
|
+
throw __DEV__ ? new tsInvariant.InvariantError("Found a ".concat(definition.operation, " operation").concat(definition.name ? " named '".concat(definition.name.value, "'") : '', ". ") +
|
|
104
|
+
'No operations are allowed when using a fragment as a query. Only fragments are allowed.') : new tsInvariant.InvariantError(41);
|
|
105
105
|
}
|
|
106
106
|
if (definition.kind === 'FragmentDefinition') {
|
|
107
107
|
fragments.push(definition);
|
|
108
108
|
}
|
|
109
109
|
});
|
|
110
110
|
if (typeof actualFragmentName === 'undefined') {
|
|
111
|
-
__DEV__ ? tsInvariant.invariant(fragments.length === 1, "Found "
|
|
111
|
+
__DEV__ ? tsInvariant.invariant(fragments.length === 1, "Found ".concat(fragments.length, " fragments. `fragmentName` must be provided when there is not exactly 1 fragment.")) : tsInvariant.invariant(fragments.length === 1, 42);
|
|
112
112
|
actualFragmentName = fragments[0].name.value;
|
|
113
113
|
}
|
|
114
114
|
var query = tslib.__assign(tslib.__assign({}, document), { definitions: tslib.__spreadArray([
|
|
@@ -145,7 +145,7 @@ function getFragmentFromSelection(selection, fragmentMap) {
|
|
|
145
145
|
return selection;
|
|
146
146
|
case 'FragmentSpread': {
|
|
147
147
|
var fragment = fragmentMap && fragmentMap[selection.name.value];
|
|
148
|
-
__DEV__ ? tsInvariant.invariant(fragment, "No fragment named "
|
|
148
|
+
__DEV__ ? tsInvariant.invariant(fragment, "No fragment named ".concat(selection.name.value, ".")) : tsInvariant.invariant(fragment, 43);
|
|
149
149
|
return fragment;
|
|
150
150
|
}
|
|
151
151
|
default:
|
|
@@ -227,9 +227,9 @@ function valueToObjectRepresentation(argObj, name, value, variables) {
|
|
|
227
227
|
argObj[name.value] = null;
|
|
228
228
|
}
|
|
229
229
|
else {
|
|
230
|
-
throw __DEV__ ? new tsInvariant.InvariantError("The inline argument \""
|
|
230
|
+
throw __DEV__ ? new tsInvariant.InvariantError("The inline argument \"".concat(name.value, "\" of kind \"").concat(value.kind, "\"") +
|
|
231
231
|
'is not supported. Use variables instead of inline arguments to ' +
|
|
232
|
-
'overcome this limitation.') : new tsInvariant.InvariantError(
|
|
232
|
+
'overcome this limitation.') : new tsInvariant.InvariantError(52);
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
235
|
function storeKeyNameFromField(field, variables) {
|
|
@@ -279,7 +279,7 @@ var getStoreKeyName = Object.assign(function (fieldName, args, directives) {
|
|
|
279
279
|
filterKeys.forEach(function (key) {
|
|
280
280
|
filteredArgs_1[key] = args[key];
|
|
281
281
|
});
|
|
282
|
-
return directives['connection']['key']
|
|
282
|
+
return "".concat(directives['connection']['key'], "(").concat(stringify(filteredArgs_1), ")");
|
|
283
283
|
}
|
|
284
284
|
else {
|
|
285
285
|
return directives['connection']['key'];
|
|
@@ -288,17 +288,17 @@ var getStoreKeyName = Object.assign(function (fieldName, args, directives) {
|
|
|
288
288
|
var completeFieldName = fieldName;
|
|
289
289
|
if (args) {
|
|
290
290
|
var stringifiedArgs = stringify(args);
|
|
291
|
-
completeFieldName += "("
|
|
291
|
+
completeFieldName += "(".concat(stringifiedArgs, ")");
|
|
292
292
|
}
|
|
293
293
|
if (directives) {
|
|
294
294
|
Object.keys(directives).forEach(function (key) {
|
|
295
295
|
if (KNOWN_DIRECTIVES.indexOf(key) !== -1)
|
|
296
296
|
return;
|
|
297
297
|
if (directives[key] && Object.keys(directives[key]).length) {
|
|
298
|
-
completeFieldName += "@"
|
|
298
|
+
completeFieldName += "@".concat(key, "(").concat(stringify(directives[key]), ")");
|
|
299
299
|
}
|
|
300
300
|
else {
|
|
301
|
-
completeFieldName += "@"
|
|
301
|
+
completeFieldName += "@".concat(key);
|
|
302
302
|
}
|
|
303
303
|
});
|
|
304
304
|
}
|
|
@@ -363,16 +363,16 @@ function isInlineFragment(selection) {
|
|
|
363
363
|
}
|
|
364
364
|
|
|
365
365
|
function checkDocument(doc) {
|
|
366
|
-
__DEV__ ? tsInvariant.invariant(doc && doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql") : tsInvariant.invariant(doc && doc.kind === 'Document',
|
|
366
|
+
__DEV__ ? tsInvariant.invariant(doc && doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql") : tsInvariant.invariant(doc && doc.kind === 'Document', 44);
|
|
367
367
|
var operations = doc.definitions
|
|
368
368
|
.filter(function (d) { return d.kind !== 'FragmentDefinition'; })
|
|
369
369
|
.map(function (definition) {
|
|
370
370
|
if (definition.kind !== 'OperationDefinition') {
|
|
371
|
-
throw __DEV__ ? new tsInvariant.InvariantError("Schema type definitions not allowed in queries. Found: \""
|
|
371
|
+
throw __DEV__ ? new tsInvariant.InvariantError("Schema type definitions not allowed in queries. Found: \"".concat(definition.kind, "\"")) : new tsInvariant.InvariantError(45);
|
|
372
372
|
}
|
|
373
373
|
return definition;
|
|
374
374
|
});
|
|
375
|
-
__DEV__ ? tsInvariant.invariant(operations.length <= 1, "Ambiguous GraphQL document: contains "
|
|
375
|
+
__DEV__ ? tsInvariant.invariant(operations.length <= 1, "Ambiguous GraphQL document: contains ".concat(operations.length, " operations")) : tsInvariant.invariant(operations.length <= 1, 46);
|
|
376
376
|
return doc;
|
|
377
377
|
}
|
|
378
378
|
function getOperationDefinition(doc) {
|
|
@@ -391,14 +391,14 @@ function getFragmentDefinitions(doc) {
|
|
|
391
391
|
}
|
|
392
392
|
function getQueryDefinition(doc) {
|
|
393
393
|
var queryDef = getOperationDefinition(doc);
|
|
394
|
-
__DEV__ ? tsInvariant.invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.') : tsInvariant.invariant(queryDef && queryDef.operation === 'query',
|
|
394
|
+
__DEV__ ? tsInvariant.invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.') : tsInvariant.invariant(queryDef && queryDef.operation === 'query', 47);
|
|
395
395
|
return queryDef;
|
|
396
396
|
}
|
|
397
397
|
function getFragmentDefinition(doc) {
|
|
398
|
-
__DEV__ ? tsInvariant.invariant(doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql") : tsInvariant.invariant(doc.kind === 'Document',
|
|
399
|
-
__DEV__ ? tsInvariant.invariant(doc.definitions.length <= 1, 'Fragment must have exactly one definition.') : tsInvariant.invariant(doc.definitions.length <= 1,
|
|
398
|
+
__DEV__ ? tsInvariant.invariant(doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql") : tsInvariant.invariant(doc.kind === 'Document', 48);
|
|
399
|
+
__DEV__ ? tsInvariant.invariant(doc.definitions.length <= 1, 'Fragment must have exactly one definition.') : tsInvariant.invariant(doc.definitions.length <= 1, 49);
|
|
400
400
|
var fragmentDef = doc.definitions[0];
|
|
401
|
-
__DEV__ ? tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.') : tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition',
|
|
401
|
+
__DEV__ ? tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.') : tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition', 50);
|
|
402
402
|
return fragmentDef;
|
|
403
403
|
}
|
|
404
404
|
function getMainDefinition(queryDoc) {
|
|
@@ -421,7 +421,7 @@ function getMainDefinition(queryDoc) {
|
|
|
421
421
|
if (fragmentDefinition) {
|
|
422
422
|
return fragmentDefinition;
|
|
423
423
|
}
|
|
424
|
-
throw __DEV__ ? new tsInvariant.InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.') : new tsInvariant.InvariantError(
|
|
424
|
+
throw __DEV__ ? new tsInvariant.InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.') : new tsInvariant.InvariantError(51);
|
|
425
425
|
}
|
|
426
426
|
function getDefaultValues(definition) {
|
|
427
427
|
var defaultValues = Object.create(null);
|
|
@@ -760,7 +760,12 @@ var DeepMerger = (function () {
|
|
|
760
760
|
return source;
|
|
761
761
|
};
|
|
762
762
|
DeepMerger.prototype.shallowCopyForMerge = function (value) {
|
|
763
|
-
if (isNonNullObject(value)
|
|
763
|
+
if (isNonNullObject(value)) {
|
|
764
|
+
if (this.pastCopies.has(value)) {
|
|
765
|
+
if (!Object.isFrozen(value))
|
|
766
|
+
return value;
|
|
767
|
+
this.pastCopies.delete(value);
|
|
768
|
+
}
|
|
764
769
|
if (Array.isArray(value)) {
|
|
765
770
|
value = value.slice(0);
|
|
766
771
|
}
|
|
@@ -1072,7 +1077,7 @@ var prefixCounts = new Map();
|
|
|
1072
1077
|
function makeUniqueId(prefix) {
|
|
1073
1078
|
var count = prefixCounts.get(prefix) || 1;
|
|
1074
1079
|
prefixCounts.set(prefix, count + 1);
|
|
1075
|
-
return prefix
|
|
1080
|
+
return "".concat(prefix, ":").concat(count, ":").concat(Math.random().toString(36).slice(2));
|
|
1076
1081
|
}
|
|
1077
1082
|
|
|
1078
1083
|
function stringifyForDisplay(value) {
|
|
@@ -1137,7 +1142,7 @@ function validateOperation(operation) {
|
|
|
1137
1142
|
for (var _i = 0, _a = Object.keys(operation); _i < _a.length; _i++) {
|
|
1138
1143
|
var key = _a[_i];
|
|
1139
1144
|
if (OPERATION_FIELDS.indexOf(key) < 0) {
|
|
1140
|
-
throw __DEV__ ? new tsInvariant.InvariantError("illegal argument: "
|
|
1145
|
+
throw __DEV__ ? new tsInvariant.InvariantError("illegal argument: ".concat(key)) : new tsInvariant.InvariantError(24);
|
|
1141
1146
|
}
|
|
1142
1147
|
}
|
|
1143
1148
|
return operation;
|
|
@@ -1260,7 +1265,7 @@ var ApolloLink = (function () {
|
|
|
1260
1265
|
return ApolloLink.concat(this, next);
|
|
1261
1266
|
};
|
|
1262
1267
|
ApolloLink.prototype.request = function (operation, forward) {
|
|
1263
|
-
throw __DEV__ ? new tsInvariant.InvariantError('request is not implemented') : new tsInvariant.InvariantError(
|
|
1268
|
+
throw __DEV__ ? new tsInvariant.InvariantError('request is not implemented') : new tsInvariant.InvariantError(19);
|
|
1264
1269
|
};
|
|
1265
1270
|
ApolloLink.prototype.onError = function (error, observer) {
|
|
1266
1271
|
if (observer && observer.error) {
|
|
@@ -1286,7 +1291,7 @@ var concat = ApolloLink.concat;
|
|
|
1286
1291
|
|
|
1287
1292
|
var execute = ApolloLink.execute;
|
|
1288
1293
|
|
|
1289
|
-
var version = '3.
|
|
1294
|
+
var version = '3.5.6';
|
|
1290
1295
|
|
|
1291
1296
|
var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
|
|
1292
1297
|
function parseAndCheckHttpResponse(operations) {
|
|
@@ -1307,14 +1312,14 @@ function parseAndCheckHttpResponse(operations) {
|
|
|
1307
1312
|
})
|
|
1308
1313
|
.then(function (result) {
|
|
1309
1314
|
if (response.status >= 300) {
|
|
1310
|
-
throwServerError(response, result, "Response not successful: Received status code "
|
|
1315
|
+
throwServerError(response, result, "Response not successful: Received status code ".concat(response.status));
|
|
1311
1316
|
}
|
|
1312
1317
|
if (!Array.isArray(result) &&
|
|
1313
1318
|
!hasOwnProperty$2.call(result, 'data') &&
|
|
1314
1319
|
!hasOwnProperty$2.call(result, 'errors')) {
|
|
1315
|
-
throwServerError(response, result, "Server response was missing for query '"
|
|
1320
|
+
throwServerError(response, result, "Server response was missing for query '".concat(Array.isArray(operations)
|
|
1316
1321
|
? operations.map(function (op) { return op.operationName; })
|
|
1317
|
-
: operations.operationName
|
|
1322
|
+
: operations.operationName, "'."));
|
|
1318
1323
|
}
|
|
1319
1324
|
return result;
|
|
1320
1325
|
}); };
|
|
@@ -1326,7 +1331,7 @@ var serializeFetchParameter = function (p, label) {
|
|
|
1326
1331
|
serialized = JSON.stringify(p);
|
|
1327
1332
|
}
|
|
1328
1333
|
catch (e) {
|
|
1329
|
-
var parseError = __DEV__ ? new tsInvariant.InvariantError("Network request failed. "
|
|
1334
|
+
var parseError = __DEV__ ? new tsInvariant.InvariantError("Network request failed. ".concat(label, " is not serializable: ").concat(e.message)) : new tsInvariant.InvariantError(21);
|
|
1330
1335
|
parseError.parseError = e;
|
|
1331
1336
|
throw parseError;
|
|
1332
1337
|
}
|
|
@@ -1349,17 +1354,28 @@ var fallbackHttpConfig = {
|
|
|
1349
1354
|
headers: defaultHeaders,
|
|
1350
1355
|
options: defaultOptions,
|
|
1351
1356
|
};
|
|
1352
|
-
var
|
|
1357
|
+
var defaultPrinter = function (ast, printer) { return printer(ast); };
|
|
1358
|
+
function selectHttpOptionsAndBody(operation, fallbackConfig) {
|
|
1359
|
+
var configs = [];
|
|
1360
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1361
|
+
configs[_i - 2] = arguments[_i];
|
|
1362
|
+
}
|
|
1363
|
+
configs.unshift(fallbackConfig);
|
|
1364
|
+
return selectHttpOptionsAndBodyInternal.apply(void 0, tslib.__spreadArray([operation,
|
|
1365
|
+
defaultPrinter], configs, false));
|
|
1366
|
+
}
|
|
1367
|
+
function selectHttpOptionsAndBodyInternal(operation, printer) {
|
|
1353
1368
|
var configs = [];
|
|
1354
1369
|
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1355
1370
|
configs[_i - 2] = arguments[_i];
|
|
1356
1371
|
}
|
|
1357
|
-
var options =
|
|
1358
|
-
var http =
|
|
1372
|
+
var options = {};
|
|
1373
|
+
var http = {};
|
|
1359
1374
|
configs.forEach(function (config) {
|
|
1360
1375
|
options = tslib.__assign(tslib.__assign(tslib.__assign({}, options), config.options), { headers: tslib.__assign(tslib.__assign({}, options.headers), headersToLowerCase(config.headers)) });
|
|
1361
|
-
if (config.credentials)
|
|
1376
|
+
if (config.credentials) {
|
|
1362
1377
|
options.credentials = config.credentials;
|
|
1378
|
+
}
|
|
1363
1379
|
http = tslib.__assign(tslib.__assign({}, http), config.http);
|
|
1364
1380
|
});
|
|
1365
1381
|
var operationName = operation.operationName, extensions = operation.extensions, variables = operation.variables, query = operation.query;
|
|
@@ -1367,12 +1383,12 @@ var selectHttpOptionsAndBody = function (operation, fallbackConfig) {
|
|
|
1367
1383
|
if (http.includeExtensions)
|
|
1368
1384
|
body.extensions = extensions;
|
|
1369
1385
|
if (http.includeQuery)
|
|
1370
|
-
body.query = graphql.print
|
|
1386
|
+
body.query = printer(query, graphql.print);
|
|
1371
1387
|
return {
|
|
1372
1388
|
options: options,
|
|
1373
1389
|
body: body,
|
|
1374
1390
|
};
|
|
1375
|
-
}
|
|
1391
|
+
}
|
|
1376
1392
|
function headersToLowerCase(headers) {
|
|
1377
1393
|
if (headers) {
|
|
1378
1394
|
var normalized_1 = Object.create(null);
|
|
@@ -1386,7 +1402,7 @@ function headersToLowerCase(headers) {
|
|
|
1386
1402
|
|
|
1387
1403
|
var checkFetcher = function (fetcher) {
|
|
1388
1404
|
if (!fetcher && typeof fetch === 'undefined') {
|
|
1389
|
-
throw __DEV__ ? new tsInvariant.InvariantError("\n\"fetch\" has not been found globally and no fetcher has been configured. To fix this, install a fetch package (like https://www.npmjs.com/package/cross-fetch), instantiate the fetcher, and pass it into your HttpLink constructor. For example:\n\nimport fetch from 'cross-fetch';\nimport { ApolloClient, HttpLink } from '@apollo/client';\nconst client = new ApolloClient({\n link: new HttpLink({ uri: '/graphql', fetch })\n});\n ") : new tsInvariant.InvariantError(
|
|
1405
|
+
throw __DEV__ ? new tsInvariant.InvariantError("\n\"fetch\" has not been found globally and no fetcher has been configured. To fix this, install a fetch package (like https://www.npmjs.com/package/cross-fetch), instantiate the fetcher, and pass it into your HttpLink constructor. For example:\n\nimport fetch from 'cross-fetch';\nimport { ApolloClient, HttpLink } from '@apollo/client';\nconst client = new ApolloClient({\n link: new HttpLink({ uri: '/graphql', fetch })\n});\n ") : new tsInvariant.InvariantError(20);
|
|
1390
1406
|
}
|
|
1391
1407
|
};
|
|
1392
1408
|
|
|
@@ -1415,7 +1431,7 @@ var selectURI = function (operation, fallbackURI) {
|
|
|
1415
1431
|
function rewriteURIForGET(chosenURI, body) {
|
|
1416
1432
|
var queryParams = [];
|
|
1417
1433
|
var addQueryParam = function (key, value) {
|
|
1418
|
-
queryParams.push(key
|
|
1434
|
+
queryParams.push("".concat(key, "=").concat(encodeURIComponent(value)));
|
|
1419
1435
|
};
|
|
1420
1436
|
if ('query' in body) {
|
|
1421
1437
|
addQueryParam('query', body.query);
|
|
@@ -1457,7 +1473,7 @@ function rewriteURIForGET(chosenURI, body) {
|
|
|
1457
1473
|
var backupFetch = maybe(function () { return fetch; });
|
|
1458
1474
|
var createHttpLink = function (linkOptions) {
|
|
1459
1475
|
if (linkOptions === void 0) { linkOptions = {}; }
|
|
1460
|
-
var _a = linkOptions.uri, uri = _a === void 0 ? '/graphql' : _a, preferredFetch = linkOptions.fetch, includeExtensions = linkOptions.includeExtensions, useGETForQueries = linkOptions.useGETForQueries,
|
|
1476
|
+
var _a = linkOptions.uri, uri = _a === void 0 ? '/graphql' : _a, preferredFetch = linkOptions.fetch, _b = linkOptions.print, print = _b === void 0 ? defaultPrinter : _b, includeExtensions = linkOptions.includeExtensions, useGETForQueries = linkOptions.useGETForQueries, _c = linkOptions.includeUnusedVariables, includeUnusedVariables = _c === void 0 ? false : _c, requestOptions = tslib.__rest(linkOptions, ["uri", "fetch", "print", "includeExtensions", "useGETForQueries", "includeUnusedVariables"]);
|
|
1461
1477
|
if (__DEV__) {
|
|
1462
1478
|
checkFetcher(preferredFetch || backupFetch);
|
|
1463
1479
|
}
|
|
@@ -1487,7 +1503,7 @@ var createHttpLink = function (linkOptions) {
|
|
|
1487
1503
|
credentials: context.credentials,
|
|
1488
1504
|
headers: contextHeaders,
|
|
1489
1505
|
};
|
|
1490
|
-
var _b =
|
|
1506
|
+
var _b = selectHttpOptionsAndBodyInternal(operation, print, fallbackHttpConfig, linkConfig, contextConfig), options = _b.options, body = _b.body;
|
|
1491
1507
|
if (body.variables && !includeUnusedVariables) {
|
|
1492
1508
|
var unusedNames_1 = new Set(Object.keys(body.variables));
|
|
1493
1509
|
graphql.visit(operation.query, {
|
|
@@ -1578,9 +1594,12 @@ var ApolloCache = (function () {
|
|
|
1578
1594
|
this.getFragmentDoc = optimism.wrap(getFragmentQueryDocument);
|
|
1579
1595
|
}
|
|
1580
1596
|
ApolloCache.prototype.batch = function (options) {
|
|
1597
|
+
var _this = this;
|
|
1581
1598
|
var optimisticId = typeof options.optimistic === "string" ? options.optimistic :
|
|
1582
1599
|
options.optimistic === false ? null : void 0;
|
|
1583
|
-
|
|
1600
|
+
var updateResult;
|
|
1601
|
+
this.performTransaction(function () { return updateResult = options.update(_this); }, optimisticId);
|
|
1602
|
+
return updateResult;
|
|
1584
1603
|
};
|
|
1585
1604
|
ApolloCache.prototype.recordOptimisticTransaction = function (transaction, optimisticId) {
|
|
1586
1605
|
this.performTransaction(transaction, optimisticId);
|
|
@@ -1623,6 +1642,30 @@ var ApolloCache = (function () {
|
|
|
1623
1642
|
result: data,
|
|
1624
1643
|
}));
|
|
1625
1644
|
};
|
|
1645
|
+
ApolloCache.prototype.updateQuery = function (options, update) {
|
|
1646
|
+
return this.batch({
|
|
1647
|
+
update: function (cache) {
|
|
1648
|
+
var value = cache.readQuery(options);
|
|
1649
|
+
var data = update(value);
|
|
1650
|
+
if (data === void 0 || data === null)
|
|
1651
|
+
return value;
|
|
1652
|
+
cache.writeQuery(tslib.__assign(tslib.__assign({}, options), { data: data }));
|
|
1653
|
+
return data;
|
|
1654
|
+
},
|
|
1655
|
+
});
|
|
1656
|
+
};
|
|
1657
|
+
ApolloCache.prototype.updateFragment = function (options, update) {
|
|
1658
|
+
return this.batch({
|
|
1659
|
+
update: function (cache) {
|
|
1660
|
+
var value = cache.readFragment(options);
|
|
1661
|
+
var data = update(value);
|
|
1662
|
+
if (data === void 0 || data === null)
|
|
1663
|
+
return value;
|
|
1664
|
+
cache.writeFragment(tslib.__assign(tslib.__assign({}, options), { data: data }));
|
|
1665
|
+
return data;
|
|
1666
|
+
},
|
|
1667
|
+
});
|
|
1668
|
+
};
|
|
1626
1669
|
return ApolloCache;
|
|
1627
1670
|
}());
|
|
1628
1671
|
|
|
@@ -1630,19 +1673,15 @@ exports.Cache = void 0;
|
|
|
1630
1673
|
(function (Cache) {
|
|
1631
1674
|
})(exports.Cache || (exports.Cache = {}));
|
|
1632
1675
|
|
|
1633
|
-
var MissingFieldError = (function (
|
|
1634
|
-
tslib.__extends(MissingFieldError, _super);
|
|
1676
|
+
var MissingFieldError = (function () {
|
|
1635
1677
|
function MissingFieldError(message, path, query, variables) {
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
_this.variables = variables;
|
|
1641
|
-
_this.__proto__ = MissingFieldError.prototype;
|
|
1642
|
-
return _this;
|
|
1678
|
+
this.message = message;
|
|
1679
|
+
this.path = path;
|
|
1680
|
+
this.query = query;
|
|
1681
|
+
this.variables = variables;
|
|
1643
1682
|
}
|
|
1644
1683
|
return MissingFieldError;
|
|
1645
|
-
}(
|
|
1684
|
+
}());
|
|
1646
1685
|
|
|
1647
1686
|
var hasOwn = Object.prototype.hasOwnProperty;
|
|
1648
1687
|
function defaultDataIdFromObject(_a, context) {
|
|
@@ -1657,7 +1696,7 @@ function defaultDataIdFromObject(_a, context) {
|
|
|
1657
1696
|
if (id === void 0)
|
|
1658
1697
|
id = _id;
|
|
1659
1698
|
if (id !== void 0) {
|
|
1660
|
-
return __typename
|
|
1699
|
+
return "".concat(__typename, ":").concat((typeof id === "number" ||
|
|
1661
1700
|
typeof id === "string") ? id : JSON.stringify(id));
|
|
1662
1701
|
}
|
|
1663
1702
|
}
|
|
@@ -2283,9 +2322,6 @@ function resetCanonicalStringify() {
|
|
|
2283
2322
|
stringifyCache = new (canUseWeakMap ? WeakMap : Map)();
|
|
2284
2323
|
}
|
|
2285
2324
|
|
|
2286
|
-
function missingFromInvariant(err, context) {
|
|
2287
|
-
return new MissingFieldError(err.message, context.path.slice(), context.query, context.variables);
|
|
2288
|
-
}
|
|
2289
2325
|
function execSelectionSetKeyArgs(options) {
|
|
2290
2326
|
return [
|
|
2291
2327
|
options.selectionSet,
|
|
@@ -2347,6 +2383,7 @@ var StoreReader = (function () {
|
|
|
2347
2383
|
var policies = this.config.cache.policies;
|
|
2348
2384
|
variables = tslib.__assign(tslib.__assign({}, getDefaultValues(getQueryDefinition(query))), variables);
|
|
2349
2385
|
var rootRef = makeReference(rootId);
|
|
2386
|
+
var merger = new DeepMerger;
|
|
2350
2387
|
var execResult = this.executeSelectionSet({
|
|
2351
2388
|
selectionSet: getMainDefinition(query).selectionSet,
|
|
2352
2389
|
objectOrReference: rootRef,
|
|
@@ -2359,17 +2396,22 @@ var StoreReader = (function () {
|
|
|
2359
2396
|
varString: canonicalStringify(variables),
|
|
2360
2397
|
canonizeResults: canonizeResults,
|
|
2361
2398
|
fragmentMap: createFragmentMap(getFragmentDefinitions(query)),
|
|
2362
|
-
|
|
2399
|
+
merge: function (a, b) {
|
|
2400
|
+
return merger.merge(a, b);
|
|
2401
|
+
},
|
|
2363
2402
|
},
|
|
2364
2403
|
});
|
|
2365
|
-
var
|
|
2366
|
-
if (
|
|
2367
|
-
|
|
2404
|
+
var missing;
|
|
2405
|
+
if (execResult.missing) {
|
|
2406
|
+
missing = [new MissingFieldError(firstMissing(execResult.missing), execResult.missing, query, variables)];
|
|
2407
|
+
if (!returnPartialData) {
|
|
2408
|
+
throw missing[0];
|
|
2409
|
+
}
|
|
2368
2410
|
}
|
|
2369
2411
|
return {
|
|
2370
2412
|
result: execResult.result,
|
|
2371
|
-
|
|
2372
|
-
|
|
2413
|
+
complete: !missing,
|
|
2414
|
+
missing: missing,
|
|
2373
2415
|
};
|
|
2374
2416
|
};
|
|
2375
2417
|
StoreReader.prototype.isFresh = function (result, parent, selectionSet, context) {
|
|
@@ -2390,30 +2432,28 @@ var StoreReader = (function () {
|
|
|
2390
2432
|
!context.store.has(objectOrReference.__ref)) {
|
|
2391
2433
|
return {
|
|
2392
2434
|
result: this.canon.empty,
|
|
2393
|
-
missing:
|
|
2435
|
+
missing: "Dangling reference to missing ".concat(objectOrReference.__ref, " object"),
|
|
2394
2436
|
};
|
|
2395
2437
|
}
|
|
2396
2438
|
var variables = context.variables, policies = context.policies, store = context.store;
|
|
2397
|
-
var objectsToMerge = [];
|
|
2398
|
-
var finalResult = { result: null };
|
|
2399
2439
|
var typename = store.getFieldValue(objectOrReference, "__typename");
|
|
2440
|
+
var result = {};
|
|
2441
|
+
var missing;
|
|
2400
2442
|
if (this.config.addTypename &&
|
|
2401
2443
|
typeof typename === "string" &&
|
|
2402
2444
|
!policies.rootIdsByTypename[typename]) {
|
|
2403
|
-
|
|
2404
|
-
}
|
|
2405
|
-
function getMissing() {
|
|
2406
|
-
return finalResult.missing || (finalResult.missing = []);
|
|
2445
|
+
result = { __typename: typename };
|
|
2407
2446
|
}
|
|
2408
|
-
function handleMissing(result) {
|
|
2447
|
+
function handleMissing(result, resultName) {
|
|
2409
2448
|
var _a;
|
|
2410
|
-
if (result.missing)
|
|
2411
|
-
|
|
2449
|
+
if (result.missing) {
|
|
2450
|
+
missing = context.merge(missing, (_a = {}, _a[resultName] = result.missing, _a));
|
|
2451
|
+
}
|
|
2412
2452
|
return result.result;
|
|
2413
2453
|
}
|
|
2414
2454
|
var workSet = new Set(selectionSet.selections);
|
|
2415
2455
|
workSet.forEach(function (selection) {
|
|
2416
|
-
var _a;
|
|
2456
|
+
var _a, _b;
|
|
2417
2457
|
if (!shouldInclude(selection, variables))
|
|
2418
2458
|
return;
|
|
2419
2459
|
if (isField(selection)) {
|
|
@@ -2424,12 +2464,13 @@ var StoreReader = (function () {
|
|
|
2424
2464
|
from: objectOrReference,
|
|
2425
2465
|
}, context);
|
|
2426
2466
|
var resultName = resultKeyNameFromField(selection);
|
|
2427
|
-
context.path.push(resultName);
|
|
2428
2467
|
if (fieldValue === void 0) {
|
|
2429
2468
|
if (!addTypenameToDocument.added(selection)) {
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2469
|
+
missing = context.merge(missing, (_a = {},
|
|
2470
|
+
_a[resultName] = "Can't find field '".concat(selection.name.value, "' on ").concat(isReference(objectOrReference)
|
|
2471
|
+
? objectOrReference.__ref + " object"
|
|
2472
|
+
: "object " + JSON.stringify(objectOrReference, null, 2)),
|
|
2473
|
+
_a));
|
|
2433
2474
|
}
|
|
2434
2475
|
}
|
|
2435
2476
|
else if (Array.isArray(fieldValue)) {
|
|
@@ -2438,7 +2479,7 @@ var StoreReader = (function () {
|
|
|
2438
2479
|
array: fieldValue,
|
|
2439
2480
|
enclosingRef: enclosingRef,
|
|
2440
2481
|
context: context,
|
|
2441
|
-
}));
|
|
2482
|
+
}), resultName);
|
|
2442
2483
|
}
|
|
2443
2484
|
else if (!selection.selectionSet) {
|
|
2444
2485
|
if (context.canonizeResults) {
|
|
@@ -2451,12 +2492,11 @@ var StoreReader = (function () {
|
|
|
2451
2492
|
objectOrReference: fieldValue,
|
|
2452
2493
|
enclosingRef: isReference(fieldValue) ? fieldValue : enclosingRef,
|
|
2453
2494
|
context: context,
|
|
2454
|
-
}));
|
|
2495
|
+
}), resultName);
|
|
2455
2496
|
}
|
|
2456
2497
|
if (fieldValue !== void 0) {
|
|
2457
|
-
|
|
2498
|
+
result = context.merge(result, (_b = {}, _b[resultName] = fieldValue, _b));
|
|
2458
2499
|
}
|
|
2459
|
-
tsInvariant.invariant(context.path.pop() === resultName);
|
|
2460
2500
|
}
|
|
2461
2501
|
else {
|
|
2462
2502
|
var fragment = getFragmentFromSelection(selection, context.fragmentMap);
|
|
@@ -2465,23 +2505,24 @@ var StoreReader = (function () {
|
|
|
2465
2505
|
}
|
|
2466
2506
|
}
|
|
2467
2507
|
});
|
|
2468
|
-
var
|
|
2469
|
-
|
|
2470
|
-
? this.canon.admit(
|
|
2471
|
-
: maybeDeepFreeze(
|
|
2472
|
-
|
|
2473
|
-
|
|
2508
|
+
var finalResult = { result: result, missing: missing };
|
|
2509
|
+
var frozen = context.canonizeResults
|
|
2510
|
+
? this.canon.admit(finalResult)
|
|
2511
|
+
: maybeDeepFreeze(finalResult);
|
|
2512
|
+
if (frozen.result) {
|
|
2513
|
+
this.knownResults.set(frozen.result, selectionSet);
|
|
2514
|
+
}
|
|
2515
|
+
return frozen;
|
|
2474
2516
|
};
|
|
2475
2517
|
StoreReader.prototype.execSubSelectedArrayImpl = function (_a) {
|
|
2476
2518
|
var _this = this;
|
|
2477
2519
|
var field = _a.field, array = _a.array, enclosingRef = _a.enclosingRef, context = _a.context;
|
|
2478
2520
|
var missing;
|
|
2479
2521
|
function handleMissing(childResult, i) {
|
|
2522
|
+
var _a;
|
|
2480
2523
|
if (childResult.missing) {
|
|
2481
|
-
missing = missing
|
|
2482
|
-
missing.push.apply(missing, childResult.missing);
|
|
2524
|
+
missing = context.merge(missing, (_a = {}, _a[i] = childResult.missing, _a));
|
|
2483
2525
|
}
|
|
2484
|
-
tsInvariant.invariant(context.path.pop() === i);
|
|
2485
2526
|
return childResult.result;
|
|
2486
2527
|
}
|
|
2487
2528
|
if (field.selectionSet) {
|
|
@@ -2491,7 +2532,6 @@ var StoreReader = (function () {
|
|
|
2491
2532
|
if (item === null) {
|
|
2492
2533
|
return null;
|
|
2493
2534
|
}
|
|
2494
|
-
context.path.push(i);
|
|
2495
2535
|
if (Array.isArray(item)) {
|
|
2496
2536
|
return handleMissing(_this.executeSubSelectedArray({
|
|
2497
2537
|
field: field,
|
|
@@ -2511,7 +2551,6 @@ var StoreReader = (function () {
|
|
|
2511
2551
|
if (__DEV__) {
|
|
2512
2552
|
assertSelectionSetForIdValue(context.store, field, item);
|
|
2513
2553
|
}
|
|
2514
|
-
tsInvariant.invariant(context.path.pop() === i);
|
|
2515
2554
|
return item;
|
|
2516
2555
|
});
|
|
2517
2556
|
return {
|
|
@@ -2521,401 +2560,206 @@ var StoreReader = (function () {
|
|
|
2521
2560
|
};
|
|
2522
2561
|
return StoreReader;
|
|
2523
2562
|
}());
|
|
2563
|
+
function firstMissing(tree) {
|
|
2564
|
+
try {
|
|
2565
|
+
JSON.stringify(tree, function (_, value) {
|
|
2566
|
+
if (typeof value === "string")
|
|
2567
|
+
throw value;
|
|
2568
|
+
return value;
|
|
2569
|
+
});
|
|
2570
|
+
}
|
|
2571
|
+
catch (result) {
|
|
2572
|
+
return result;
|
|
2573
|
+
}
|
|
2574
|
+
}
|
|
2524
2575
|
function assertSelectionSetForIdValue(store, field, fieldValue) {
|
|
2525
2576
|
if (!field.selectionSet) {
|
|
2526
2577
|
var workSet_1 = new Set([fieldValue]);
|
|
2527
2578
|
workSet_1.forEach(function (value) {
|
|
2528
2579
|
if (isNonNullObject(value)) {
|
|
2529
|
-
__DEV__ ? tsInvariant.invariant(!isReference(value), "Missing selection set for object of type "
|
|
2580
|
+
__DEV__ ? tsInvariant.invariant(!isReference(value), "Missing selection set for object of type ".concat(getTypenameFromStoreObject(store, value), " returned for query field ").concat(field.name.value)) : tsInvariant.invariant(!isReference(value), 5);
|
|
2530
2581
|
Object.values(value).forEach(workSet_1.add, workSet_1);
|
|
2531
2582
|
}
|
|
2532
2583
|
});
|
|
2533
2584
|
}
|
|
2534
2585
|
}
|
|
2535
2586
|
|
|
2536
|
-
var
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
var operationDefinition = getOperationDefinition(query);
|
|
2545
|
-
var merger = makeProcessedFieldsMerger();
|
|
2546
|
-
variables = tslib.__assign(tslib.__assign({}, getDefaultValues(operationDefinition)), variables);
|
|
2547
|
-
var context = {
|
|
2548
|
-
store: store,
|
|
2549
|
-
written: Object.create(null),
|
|
2550
|
-
merge: function (existing, incoming) {
|
|
2551
|
-
return merger.merge(existing, incoming);
|
|
2552
|
-
},
|
|
2553
|
-
variables: variables,
|
|
2554
|
-
varString: canonicalStringify(variables),
|
|
2555
|
-
fragmentMap: createFragmentMap(getFragmentDefinitions(query)),
|
|
2556
|
-
overwrite: !!overwrite,
|
|
2557
|
-
incomingById: new Map,
|
|
2558
|
-
clientOnly: false,
|
|
2559
|
-
};
|
|
2560
|
-
var ref = this.processSelectionSet({
|
|
2561
|
-
result: result || Object.create(null),
|
|
2562
|
-
dataId: dataId,
|
|
2563
|
-
selectionSet: operationDefinition.selectionSet,
|
|
2564
|
-
mergeTree: { map: new Map },
|
|
2565
|
-
context: context,
|
|
2587
|
+
var cacheSlot = new context.Slot();
|
|
2588
|
+
var cacheInfoMap = new WeakMap();
|
|
2589
|
+
function getCacheInfo(cache) {
|
|
2590
|
+
var info = cacheInfoMap.get(cache);
|
|
2591
|
+
if (!info) {
|
|
2592
|
+
cacheInfoMap.set(cache, info = {
|
|
2593
|
+
vars: new Set,
|
|
2594
|
+
dep: optimism.dep(),
|
|
2566
2595
|
});
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
if (isField(selection) && selection.selectionSet) {
|
|
2587
|
-
fieldsWithSelectionSets_1.add(selection.name.value);
|
|
2588
|
-
}
|
|
2589
|
-
});
|
|
2590
|
-
var hasMergeFunction_1 = function (storeFieldName) {
|
|
2591
|
-
var childTree = mergeTree && mergeTree.map.get(storeFieldName);
|
|
2592
|
-
return Boolean(childTree && childTree.info && childTree.info.merge);
|
|
2593
|
-
};
|
|
2594
|
-
Object.keys(fields).forEach(function (storeFieldName) {
|
|
2595
|
-
if (hasSelectionSet_1(storeFieldName) &&
|
|
2596
|
-
!hasMergeFunction_1(storeFieldName)) {
|
|
2597
|
-
warnAboutDataLoss(entityRef, fields, storeFieldName, context.store);
|
|
2598
|
-
}
|
|
2596
|
+
}
|
|
2597
|
+
return info;
|
|
2598
|
+
}
|
|
2599
|
+
function forgetCache(cache) {
|
|
2600
|
+
getCacheInfo(cache).vars.forEach(function (rv) { return rv.forgetCache(cache); });
|
|
2601
|
+
}
|
|
2602
|
+
function recallCache(cache) {
|
|
2603
|
+
getCacheInfo(cache).vars.forEach(function (rv) { return rv.attachCache(cache); });
|
|
2604
|
+
}
|
|
2605
|
+
function makeVar(value) {
|
|
2606
|
+
var caches = new Set();
|
|
2607
|
+
var listeners = new Set();
|
|
2608
|
+
var rv = function (newValue) {
|
|
2609
|
+
if (arguments.length > 0) {
|
|
2610
|
+
if (value !== newValue) {
|
|
2611
|
+
value = newValue;
|
|
2612
|
+
caches.forEach(function (cache) {
|
|
2613
|
+
getCacheInfo(cache).dep.dirty(rv);
|
|
2614
|
+
broadcast(cache);
|
|
2599
2615
|
});
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
store.retain(ref.__ref);
|
|
2604
|
-
return ref;
|
|
2605
|
-
};
|
|
2606
|
-
StoreWriter.prototype.processSelectionSet = function (_a) {
|
|
2607
|
-
var _this = this;
|
|
2608
|
-
var dataId = _a.dataId, result = _a.result, selectionSet = _a.selectionSet, context = _a.context, mergeTree = _a.mergeTree;
|
|
2609
|
-
var policies = this.cache.policies;
|
|
2610
|
-
var _b = policies.identify(result, selectionSet, context.fragmentMap), id = _b[0], keyObject = _b[1];
|
|
2611
|
-
dataId = dataId || id;
|
|
2612
|
-
if ("string" === typeof dataId) {
|
|
2613
|
-
var sets = context.written[dataId] || (context.written[dataId] = []);
|
|
2614
|
-
var ref = makeReference(dataId);
|
|
2615
|
-
if (sets.indexOf(selectionSet) >= 0)
|
|
2616
|
-
return ref;
|
|
2617
|
-
sets.push(selectionSet);
|
|
2618
|
-
if (this.reader && this.reader.isFresh(result, ref, selectionSet, context)) {
|
|
2619
|
-
return ref;
|
|
2616
|
+
var oldListeners = Array.from(listeners);
|
|
2617
|
+
listeners.clear();
|
|
2618
|
+
oldListeners.forEach(function (listener) { return listener(value); });
|
|
2620
2619
|
}
|
|
2621
2620
|
}
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
(dataId && context.store.get(dataId, "__typename"));
|
|
2629
|
-
if ("string" === typeof typename) {
|
|
2630
|
-
incomingFields.__typename = typename;
|
|
2621
|
+
else {
|
|
2622
|
+
var cache = cacheSlot.getValue();
|
|
2623
|
+
if (cache) {
|
|
2624
|
+
attach(cache);
|
|
2625
|
+
getCacheInfo(cache).dep(rv);
|
|
2626
|
+
}
|
|
2631
2627
|
}
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2628
|
+
return value;
|
|
2629
|
+
};
|
|
2630
|
+
rv.onNextChange = function (listener) {
|
|
2631
|
+
listeners.add(listener);
|
|
2632
|
+
return function () {
|
|
2633
|
+
listeners.delete(listener);
|
|
2634
|
+
};
|
|
2635
|
+
};
|
|
2636
|
+
var attach = rv.attachCache = function (cache) {
|
|
2637
|
+
caches.add(cache);
|
|
2638
|
+
getCacheInfo(cache).vars.add(rv);
|
|
2639
|
+
return rv;
|
|
2640
|
+
};
|
|
2641
|
+
rv.forgetCache = function (cache) { return caches.delete(cache); };
|
|
2642
|
+
return rv;
|
|
2643
|
+
}
|
|
2644
|
+
function broadcast(cache) {
|
|
2645
|
+
if (cache.broadcastWatches) {
|
|
2646
|
+
cache.broadcastWatches();
|
|
2647
|
+
}
|
|
2648
|
+
}
|
|
2649
|
+
|
|
2650
|
+
var specifierInfoCache = Object.create(null);
|
|
2651
|
+
function lookupSpecifierInfo(spec) {
|
|
2652
|
+
var cacheKey = JSON.stringify(spec);
|
|
2653
|
+
return specifierInfoCache[cacheKey] ||
|
|
2654
|
+
(specifierInfoCache[cacheKey] = Object.create(null));
|
|
2655
|
+
}
|
|
2656
|
+
function keyFieldsFnFromSpecifier(specifier) {
|
|
2657
|
+
var info = lookupSpecifierInfo(specifier);
|
|
2658
|
+
return info.keyFieldsFn || (info.keyFieldsFn = function (object, context) {
|
|
2659
|
+
var extract = function (from, key) { return context.readField(key, from); };
|
|
2660
|
+
var keyObject = context.keyObject = collectSpecifierPaths(specifier, function (schemaKeyPath) {
|
|
2661
|
+
var extracted = extractKeyPath(context.storeObject, schemaKeyPath, extract);
|
|
2662
|
+
if (extracted === void 0 &&
|
|
2663
|
+
object !== context.storeObject &&
|
|
2664
|
+
hasOwn.call(object, schemaKeyPath[0])) {
|
|
2665
|
+
extracted = extractKeyPath(object, schemaKeyPath, extractKey);
|
|
2666
|
+
}
|
|
2667
|
+
__DEV__ ? tsInvariant.invariant(extracted !== void 0, "Missing field '".concat(schemaKeyPath.join('.'), "' while extracting keyFields from ").concat(JSON.stringify(object))) : tsInvariant.invariant(extracted !== void 0, 2);
|
|
2668
|
+
return extracted;
|
|
2669
|
+
});
|
|
2670
|
+
return "".concat(context.typename, ":").concat(JSON.stringify(keyObject));
|
|
2671
|
+
});
|
|
2672
|
+
}
|
|
2673
|
+
function keyArgsFnFromSpecifier(specifier) {
|
|
2674
|
+
var info = lookupSpecifierInfo(specifier);
|
|
2675
|
+
return info.keyArgsFn || (info.keyArgsFn = function (args, _a) {
|
|
2676
|
+
var field = _a.field, variables = _a.variables, fieldName = _a.fieldName;
|
|
2677
|
+
var collected = collectSpecifierPaths(specifier, function (keyPath) {
|
|
2678
|
+
var firstKey = keyPath[0];
|
|
2679
|
+
var firstChar = firstKey.charAt(0);
|
|
2680
|
+
if (firstChar === "@") {
|
|
2681
|
+
if (field && isNonEmptyArray(field.directives)) {
|
|
2682
|
+
var directiveName_1 = firstKey.slice(1);
|
|
2683
|
+
var d = field.directives.find(function (d) { return d.name.value === directiveName_1; });
|
|
2684
|
+
var directiveArgs = d && argumentsObjectFromField(d, variables);
|
|
2685
|
+
return directiveArgs && extractKeyPath(directiveArgs, keyPath.slice(1));
|
|
2678
2686
|
}
|
|
2679
|
-
|
|
2687
|
+
return;
|
|
2680
2688
|
}
|
|
2681
|
-
|
|
2682
|
-
var
|
|
2683
|
-
if (
|
|
2684
|
-
|
|
2685
|
-
|
|
2689
|
+
if (firstChar === "$") {
|
|
2690
|
+
var variableName = firstKey.slice(1);
|
|
2691
|
+
if (variables && hasOwn.call(variables, variableName)) {
|
|
2692
|
+
var varKeyPath = keyPath.slice(0);
|
|
2693
|
+
varKeyPath[0] = variableName;
|
|
2694
|
+
return extractKeyPath(variables, varKeyPath);
|
|
2686
2695
|
}
|
|
2696
|
+
return;
|
|
2697
|
+
}
|
|
2698
|
+
if (args) {
|
|
2699
|
+
return extractKeyPath(args, keyPath);
|
|
2687
2700
|
}
|
|
2688
2701
|
});
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2702
|
+
var suffix = JSON.stringify(collected);
|
|
2703
|
+
if (args || suffix !== "{}") {
|
|
2704
|
+
fieldName += ":" + suffix;
|
|
2705
|
+
}
|
|
2706
|
+
return fieldName;
|
|
2707
|
+
});
|
|
2708
|
+
}
|
|
2709
|
+
function collectSpecifierPaths(specifier, extractor) {
|
|
2710
|
+
var merger = new DeepMerger;
|
|
2711
|
+
return getSpecifierPaths(specifier).reduce(function (collected, path) {
|
|
2712
|
+
var _a;
|
|
2713
|
+
var toMerge = extractor(path);
|
|
2714
|
+
if (toMerge !== void 0) {
|
|
2715
|
+
for (var i = path.length - 1; i >= 0; --i) {
|
|
2716
|
+
toMerge = (_a = {}, _a[path[i]] = toMerge, _a);
|
|
2717
|
+
}
|
|
2718
|
+
collected = merger.merge(collected, toMerge);
|
|
2719
|
+
}
|
|
2720
|
+
return collected;
|
|
2721
|
+
}, Object.create(null));
|
|
2722
|
+
}
|
|
2723
|
+
function getSpecifierPaths(spec) {
|
|
2724
|
+
var info = lookupSpecifierInfo(spec);
|
|
2725
|
+
if (!info.paths) {
|
|
2726
|
+
var paths_1 = info.paths = [];
|
|
2727
|
+
var currentPath_1 = [];
|
|
2728
|
+
spec.forEach(function (s, i) {
|
|
2729
|
+
if (Array.isArray(s)) {
|
|
2730
|
+
getSpecifierPaths(s).forEach(function (p) { return paths_1.push(currentPath_1.concat(p)); });
|
|
2731
|
+
currentPath_1.length = 0;
|
|
2696
2732
|
}
|
|
2697
2733
|
else {
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
}
|
|
2734
|
+
currentPath_1.push(s);
|
|
2735
|
+
if (!Array.isArray(spec[i + 1])) {
|
|
2736
|
+
paths_1.push(currentPath_1.slice(0));
|
|
2737
|
+
currentPath_1.length = 0;
|
|
2738
|
+
}
|
|
2703
2739
|
}
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2740
|
+
});
|
|
2741
|
+
}
|
|
2742
|
+
return info.paths;
|
|
2743
|
+
}
|
|
2744
|
+
function extractKey(object, key) {
|
|
2745
|
+
return object[key];
|
|
2746
|
+
}
|
|
2747
|
+
function extractKeyPath(object, path, extract) {
|
|
2748
|
+
extract = extract || extractKey;
|
|
2749
|
+
return normalize(path.reduce(function reducer(obj, key) {
|
|
2750
|
+
return Array.isArray(obj)
|
|
2751
|
+
? obj.map(function (child) { return reducer(child, key); })
|
|
2752
|
+
: obj && extract(obj, key);
|
|
2753
|
+
}, object));
|
|
2754
|
+
}
|
|
2755
|
+
function normalize(value) {
|
|
2756
|
+
if (isNonNullObject(value)) {
|
|
2713
2757
|
if (Array.isArray(value)) {
|
|
2714
|
-
return value.map(
|
|
2715
|
-
var value = _this.processFieldValue(item, field, context, getChildMergeTree(mergeTree, i));
|
|
2716
|
-
maybeRecycleChildMergeTree(mergeTree, i);
|
|
2717
|
-
return value;
|
|
2718
|
-
});
|
|
2758
|
+
return value.map(normalize);
|
|
2719
2759
|
}
|
|
2720
|
-
return
|
|
2721
|
-
result: value,
|
|
2722
|
-
selectionSet: field.selectionSet,
|
|
2723
|
-
context: context,
|
|
2724
|
-
mergeTree: mergeTree,
|
|
2725
|
-
});
|
|
2726
|
-
};
|
|
2727
|
-
StoreWriter.prototype.applyMerges = function (mergeTree, existing, incoming, context, getStorageArgs) {
|
|
2728
|
-
var _a;
|
|
2729
|
-
var _this = this;
|
|
2730
|
-
if (mergeTree.map.size && !isReference(incoming)) {
|
|
2731
|
-
var e_1 = (!Array.isArray(incoming) &&
|
|
2732
|
-
(isReference(existing) || storeValueIsStoreObject(existing))) ? existing : void 0;
|
|
2733
|
-
var i_1 = incoming;
|
|
2734
|
-
if (e_1 && !getStorageArgs) {
|
|
2735
|
-
getStorageArgs = [isReference(e_1) ? e_1.__ref : e_1];
|
|
2736
|
-
}
|
|
2737
|
-
var changedFields_1;
|
|
2738
|
-
var getValue_1 = function (from, name) {
|
|
2739
|
-
return Array.isArray(from)
|
|
2740
|
-
? (typeof name === "number" ? from[name] : void 0)
|
|
2741
|
-
: context.store.getFieldValue(from, String(name));
|
|
2742
|
-
};
|
|
2743
|
-
mergeTree.map.forEach(function (childTree, storeFieldName) {
|
|
2744
|
-
var eVal = getValue_1(e_1, storeFieldName);
|
|
2745
|
-
var iVal = getValue_1(i_1, storeFieldName);
|
|
2746
|
-
if (void 0 === iVal)
|
|
2747
|
-
return;
|
|
2748
|
-
if (getStorageArgs) {
|
|
2749
|
-
getStorageArgs.push(storeFieldName);
|
|
2750
|
-
}
|
|
2751
|
-
var aVal = _this.applyMerges(childTree, eVal, iVal, context, getStorageArgs);
|
|
2752
|
-
if (aVal !== iVal) {
|
|
2753
|
-
changedFields_1 = changedFields_1 || new Map;
|
|
2754
|
-
changedFields_1.set(storeFieldName, aVal);
|
|
2755
|
-
}
|
|
2756
|
-
if (getStorageArgs) {
|
|
2757
|
-
tsInvariant.invariant(getStorageArgs.pop() === storeFieldName);
|
|
2758
|
-
}
|
|
2759
|
-
});
|
|
2760
|
-
if (changedFields_1) {
|
|
2761
|
-
incoming = (Array.isArray(i_1) ? i_1.slice(0) : tslib.__assign({}, i_1));
|
|
2762
|
-
changedFields_1.forEach(function (value, name) {
|
|
2763
|
-
incoming[name] = value;
|
|
2764
|
-
});
|
|
2765
|
-
}
|
|
2766
|
-
}
|
|
2767
|
-
if (mergeTree.info) {
|
|
2768
|
-
return this.cache.policies.runMergeFunction(existing, incoming, mergeTree.info, context, getStorageArgs && (_a = context.store).getStorage.apply(_a, getStorageArgs));
|
|
2769
|
-
}
|
|
2770
|
-
return incoming;
|
|
2771
|
-
};
|
|
2772
|
-
return StoreWriter;
|
|
2773
|
-
}());
|
|
2774
|
-
var emptyMergeTreePool = [];
|
|
2775
|
-
function getChildMergeTree(_a, name) {
|
|
2776
|
-
var map = _a.map;
|
|
2777
|
-
if (!map.has(name)) {
|
|
2778
|
-
map.set(name, emptyMergeTreePool.pop() || { map: new Map });
|
|
2779
|
-
}
|
|
2780
|
-
return map.get(name);
|
|
2781
|
-
}
|
|
2782
|
-
function mergeMergeTrees(left, right) {
|
|
2783
|
-
if (left === right || !right || mergeTreeIsEmpty(right))
|
|
2784
|
-
return left;
|
|
2785
|
-
if (!left || mergeTreeIsEmpty(left))
|
|
2786
|
-
return right;
|
|
2787
|
-
var info = left.info && right.info ? tslib.__assign(tslib.__assign({}, left.info), right.info) : left.info || right.info;
|
|
2788
|
-
var needToMergeMaps = left.map.size && right.map.size;
|
|
2789
|
-
var map = needToMergeMaps ? new Map :
|
|
2790
|
-
left.map.size ? left.map : right.map;
|
|
2791
|
-
var merged = { info: info, map: map };
|
|
2792
|
-
if (needToMergeMaps) {
|
|
2793
|
-
var remainingRightKeys_1 = new Set(right.map.keys());
|
|
2794
|
-
left.map.forEach(function (leftTree, key) {
|
|
2795
|
-
merged.map.set(key, mergeMergeTrees(leftTree, right.map.get(key)));
|
|
2796
|
-
remainingRightKeys_1.delete(key);
|
|
2797
|
-
});
|
|
2798
|
-
remainingRightKeys_1.forEach(function (key) {
|
|
2799
|
-
merged.map.set(key, mergeMergeTrees(right.map.get(key), left.map.get(key)));
|
|
2800
|
-
});
|
|
2801
|
-
}
|
|
2802
|
-
return merged;
|
|
2803
|
-
}
|
|
2804
|
-
function mergeTreeIsEmpty(tree) {
|
|
2805
|
-
return !tree || !(tree.info || tree.map.size);
|
|
2806
|
-
}
|
|
2807
|
-
function maybeRecycleChildMergeTree(_a, name) {
|
|
2808
|
-
var map = _a.map;
|
|
2809
|
-
var childTree = map.get(name);
|
|
2810
|
-
if (childTree && mergeTreeIsEmpty(childTree)) {
|
|
2811
|
-
emptyMergeTreePool.push(childTree);
|
|
2812
|
-
map.delete(name);
|
|
2813
|
-
}
|
|
2814
|
-
}
|
|
2815
|
-
var warnings = new Set();
|
|
2816
|
-
function warnAboutDataLoss(existingRef, incomingObj, storeFieldName, store) {
|
|
2817
|
-
var getChild = function (objOrRef) {
|
|
2818
|
-
var child = store.getFieldValue(objOrRef, storeFieldName);
|
|
2819
|
-
return typeof child === "object" && child;
|
|
2820
|
-
};
|
|
2821
|
-
var existing = getChild(existingRef);
|
|
2822
|
-
if (!existing)
|
|
2823
|
-
return;
|
|
2824
|
-
var incoming = getChild(incomingObj);
|
|
2825
|
-
if (!incoming)
|
|
2826
|
-
return;
|
|
2827
|
-
if (isReference(existing))
|
|
2828
|
-
return;
|
|
2829
|
-
if (equality.equal(existing, incoming))
|
|
2830
|
-
return;
|
|
2831
|
-
if (Object.keys(existing).every(function (key) { return store.getFieldValue(incoming, key) !== void 0; })) {
|
|
2832
|
-
return;
|
|
2833
|
-
}
|
|
2834
|
-
var parentType = store.getFieldValue(existingRef, "__typename") ||
|
|
2835
|
-
store.getFieldValue(incomingObj, "__typename");
|
|
2836
|
-
var fieldName = fieldNameFromStoreName(storeFieldName);
|
|
2837
|
-
var typeDotName = parentType + "." + fieldName;
|
|
2838
|
-
if (warnings.has(typeDotName))
|
|
2839
|
-
return;
|
|
2840
|
-
warnings.add(typeDotName);
|
|
2841
|
-
var childTypenames = [];
|
|
2842
|
-
if (!Array.isArray(existing) &&
|
|
2843
|
-
!Array.isArray(incoming)) {
|
|
2844
|
-
[existing, incoming].forEach(function (child) {
|
|
2845
|
-
var typename = store.getFieldValue(child, "__typename");
|
|
2846
|
-
if (typeof typename === "string" &&
|
|
2847
|
-
!childTypenames.includes(typename)) {
|
|
2848
|
-
childTypenames.push(typename);
|
|
2849
|
-
}
|
|
2850
|
-
});
|
|
2851
|
-
}
|
|
2852
|
-
__DEV__ && tsInvariant.invariant.warn("Cache data may be lost when replacing the " + fieldName + " field of a " + parentType + " object.\n\nTo address this problem (which is not a bug in Apollo Client), " + (childTypenames.length
|
|
2853
|
-
? "either ensure all objects of type " +
|
|
2854
|
-
childTypenames.join(" and ") + " have an ID or a custom merge function, or "
|
|
2855
|
-
: "") + "define a custom merge function for the " + typeDotName + " field, so InMemoryCache can safely merge these objects:\n\n existing: " + JSON.stringify(existing).slice(0, 1000) + "\n incoming: " + JSON.stringify(incoming).slice(0, 1000) + "\n\nFor more information about these options, please refer to the documentation:\n\n * Ensuring entity objects have IDs: https://go.apollo.dev/c/generating-unique-identifiers\n * Defining custom merge functions: https://go.apollo.dev/c/merging-non-normalized-objects\n");
|
|
2856
|
-
}
|
|
2857
|
-
|
|
2858
|
-
var cacheSlot = new context.Slot();
|
|
2859
|
-
var cacheInfoMap = new WeakMap();
|
|
2860
|
-
function getCacheInfo(cache) {
|
|
2861
|
-
var info = cacheInfoMap.get(cache);
|
|
2862
|
-
if (!info) {
|
|
2863
|
-
cacheInfoMap.set(cache, info = {
|
|
2864
|
-
vars: new Set,
|
|
2865
|
-
dep: optimism.dep(),
|
|
2866
|
-
});
|
|
2867
|
-
}
|
|
2868
|
-
return info;
|
|
2869
|
-
}
|
|
2870
|
-
function forgetCache(cache) {
|
|
2871
|
-
getCacheInfo(cache).vars.forEach(function (rv) { return rv.forgetCache(cache); });
|
|
2872
|
-
}
|
|
2873
|
-
function recallCache(cache) {
|
|
2874
|
-
getCacheInfo(cache).vars.forEach(function (rv) { return rv.attachCache(cache); });
|
|
2875
|
-
}
|
|
2876
|
-
function makeVar(value) {
|
|
2877
|
-
var caches = new Set();
|
|
2878
|
-
var listeners = new Set();
|
|
2879
|
-
var rv = function (newValue) {
|
|
2880
|
-
if (arguments.length > 0) {
|
|
2881
|
-
if (value !== newValue) {
|
|
2882
|
-
value = newValue;
|
|
2883
|
-
caches.forEach(function (cache) {
|
|
2884
|
-
getCacheInfo(cache).dep.dirty(rv);
|
|
2885
|
-
broadcast(cache);
|
|
2886
|
-
});
|
|
2887
|
-
var oldListeners = Array.from(listeners);
|
|
2888
|
-
listeners.clear();
|
|
2889
|
-
oldListeners.forEach(function (listener) { return listener(value); });
|
|
2890
|
-
}
|
|
2891
|
-
}
|
|
2892
|
-
else {
|
|
2893
|
-
var cache = cacheSlot.getValue();
|
|
2894
|
-
if (cache) {
|
|
2895
|
-
attach(cache);
|
|
2896
|
-
getCacheInfo(cache).dep(rv);
|
|
2897
|
-
}
|
|
2898
|
-
}
|
|
2899
|
-
return value;
|
|
2900
|
-
};
|
|
2901
|
-
rv.onNextChange = function (listener) {
|
|
2902
|
-
listeners.add(listener);
|
|
2903
|
-
return function () {
|
|
2904
|
-
listeners.delete(listener);
|
|
2905
|
-
};
|
|
2906
|
-
};
|
|
2907
|
-
var attach = rv.attachCache = function (cache) {
|
|
2908
|
-
caches.add(cache);
|
|
2909
|
-
getCacheInfo(cache).vars.add(rv);
|
|
2910
|
-
return rv;
|
|
2911
|
-
};
|
|
2912
|
-
rv.forgetCache = function (cache) { return caches.delete(cache); };
|
|
2913
|
-
return rv;
|
|
2914
|
-
}
|
|
2915
|
-
function broadcast(cache) {
|
|
2916
|
-
if (cache.broadcastWatches) {
|
|
2917
|
-
cache.broadcastWatches();
|
|
2760
|
+
return collectSpecifierPaths(Object.keys(value).sort(), function (path) { return extractKeyPath(value, path); });
|
|
2918
2761
|
}
|
|
2762
|
+
return value;
|
|
2919
2763
|
}
|
|
2920
2764
|
|
|
2921
2765
|
getStoreKeyName.setStringify(canonicalStringify);
|
|
@@ -2952,18 +2796,22 @@ var Policies = (function () {
|
|
|
2952
2796
|
this.addTypePolicies(config.typePolicies);
|
|
2953
2797
|
}
|
|
2954
2798
|
}
|
|
2955
|
-
Policies.prototype.identify = function (object,
|
|
2956
|
-
var
|
|
2957
|
-
|
|
2958
|
-
|
|
2799
|
+
Policies.prototype.identify = function (object, partialContext) {
|
|
2800
|
+
var _a;
|
|
2801
|
+
var policies = this;
|
|
2802
|
+
var typename = partialContext && (partialContext.typename ||
|
|
2803
|
+
((_a = partialContext.storeObject) === null || _a === void 0 ? void 0 : _a.__typename)) || object.__typename;
|
|
2959
2804
|
if (typename === this.rootTypenamesById.ROOT_QUERY) {
|
|
2960
2805
|
return ["ROOT_QUERY"];
|
|
2961
2806
|
}
|
|
2962
|
-
var
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2807
|
+
var storeObject = partialContext && partialContext.storeObject || object;
|
|
2808
|
+
var context = tslib.__assign(tslib.__assign({}, partialContext), { typename: typename, storeObject: storeObject, readField: partialContext && partialContext.readField || function () {
|
|
2809
|
+
var options = normalizeReadFieldOptions(arguments, storeObject);
|
|
2810
|
+
return policies.readField(options, {
|
|
2811
|
+
store: policies.cache["data"],
|
|
2812
|
+
variables: options.variables,
|
|
2813
|
+
});
|
|
2814
|
+
} });
|
|
2967
2815
|
var id;
|
|
2968
2816
|
var policy = typename && this.getTypePolicy(typename);
|
|
2969
2817
|
var keyFn = policy && policy.keyFn || this.config.dataIdFromObject;
|
|
@@ -3045,7 +2893,7 @@ var Policies = (function () {
|
|
|
3045
2893
|
var rootId = "ROOT_" + which.toUpperCase();
|
|
3046
2894
|
var old = this.rootTypenamesById[rootId];
|
|
3047
2895
|
if (typename !== old) {
|
|
3048
|
-
__DEV__ ? tsInvariant.invariant(!old || old === which, "Cannot change root "
|
|
2896
|
+
__DEV__ ? tsInvariant.invariant(!old || old === which, "Cannot change root ".concat(which, " __typename more than once")) : tsInvariant.invariant(!old || old === which, 3);
|
|
3049
2897
|
if (old)
|
|
3050
2898
|
delete this.rootIdsByTypename[old];
|
|
3051
2899
|
this.rootIdsByTypename[typename] = rootId;
|
|
@@ -3129,7 +2977,7 @@ var Policies = (function () {
|
|
|
3129
2977
|
if (supertypeSet.has(supertype)) {
|
|
3130
2978
|
if (!typenameSupertypeSet.has(supertype)) {
|
|
3131
2979
|
if (checkingFuzzySubtypes) {
|
|
3132
|
-
__DEV__ && tsInvariant.invariant.warn("Inferring subtype "
|
|
2980
|
+
__DEV__ && tsInvariant.invariant.warn("Inferring subtype ".concat(typename, " of supertype ").concat(supertype));
|
|
3133
2981
|
}
|
|
3134
2982
|
typenameSupertypeSet.add(supertype);
|
|
3135
2983
|
}
|
|
@@ -3217,6 +3065,10 @@ var Policies = (function () {
|
|
|
3217
3065
|
}
|
|
3218
3066
|
return existing;
|
|
3219
3067
|
};
|
|
3068
|
+
Policies.prototype.getReadFunction = function (typename, fieldName) {
|
|
3069
|
+
var policy = this.getFieldPolicy(typename, fieldName, false);
|
|
3070
|
+
return policy && policy.read;
|
|
3071
|
+
};
|
|
3220
3072
|
Policies.prototype.getMergeFunction = function (parentTypename, fieldName, childTypename) {
|
|
3221
3073
|
var policy = this.getFieldPolicy(parentTypename, fieldName, false);
|
|
3222
3074
|
var merge = policy && policy.merge;
|
|
@@ -3257,39 +3109,39 @@ function makeFieldFunctionOptions(policies, objectOrReference, fieldSpec, contex
|
|
|
3257
3109
|
storage: storage,
|
|
3258
3110
|
cache: policies.cache,
|
|
3259
3111
|
canRead: canRead,
|
|
3260
|
-
readField: function (
|
|
3261
|
-
|
|
3262
|
-
if (typeof fieldNameOrOptions === "string") {
|
|
3263
|
-
options = {
|
|
3264
|
-
fieldName: fieldNameOrOptions,
|
|
3265
|
-
from: arguments.length > 1 ? from : objectOrReference,
|
|
3266
|
-
};
|
|
3267
|
-
}
|
|
3268
|
-
else if (isNonNullObject(fieldNameOrOptions)) {
|
|
3269
|
-
options = tslib.__assign({}, fieldNameOrOptions);
|
|
3270
|
-
if (!hasOwn.call(fieldNameOrOptions, "from")) {
|
|
3271
|
-
options.from = objectOrReference;
|
|
3272
|
-
}
|
|
3273
|
-
}
|
|
3274
|
-
else {
|
|
3275
|
-
__DEV__ && tsInvariant.invariant.warn("Unexpected readField arguments: " + stringifyForDisplay(Array.from(arguments)));
|
|
3276
|
-
return;
|
|
3277
|
-
}
|
|
3278
|
-
if (__DEV__ && options.from === void 0) {
|
|
3279
|
-
__DEV__ && tsInvariant.invariant.warn("Undefined 'from' passed to readField with arguments " + stringifyForDisplay(Array.from(arguments)));
|
|
3280
|
-
}
|
|
3281
|
-
if (void 0 === options.variables) {
|
|
3282
|
-
options.variables = variables;
|
|
3283
|
-
}
|
|
3284
|
-
return policies.readField(options, context);
|
|
3112
|
+
readField: function () {
|
|
3113
|
+
return policies.readField(normalizeReadFieldOptions(arguments, objectOrReference, context), context);
|
|
3285
3114
|
},
|
|
3286
3115
|
mergeObjects: makeMergeObjectsFunction(context.store),
|
|
3287
3116
|
};
|
|
3288
3117
|
}
|
|
3118
|
+
function normalizeReadFieldOptions(readFieldArgs, objectOrReference, variables) {
|
|
3119
|
+
var fieldNameOrOptions = readFieldArgs[0], from = readFieldArgs[1], argc = readFieldArgs.length;
|
|
3120
|
+
var options;
|
|
3121
|
+
if (typeof fieldNameOrOptions === "string") {
|
|
3122
|
+
options = {
|
|
3123
|
+
fieldName: fieldNameOrOptions,
|
|
3124
|
+
from: argc > 1 ? from : objectOrReference,
|
|
3125
|
+
};
|
|
3126
|
+
}
|
|
3127
|
+
else {
|
|
3128
|
+
options = tslib.__assign({}, fieldNameOrOptions);
|
|
3129
|
+
if (!hasOwn.call(options, "from")) {
|
|
3130
|
+
options.from = objectOrReference;
|
|
3131
|
+
}
|
|
3132
|
+
}
|
|
3133
|
+
if (__DEV__ && options.from === void 0) {
|
|
3134
|
+
__DEV__ && tsInvariant.invariant.warn("Undefined 'from' passed to readField with arguments ".concat(stringifyForDisplay(Array.from(readFieldArgs))));
|
|
3135
|
+
}
|
|
3136
|
+
if (void 0 === options.variables) {
|
|
3137
|
+
options.variables = variables;
|
|
3138
|
+
}
|
|
3139
|
+
return options;
|
|
3140
|
+
}
|
|
3289
3141
|
function makeMergeObjectsFunction(store) {
|
|
3290
3142
|
return function mergeObjects(existing, incoming) {
|
|
3291
3143
|
if (Array.isArray(existing) || Array.isArray(incoming)) {
|
|
3292
|
-
throw __DEV__ ? new tsInvariant.InvariantError("Cannot automatically merge arrays") : new tsInvariant.InvariantError(
|
|
3144
|
+
throw __DEV__ ? new tsInvariant.InvariantError("Cannot automatically merge arrays") : new tsInvariant.InvariantError(4);
|
|
3293
3145
|
}
|
|
3294
3146
|
if (isNonNullObject(existing) &&
|
|
3295
3147
|
isNonNullObject(incoming)) {
|
|
@@ -3317,84 +3169,396 @@ function makeMergeObjectsFunction(store) {
|
|
|
3317
3169
|
return incoming;
|
|
3318
3170
|
};
|
|
3319
3171
|
}
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3172
|
+
|
|
3173
|
+
function getContextFlavor(context, clientOnly, deferred) {
|
|
3174
|
+
var key = "".concat(clientOnly).concat(deferred);
|
|
3175
|
+
var flavored = context.flavors.get(key);
|
|
3176
|
+
if (!flavored) {
|
|
3177
|
+
context.flavors.set(key, flavored = (context.clientOnly === clientOnly &&
|
|
3178
|
+
context.deferred === deferred) ? context : tslib.__assign(tslib.__assign({}, context), { clientOnly: clientOnly, deferred: deferred }));
|
|
3179
|
+
}
|
|
3180
|
+
return flavored;
|
|
3324
3181
|
}
|
|
3325
|
-
function
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3182
|
+
var StoreWriter = (function () {
|
|
3183
|
+
function StoreWriter(cache, reader) {
|
|
3184
|
+
this.cache = cache;
|
|
3185
|
+
this.reader = reader;
|
|
3186
|
+
}
|
|
3187
|
+
StoreWriter.prototype.writeToStore = function (store, _a) {
|
|
3188
|
+
var _this = this;
|
|
3189
|
+
var query = _a.query, result = _a.result, dataId = _a.dataId, variables = _a.variables, overwrite = _a.overwrite;
|
|
3190
|
+
var operationDefinition = getOperationDefinition(query);
|
|
3191
|
+
var merger = makeProcessedFieldsMerger();
|
|
3192
|
+
variables = tslib.__assign(tslib.__assign({}, getDefaultValues(operationDefinition)), variables);
|
|
3193
|
+
var context = {
|
|
3194
|
+
store: store,
|
|
3195
|
+
written: Object.create(null),
|
|
3196
|
+
merge: function (existing, incoming) {
|
|
3197
|
+
return merger.merge(existing, incoming);
|
|
3198
|
+
},
|
|
3199
|
+
variables: variables,
|
|
3200
|
+
varString: canonicalStringify(variables),
|
|
3201
|
+
fragmentMap: createFragmentMap(getFragmentDefinitions(query)),
|
|
3202
|
+
overwrite: !!overwrite,
|
|
3203
|
+
incomingById: new Map,
|
|
3204
|
+
clientOnly: false,
|
|
3205
|
+
deferred: false,
|
|
3206
|
+
flavors: new Map,
|
|
3207
|
+
};
|
|
3208
|
+
var ref = this.processSelectionSet({
|
|
3209
|
+
result: result || Object.create(null),
|
|
3210
|
+
dataId: dataId,
|
|
3211
|
+
selectionSet: operationDefinition.selectionSet,
|
|
3212
|
+
mergeTree: { map: new Map },
|
|
3213
|
+
context: context,
|
|
3214
|
+
});
|
|
3215
|
+
if (!isReference(ref)) {
|
|
3216
|
+
throw __DEV__ ? new tsInvariant.InvariantError("Could not identify object ".concat(JSON.stringify(result))) : new tsInvariant.InvariantError(6);
|
|
3335
3217
|
}
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3218
|
+
context.incomingById.forEach(function (_a, dataId) {
|
|
3219
|
+
var storeObject = _a.storeObject, mergeTree = _a.mergeTree, fieldNodeSet = _a.fieldNodeSet;
|
|
3220
|
+
var entityRef = makeReference(dataId);
|
|
3221
|
+
if (mergeTree && mergeTree.map.size) {
|
|
3222
|
+
var applied = _this.applyMerges(mergeTree, entityRef, storeObject, context);
|
|
3223
|
+
if (isReference(applied)) {
|
|
3224
|
+
return;
|
|
3225
|
+
}
|
|
3226
|
+
storeObject = applied;
|
|
3227
|
+
}
|
|
3228
|
+
if (__DEV__ && !context.overwrite) {
|
|
3229
|
+
var fieldsWithSelectionSets_1 = Object.create(null);
|
|
3230
|
+
fieldNodeSet.forEach(function (field) {
|
|
3231
|
+
if (field.selectionSet) {
|
|
3232
|
+
fieldsWithSelectionSets_1[field.name.value] = true;
|
|
3233
|
+
}
|
|
3234
|
+
});
|
|
3235
|
+
var hasSelectionSet_1 = function (storeFieldName) {
|
|
3236
|
+
return fieldsWithSelectionSets_1[fieldNameFromStoreName(storeFieldName)] === true;
|
|
3237
|
+
};
|
|
3238
|
+
var hasMergeFunction_1 = function (storeFieldName) {
|
|
3239
|
+
var childTree = mergeTree && mergeTree.map.get(storeFieldName);
|
|
3240
|
+
return Boolean(childTree && childTree.info && childTree.info.merge);
|
|
3241
|
+
};
|
|
3242
|
+
Object.keys(storeObject).forEach(function (storeFieldName) {
|
|
3243
|
+
if (hasSelectionSet_1(storeFieldName) &&
|
|
3244
|
+
!hasMergeFunction_1(storeFieldName)) {
|
|
3245
|
+
warnAboutDataLoss(entityRef, storeObject, storeFieldName, context.store);
|
|
3246
|
+
}
|
|
3247
|
+
});
|
|
3248
|
+
}
|
|
3249
|
+
store.merge(dataId, storeObject);
|
|
3250
|
+
});
|
|
3251
|
+
store.retain(ref.__ref);
|
|
3252
|
+
return ref;
|
|
3339
3253
|
};
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3254
|
+
StoreWriter.prototype.processSelectionSet = function (_a) {
|
|
3255
|
+
var _this = this;
|
|
3256
|
+
var dataId = _a.dataId, result = _a.result, selectionSet = _a.selectionSet, context = _a.context, mergeTree = _a.mergeTree;
|
|
3257
|
+
var policies = this.cache.policies;
|
|
3258
|
+
var incoming = Object.create(null);
|
|
3259
|
+
var typename = (dataId && policies.rootTypenamesById[dataId]) ||
|
|
3260
|
+
getTypenameFromResult(result, selectionSet, context.fragmentMap) ||
|
|
3261
|
+
(dataId && context.store.get(dataId, "__typename"));
|
|
3262
|
+
if ("string" === typeof typename) {
|
|
3263
|
+
incoming.__typename = typename;
|
|
3264
|
+
}
|
|
3265
|
+
var readField = function () {
|
|
3266
|
+
var options = normalizeReadFieldOptions(arguments, incoming, context.variables);
|
|
3267
|
+
if (isReference(options.from)) {
|
|
3268
|
+
var info = context.incomingById.get(options.from.__ref);
|
|
3269
|
+
if (info) {
|
|
3270
|
+
var result_1 = policies.readField(tslib.__assign(tslib.__assign({}, options), { from: info.storeObject }), context);
|
|
3271
|
+
if (result_1 !== void 0) {
|
|
3272
|
+
return result_1;
|
|
3353
3273
|
}
|
|
3354
3274
|
}
|
|
3355
|
-
if (selection.selectionSet) {
|
|
3356
|
-
var subsets = map.subsets || (map.subsets = Object.create(null));
|
|
3357
|
-
subsets[selection.name.value] =
|
|
3358
|
-
makeAliasMap(selection.selectionSet, fragmentMap);
|
|
3359
|
-
}
|
|
3360
3275
|
}
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3276
|
+
return policies.readField(options, context);
|
|
3277
|
+
};
|
|
3278
|
+
var fieldNodeSet = new Set();
|
|
3279
|
+
this.flattenFields(selectionSet, result, context, typename).forEach(function (context, field) {
|
|
3280
|
+
var _a;
|
|
3281
|
+
var resultFieldKey = resultKeyNameFromField(field);
|
|
3282
|
+
var value = result[resultFieldKey];
|
|
3283
|
+
fieldNodeSet.add(field);
|
|
3284
|
+
if (value !== void 0) {
|
|
3285
|
+
var storeFieldName = policies.getStoreFieldName({
|
|
3286
|
+
typename: typename,
|
|
3287
|
+
fieldName: field.name.value,
|
|
3288
|
+
field: field,
|
|
3289
|
+
variables: context.variables,
|
|
3290
|
+
});
|
|
3291
|
+
var childTree = getChildMergeTree(mergeTree, storeFieldName);
|
|
3292
|
+
var incomingValue = _this.processFieldValue(value, field, field.selectionSet
|
|
3293
|
+
? getContextFlavor(context, false, false)
|
|
3294
|
+
: context, childTree);
|
|
3295
|
+
var childTypename = void 0;
|
|
3296
|
+
if (field.selectionSet &&
|
|
3297
|
+
(isReference(incomingValue) ||
|
|
3298
|
+
storeValueIsStoreObject(incomingValue))) {
|
|
3299
|
+
childTypename = readField("__typename", incomingValue);
|
|
3365
3300
|
}
|
|
3301
|
+
var merge = policies.getMergeFunction(typename, field.name.value, childTypename);
|
|
3302
|
+
if (merge) {
|
|
3303
|
+
childTree.info = {
|
|
3304
|
+
field: field,
|
|
3305
|
+
typename: typename,
|
|
3306
|
+
merge: merge,
|
|
3307
|
+
};
|
|
3308
|
+
}
|
|
3309
|
+
else {
|
|
3310
|
+
maybeRecycleChildMergeTree(mergeTree, storeFieldName);
|
|
3311
|
+
}
|
|
3312
|
+
incoming = context.merge(incoming, (_a = {},
|
|
3313
|
+
_a[storeFieldName] = incomingValue,
|
|
3314
|
+
_a));
|
|
3315
|
+
}
|
|
3316
|
+
else if (__DEV__ &&
|
|
3317
|
+
!context.clientOnly &&
|
|
3318
|
+
!context.deferred &&
|
|
3319
|
+
!addTypenameToDocument.added(field) &&
|
|
3320
|
+
!policies.getReadFunction(typename, field.name.value)) {
|
|
3321
|
+
__DEV__ && tsInvariant.invariant.error("Missing field '".concat(resultKeyNameFromField(field), "' while writing result ").concat(JSON.stringify(result, null, 2)).substring(0, 1000));
|
|
3366
3322
|
}
|
|
3367
3323
|
});
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
if (
|
|
3378
|
-
|
|
3379
|
-
var subsets = aliasMap && aliasMap.subsets;
|
|
3380
|
-
var subset = subsets && subsets[lastActualKey];
|
|
3381
|
-
keyObj[lastActualKey] =
|
|
3382
|
-
computeKeyObject(response[lastResponseKey], s, strict, subset);
|
|
3324
|
+
try {
|
|
3325
|
+
var _b = policies.identify(result, {
|
|
3326
|
+
typename: typename,
|
|
3327
|
+
selectionSet: selectionSet,
|
|
3328
|
+
fragmentMap: context.fragmentMap,
|
|
3329
|
+
storeObject: incoming,
|
|
3330
|
+
readField: readField,
|
|
3331
|
+
}), id = _b[0], keyObject = _b[1];
|
|
3332
|
+
dataId = dataId || id;
|
|
3333
|
+
if (keyObject) {
|
|
3334
|
+
incoming = context.merge(incoming, keyObject);
|
|
3383
3335
|
}
|
|
3384
3336
|
}
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3337
|
+
catch (e) {
|
|
3338
|
+
if (!dataId)
|
|
3339
|
+
throw e;
|
|
3340
|
+
}
|
|
3341
|
+
if ("string" === typeof dataId) {
|
|
3342
|
+
var dataRef = makeReference(dataId);
|
|
3343
|
+
var sets = context.written[dataId] || (context.written[dataId] = []);
|
|
3344
|
+
if (sets.indexOf(selectionSet) >= 0)
|
|
3345
|
+
return dataRef;
|
|
3346
|
+
sets.push(selectionSet);
|
|
3347
|
+
if (this.reader && this.reader.isFresh(result, dataRef, selectionSet, context)) {
|
|
3348
|
+
return dataRef;
|
|
3349
|
+
}
|
|
3350
|
+
var previous_1 = context.incomingById.get(dataId);
|
|
3351
|
+
if (previous_1) {
|
|
3352
|
+
previous_1.storeObject = context.merge(previous_1.storeObject, incoming);
|
|
3353
|
+
previous_1.mergeTree = mergeMergeTrees(previous_1.mergeTree, mergeTree);
|
|
3354
|
+
fieldNodeSet.forEach(function (field) { return previous_1.fieldNodeSet.add(field); });
|
|
3390
3355
|
}
|
|
3391
3356
|
else {
|
|
3392
|
-
|
|
3393
|
-
|
|
3357
|
+
context.incomingById.set(dataId, {
|
|
3358
|
+
storeObject: incoming,
|
|
3359
|
+
mergeTree: mergeTreeIsEmpty(mergeTree) ? void 0 : mergeTree,
|
|
3360
|
+
fieldNodeSet: fieldNodeSet,
|
|
3361
|
+
});
|
|
3394
3362
|
}
|
|
3363
|
+
return dataRef;
|
|
3395
3364
|
}
|
|
3396
|
-
|
|
3397
|
-
|
|
3365
|
+
return incoming;
|
|
3366
|
+
};
|
|
3367
|
+
StoreWriter.prototype.processFieldValue = function (value, field, context, mergeTree) {
|
|
3368
|
+
var _this = this;
|
|
3369
|
+
if (!field.selectionSet || value === null) {
|
|
3370
|
+
return __DEV__ ? cloneDeep(value) : value;
|
|
3371
|
+
}
|
|
3372
|
+
if (Array.isArray(value)) {
|
|
3373
|
+
return value.map(function (item, i) {
|
|
3374
|
+
var value = _this.processFieldValue(item, field, context, getChildMergeTree(mergeTree, i));
|
|
3375
|
+
maybeRecycleChildMergeTree(mergeTree, i);
|
|
3376
|
+
return value;
|
|
3377
|
+
});
|
|
3378
|
+
}
|
|
3379
|
+
return this.processSelectionSet({
|
|
3380
|
+
result: value,
|
|
3381
|
+
selectionSet: field.selectionSet,
|
|
3382
|
+
context: context,
|
|
3383
|
+
mergeTree: mergeTree,
|
|
3384
|
+
});
|
|
3385
|
+
};
|
|
3386
|
+
StoreWriter.prototype.flattenFields = function (selectionSet, result, context, typename) {
|
|
3387
|
+
if (typename === void 0) { typename = getTypenameFromResult(result, selectionSet, context.fragmentMap); }
|
|
3388
|
+
var fieldMap = new Map();
|
|
3389
|
+
var policies = this.cache.policies;
|
|
3390
|
+
var limitingTrie = new trie.Trie(false);
|
|
3391
|
+
(function flatten(selectionSet, inheritedContext) {
|
|
3392
|
+
var visitedNode = limitingTrie.lookup(selectionSet, inheritedContext.clientOnly, inheritedContext.deferred);
|
|
3393
|
+
if (visitedNode.visited)
|
|
3394
|
+
return;
|
|
3395
|
+
visitedNode.visited = true;
|
|
3396
|
+
selectionSet.selections.forEach(function (selection) {
|
|
3397
|
+
if (!shouldInclude(selection, context.variables))
|
|
3398
|
+
return;
|
|
3399
|
+
var clientOnly = inheritedContext.clientOnly, deferred = inheritedContext.deferred;
|
|
3400
|
+
if (!(clientOnly && deferred) &&
|
|
3401
|
+
isNonEmptyArray(selection.directives)) {
|
|
3402
|
+
selection.directives.forEach(function (dir) {
|
|
3403
|
+
var name = dir.name.value;
|
|
3404
|
+
if (name === "client")
|
|
3405
|
+
clientOnly = true;
|
|
3406
|
+
if (name === "defer") {
|
|
3407
|
+
var args = argumentsObjectFromField(dir, context.variables);
|
|
3408
|
+
if (!args || args.if !== false) {
|
|
3409
|
+
deferred = true;
|
|
3410
|
+
}
|
|
3411
|
+
}
|
|
3412
|
+
});
|
|
3413
|
+
}
|
|
3414
|
+
if (isField(selection)) {
|
|
3415
|
+
var existing = fieldMap.get(selection);
|
|
3416
|
+
if (existing) {
|
|
3417
|
+
clientOnly = clientOnly && existing.clientOnly;
|
|
3418
|
+
deferred = deferred && existing.deferred;
|
|
3419
|
+
}
|
|
3420
|
+
fieldMap.set(selection, getContextFlavor(context, clientOnly, deferred));
|
|
3421
|
+
}
|
|
3422
|
+
else {
|
|
3423
|
+
var fragment = getFragmentFromSelection(selection, context.fragmentMap);
|
|
3424
|
+
if (fragment &&
|
|
3425
|
+
policies.fragmentMatches(fragment, typename, result, context.variables)) {
|
|
3426
|
+
flatten(fragment.selectionSet, getContextFlavor(context, clientOnly, deferred));
|
|
3427
|
+
}
|
|
3428
|
+
}
|
|
3429
|
+
});
|
|
3430
|
+
})(selectionSet, context);
|
|
3431
|
+
return fieldMap;
|
|
3432
|
+
};
|
|
3433
|
+
StoreWriter.prototype.applyMerges = function (mergeTree, existing, incoming, context, getStorageArgs) {
|
|
3434
|
+
var _a;
|
|
3435
|
+
var _this = this;
|
|
3436
|
+
if (mergeTree.map.size && !isReference(incoming)) {
|
|
3437
|
+
var e_1 = (!Array.isArray(incoming) &&
|
|
3438
|
+
(isReference(existing) || storeValueIsStoreObject(existing))) ? existing : void 0;
|
|
3439
|
+
var i_1 = incoming;
|
|
3440
|
+
if (e_1 && !getStorageArgs) {
|
|
3441
|
+
getStorageArgs = [isReference(e_1) ? e_1.__ref : e_1];
|
|
3442
|
+
}
|
|
3443
|
+
var changedFields_1;
|
|
3444
|
+
var getValue_1 = function (from, name) {
|
|
3445
|
+
return Array.isArray(from)
|
|
3446
|
+
? (typeof name === "number" ? from[name] : void 0)
|
|
3447
|
+
: context.store.getFieldValue(from, String(name));
|
|
3448
|
+
};
|
|
3449
|
+
mergeTree.map.forEach(function (childTree, storeFieldName) {
|
|
3450
|
+
var eVal = getValue_1(e_1, storeFieldName);
|
|
3451
|
+
var iVal = getValue_1(i_1, storeFieldName);
|
|
3452
|
+
if (void 0 === iVal)
|
|
3453
|
+
return;
|
|
3454
|
+
if (getStorageArgs) {
|
|
3455
|
+
getStorageArgs.push(storeFieldName);
|
|
3456
|
+
}
|
|
3457
|
+
var aVal = _this.applyMerges(childTree, eVal, iVal, context, getStorageArgs);
|
|
3458
|
+
if (aVal !== iVal) {
|
|
3459
|
+
changedFields_1 = changedFields_1 || new Map;
|
|
3460
|
+
changedFields_1.set(storeFieldName, aVal);
|
|
3461
|
+
}
|
|
3462
|
+
if (getStorageArgs) {
|
|
3463
|
+
tsInvariant.invariant(getStorageArgs.pop() === storeFieldName);
|
|
3464
|
+
}
|
|
3465
|
+
});
|
|
3466
|
+
if (changedFields_1) {
|
|
3467
|
+
incoming = (Array.isArray(i_1) ? i_1.slice(0) : tslib.__assign({}, i_1));
|
|
3468
|
+
changedFields_1.forEach(function (value, name) {
|
|
3469
|
+
incoming[name] = value;
|
|
3470
|
+
});
|
|
3471
|
+
}
|
|
3472
|
+
}
|
|
3473
|
+
if (mergeTree.info) {
|
|
3474
|
+
return this.cache.policies.runMergeFunction(existing, incoming, mergeTree.info, context, getStorageArgs && (_a = context.store).getStorage.apply(_a, getStorageArgs));
|
|
3475
|
+
}
|
|
3476
|
+
return incoming;
|
|
3477
|
+
};
|
|
3478
|
+
return StoreWriter;
|
|
3479
|
+
}());
|
|
3480
|
+
var emptyMergeTreePool = [];
|
|
3481
|
+
function getChildMergeTree(_a, name) {
|
|
3482
|
+
var map = _a.map;
|
|
3483
|
+
if (!map.has(name)) {
|
|
3484
|
+
map.set(name, emptyMergeTreePool.pop() || { map: new Map });
|
|
3485
|
+
}
|
|
3486
|
+
return map.get(name);
|
|
3487
|
+
}
|
|
3488
|
+
function mergeMergeTrees(left, right) {
|
|
3489
|
+
if (left === right || !right || mergeTreeIsEmpty(right))
|
|
3490
|
+
return left;
|
|
3491
|
+
if (!left || mergeTreeIsEmpty(left))
|
|
3492
|
+
return right;
|
|
3493
|
+
var info = left.info && right.info ? tslib.__assign(tslib.__assign({}, left.info), right.info) : left.info || right.info;
|
|
3494
|
+
var needToMergeMaps = left.map.size && right.map.size;
|
|
3495
|
+
var map = needToMergeMaps ? new Map :
|
|
3496
|
+
left.map.size ? left.map : right.map;
|
|
3497
|
+
var merged = { info: info, map: map };
|
|
3498
|
+
if (needToMergeMaps) {
|
|
3499
|
+
var remainingRightKeys_1 = new Set(right.map.keys());
|
|
3500
|
+
left.map.forEach(function (leftTree, key) {
|
|
3501
|
+
merged.map.set(key, mergeMergeTrees(leftTree, right.map.get(key)));
|
|
3502
|
+
remainingRightKeys_1.delete(key);
|
|
3503
|
+
});
|
|
3504
|
+
remainingRightKeys_1.forEach(function (key) {
|
|
3505
|
+
merged.map.set(key, mergeMergeTrees(right.map.get(key), left.map.get(key)));
|
|
3506
|
+
});
|
|
3507
|
+
}
|
|
3508
|
+
return merged;
|
|
3509
|
+
}
|
|
3510
|
+
function mergeTreeIsEmpty(tree) {
|
|
3511
|
+
return !tree || !(tree.info || tree.map.size);
|
|
3512
|
+
}
|
|
3513
|
+
function maybeRecycleChildMergeTree(_a, name) {
|
|
3514
|
+
var map = _a.map;
|
|
3515
|
+
var childTree = map.get(name);
|
|
3516
|
+
if (childTree && mergeTreeIsEmpty(childTree)) {
|
|
3517
|
+
emptyMergeTreePool.push(childTree);
|
|
3518
|
+
map.delete(name);
|
|
3519
|
+
}
|
|
3520
|
+
}
|
|
3521
|
+
var warnings = new Set();
|
|
3522
|
+
function warnAboutDataLoss(existingRef, incomingObj, storeFieldName, store) {
|
|
3523
|
+
var getChild = function (objOrRef) {
|
|
3524
|
+
var child = store.getFieldValue(objOrRef, storeFieldName);
|
|
3525
|
+
return typeof child === "object" && child;
|
|
3526
|
+
};
|
|
3527
|
+
var existing = getChild(existingRef);
|
|
3528
|
+
if (!existing)
|
|
3529
|
+
return;
|
|
3530
|
+
var incoming = getChild(incomingObj);
|
|
3531
|
+
if (!incoming)
|
|
3532
|
+
return;
|
|
3533
|
+
if (isReference(existing))
|
|
3534
|
+
return;
|
|
3535
|
+
if (equality.equal(existing, incoming))
|
|
3536
|
+
return;
|
|
3537
|
+
if (Object.keys(existing).every(function (key) { return store.getFieldValue(incoming, key) !== void 0; })) {
|
|
3538
|
+
return;
|
|
3539
|
+
}
|
|
3540
|
+
var parentType = store.getFieldValue(existingRef, "__typename") ||
|
|
3541
|
+
store.getFieldValue(incomingObj, "__typename");
|
|
3542
|
+
var fieldName = fieldNameFromStoreName(storeFieldName);
|
|
3543
|
+
var typeDotName = "".concat(parentType, ".").concat(fieldName);
|
|
3544
|
+
if (warnings.has(typeDotName))
|
|
3545
|
+
return;
|
|
3546
|
+
warnings.add(typeDotName);
|
|
3547
|
+
var childTypenames = [];
|
|
3548
|
+
if (!Array.isArray(existing) &&
|
|
3549
|
+
!Array.isArray(incoming)) {
|
|
3550
|
+
[existing, incoming].forEach(function (child) {
|
|
3551
|
+
var typename = store.getFieldValue(child, "__typename");
|
|
3552
|
+
if (typeof typename === "string" &&
|
|
3553
|
+
!childTypenames.includes(typename)) {
|
|
3554
|
+
childTypenames.push(typename);
|
|
3555
|
+
}
|
|
3556
|
+
});
|
|
3557
|
+
}
|
|
3558
|
+
__DEV__ && tsInvariant.invariant.warn("Cache data may be lost when replacing the ".concat(fieldName, " field of a ").concat(parentType, " object.\n\nTo address this problem (which is not a bug in Apollo Client), ").concat(childTypenames.length
|
|
3559
|
+
? "either ensure all objects of type " +
|
|
3560
|
+
childTypenames.join(" and ") + " have an ID or a custom merge function, or "
|
|
3561
|
+
: "", "define a custom merge function for the ").concat(typeDotName, " field, so InMemoryCache can safely merge these objects:\n\n existing: ").concat(JSON.stringify(existing).slice(0, 1000), "\n incoming: ").concat(JSON.stringify(incoming).slice(0, 1000), "\n\nFor more information about these options, please refer to the documentation:\n\n * Ensuring entity objects have IDs: https://go.apollo.dev/c/generating-unique-identifiers\n * Defining custom merge functions: https://go.apollo.dev/c/merging-non-normalized-objects\n"));
|
|
3398
3562
|
}
|
|
3399
3563
|
|
|
3400
3564
|
var InMemoryCache = (function (_super) {
|
|
@@ -3543,8 +3707,14 @@ var InMemoryCache = (function (_super) {
|
|
|
3543
3707
|
return (optimistic ? this.optimisticData : this.data).release(rootId);
|
|
3544
3708
|
};
|
|
3545
3709
|
InMemoryCache.prototype.identify = function (object) {
|
|
3546
|
-
|
|
3547
|
-
|
|
3710
|
+
if (isReference(object))
|
|
3711
|
+
return object.__ref;
|
|
3712
|
+
try {
|
|
3713
|
+
return this.policies.identify(object)[0];
|
|
3714
|
+
}
|
|
3715
|
+
catch (e) {
|
|
3716
|
+
__DEV__ && tsInvariant.invariant.warn(e);
|
|
3717
|
+
}
|
|
3548
3718
|
};
|
|
3549
3719
|
InMemoryCache.prototype.evict = function (options) {
|
|
3550
3720
|
if (!options.id) {
|
|
@@ -3587,6 +3757,7 @@ var InMemoryCache = (function (_super) {
|
|
|
3587
3757
|
InMemoryCache.prototype.batch = function (options) {
|
|
3588
3758
|
var _this = this;
|
|
3589
3759
|
var update = options.update, _a = options.optimistic, optimistic = _a === void 0 ? true : _a, removeOptimistic = options.removeOptimistic, onWatchUpdated = options.onWatchUpdated;
|
|
3760
|
+
var updateResult;
|
|
3590
3761
|
var perform = function (layer) {
|
|
3591
3762
|
var _a = _this, data = _a.data, optimisticData = _a.optimisticData;
|
|
3592
3763
|
++_this.txCount;
|
|
@@ -3594,7 +3765,7 @@ var InMemoryCache = (function (_super) {
|
|
|
3594
3765
|
_this.data = _this.optimisticData = layer;
|
|
3595
3766
|
}
|
|
3596
3767
|
try {
|
|
3597
|
-
update(_this);
|
|
3768
|
+
return updateResult = update(_this);
|
|
3598
3769
|
}
|
|
3599
3770
|
finally {
|
|
3600
3771
|
--_this.txCount;
|
|
@@ -3636,6 +3807,7 @@ var InMemoryCache = (function (_super) {
|
|
|
3636
3807
|
else {
|
|
3637
3808
|
this.broadcastWatches(options);
|
|
3638
3809
|
}
|
|
3810
|
+
return updateResult;
|
|
3639
3811
|
};
|
|
3640
3812
|
InMemoryCache.prototype.performTransaction = function (update, optimisticId) {
|
|
3641
3813
|
return this.batch({
|
|
@@ -3693,11 +3865,11 @@ var generateErrorMessage = function (err) {
|
|
|
3693
3865
|
var errorMessage = error
|
|
3694
3866
|
? error.message
|
|
3695
3867
|
: 'Error message not found.';
|
|
3696
|
-
message += errorMessage
|
|
3868
|
+
message += "".concat(errorMessage, "\n");
|
|
3697
3869
|
});
|
|
3698
3870
|
}
|
|
3699
3871
|
if (err.networkError) {
|
|
3700
|
-
message += err.networkError.message
|
|
3872
|
+
message += "".concat(err.networkError.message, "\n");
|
|
3701
3873
|
}
|
|
3702
3874
|
message = message.replace(/\n$/, '');
|
|
3703
3875
|
return message;
|
|
@@ -3810,11 +3982,11 @@ var ObservableQuery = (function (_super) {
|
|
|
3810
3982
|
exports.NetworkStatus.ready;
|
|
3811
3983
|
var result = tslib.__assign(tslib.__assign({}, lastResult), { loading: isNetworkRequestInFlight(networkStatus), networkStatus: networkStatus });
|
|
3812
3984
|
var _a = this.options.fetchPolicy, fetchPolicy = _a === void 0 ? "cache-first" : _a;
|
|
3813
|
-
|
|
3814
|
-
fetchPolicy
|
|
3815
|
-
fetchPolicy
|
|
3816
|
-
|
|
3817
|
-
|
|
3985
|
+
if (fetchPolicy === 'network-only' ||
|
|
3986
|
+
fetchPolicy === 'no-cache' ||
|
|
3987
|
+
fetchPolicy === 'standby' ||
|
|
3988
|
+
this.queryManager.transform(this.options.query).hasForcedResolvers) ;
|
|
3989
|
+
else {
|
|
3818
3990
|
var diff = this.queryInfo.getDiff();
|
|
3819
3991
|
if (diff.complete || this.options.returnPartialData) {
|
|
3820
3992
|
result.data = diff.result;
|
|
@@ -3823,15 +3995,16 @@ var ObservableQuery = (function (_super) {
|
|
|
3823
3995
|
result.data = void 0;
|
|
3824
3996
|
}
|
|
3825
3997
|
if (diff.complete) {
|
|
3826
|
-
|
|
3998
|
+
delete result.partial;
|
|
3999
|
+
if (diff.complete &&
|
|
4000
|
+
result.networkStatus === exports.NetworkStatus.loading &&
|
|
3827
4001
|
(fetchPolicy === 'cache-first' ||
|
|
3828
4002
|
fetchPolicy === 'cache-only')) {
|
|
3829
4003
|
result.networkStatus = exports.NetworkStatus.ready;
|
|
3830
4004
|
result.loading = false;
|
|
3831
4005
|
}
|
|
3832
|
-
delete result.partial;
|
|
3833
4006
|
}
|
|
3834
|
-
else
|
|
4007
|
+
else {
|
|
3835
4008
|
result.partial = true;
|
|
3836
4009
|
}
|
|
3837
4010
|
if (__DEV__ &&
|
|
@@ -3878,17 +4051,20 @@ var ObservableQuery = (function (_super) {
|
|
|
3878
4051
|
pollInterval: 0,
|
|
3879
4052
|
};
|
|
3880
4053
|
var fetchPolicy = this.options.fetchPolicy;
|
|
3881
|
-
if (fetchPolicy === '
|
|
4054
|
+
if (fetchPolicy === 'standby' || fetchPolicy === 'cache-and-network') {
|
|
4055
|
+
reobserveOptions.fetchPolicy = fetchPolicy;
|
|
4056
|
+
}
|
|
4057
|
+
else if (fetchPolicy === 'no-cache') {
|
|
3882
4058
|
reobserveOptions.fetchPolicy = 'no-cache';
|
|
3883
4059
|
}
|
|
3884
|
-
else
|
|
4060
|
+
else {
|
|
3885
4061
|
reobserveOptions.fetchPolicy = 'network-only';
|
|
3886
4062
|
}
|
|
3887
4063
|
if (__DEV__ && variables && hasOwnProperty$1.call(variables, "variables")) {
|
|
3888
4064
|
var queryDef = getQueryDefinition(this.options.query);
|
|
3889
4065
|
var vars = queryDef.variableDefinitions;
|
|
3890
4066
|
if (!vars || !vars.some(function (v) { return v.variable.name.value === "variables"; })) {
|
|
3891
|
-
__DEV__ && tsInvariant.invariant.warn("Called refetch("
|
|
4067
|
+
__DEV__ && tsInvariant.invariant.warn("Called refetch(".concat(JSON.stringify(variables), ") for query ").concat(((_a = queryDef.name) === null || _a === void 0 ? void 0 : _a.value) || JSON.stringify(queryDef), ", which does not declare a $variables variable.\nDid you mean to call refetch(variables) instead of refetch({ variables })?"));
|
|
3892
4068
|
}
|
|
3893
4069
|
}
|
|
3894
4070
|
if (variables && !equality.equal(this.options.variables, variables)) {
|
|
@@ -4035,7 +4211,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4035
4211
|
pollingInfo.interval === pollInterval) {
|
|
4036
4212
|
return;
|
|
4037
4213
|
}
|
|
4038
|
-
__DEV__ ? tsInvariant.invariant(pollInterval, 'Attempted to start a polling query without a polling interval.') : tsInvariant.invariant(pollInterval,
|
|
4214
|
+
__DEV__ ? tsInvariant.invariant(pollInterval, 'Attempted to start a polling query without a polling interval.') : tsInvariant.invariant(pollInterval, 10);
|
|
4039
4215
|
var info = pollingInfo || (this.pollingInfo = {});
|
|
4040
4216
|
info.interval = pollInterval;
|
|
4041
4217
|
var maybeFetch = function () {
|
|
@@ -4150,8 +4326,8 @@ function defaultSubscriptionObserverErrorCallback(error) {
|
|
|
4150
4326
|
__DEV__ && tsInvariant.invariant.error('Unhandled error', error.message, error.stack);
|
|
4151
4327
|
}
|
|
4152
4328
|
function logMissingFieldErrors(missing) {
|
|
4153
|
-
if (__DEV__ &&
|
|
4154
|
-
__DEV__ && tsInvariant.invariant.debug("Missing cache result fields: "
|
|
4329
|
+
if (__DEV__ && missing) {
|
|
4330
|
+
__DEV__ && tsInvariant.invariant.debug("Missing cache result fields: ".concat(JSON.stringify(missing)), missing);
|
|
4155
4331
|
}
|
|
4156
4332
|
}
|
|
4157
4333
|
function applyNextFetchPolicy(options) {
|
|
@@ -4332,7 +4508,7 @@ var LocalState = (function () {
|
|
|
4332
4508
|
}
|
|
4333
4509
|
else {
|
|
4334
4510
|
fragment = fragmentMap[selection.name.value];
|
|
4335
|
-
__DEV__ ? tsInvariant.invariant(fragment, "No fragment named "
|
|
4511
|
+
__DEV__ ? tsInvariant.invariant(fragment, "No fragment named ".concat(selection.name.value)) : tsInvariant.invariant(fragment, 9);
|
|
4336
4512
|
}
|
|
4337
4513
|
if (fragment && fragment.typeCondition) {
|
|
4338
4514
|
typeCondition = fragment.typeCondition.name.value;
|
|
@@ -4718,7 +4894,7 @@ var QueryManager = (function () {
|
|
|
4718
4894
|
this.queries.forEach(function (_info, queryId) {
|
|
4719
4895
|
_this.stopQueryNoBroadcast(queryId);
|
|
4720
4896
|
});
|
|
4721
|
-
this.cancelPendingFetches(__DEV__ ? new tsInvariant.InvariantError('QueryManager stopped while query was in flight') : new tsInvariant.InvariantError(
|
|
4897
|
+
this.cancelPendingFetches(__DEV__ ? new tsInvariant.InvariantError('QueryManager stopped while query was in flight') : new tsInvariant.InvariantError(11));
|
|
4722
4898
|
};
|
|
4723
4899
|
QueryManager.prototype.cancelPendingFetches = function (error) {
|
|
4724
4900
|
this.fetchCancelFns.forEach(function (cancel) { return cancel(error); });
|
|
@@ -4731,10 +4907,10 @@ var QueryManager = (function () {
|
|
|
4731
4907
|
return tslib.__generator(this, function (_f) {
|
|
4732
4908
|
switch (_f.label) {
|
|
4733
4909
|
case 0:
|
|
4734
|
-
__DEV__ ? tsInvariant.invariant(mutation, 'mutation option is required. You must specify your GraphQL document in the mutation option.') : tsInvariant.invariant(mutation,
|
|
4910
|
+
__DEV__ ? tsInvariant.invariant(mutation, 'mutation option is required. You must specify your GraphQL document in the mutation option.') : tsInvariant.invariant(mutation, 12);
|
|
4735
4911
|
__DEV__ ? tsInvariant.invariant(fetchPolicy === 'network-only' ||
|
|
4736
4912
|
fetchPolicy === 'no-cache', "Mutations support only 'network-only' or 'no-cache' fetchPolicy strings. The default `network-only` behavior automatically writes mutation results to the cache. Passing `no-cache` skips the cache write.") : tsInvariant.invariant(fetchPolicy === 'network-only' ||
|
|
4737
|
-
fetchPolicy === 'no-cache',
|
|
4913
|
+
fetchPolicy === 'no-cache', 13);
|
|
4738
4914
|
mutationId = this.generateMutationId();
|
|
4739
4915
|
mutation = this.transform(mutation).document;
|
|
4740
4916
|
variables = this.getVariables(mutation, variables);
|
|
@@ -5019,10 +5195,10 @@ var QueryManager = (function () {
|
|
|
5019
5195
|
var _this = this;
|
|
5020
5196
|
if (queryId === void 0) { queryId = this.generateQueryId(); }
|
|
5021
5197
|
__DEV__ ? tsInvariant.invariant(options.query, 'query option is required. You must specify your GraphQL document ' +
|
|
5022
|
-
'in the query option.') : tsInvariant.invariant(options.query,
|
|
5023
|
-
__DEV__ ? tsInvariant.invariant(options.query.kind === 'Document', 'You must wrap the query string in a "gql" tag.') : tsInvariant.invariant(options.query.kind === 'Document',
|
|
5024
|
-
__DEV__ ? tsInvariant.invariant(!options.returnPartialData, 'returnPartialData option only supported on watchQuery.') : tsInvariant.invariant(!options.returnPartialData,
|
|
5025
|
-
__DEV__ ? tsInvariant.invariant(!options.pollInterval, 'pollInterval option only supported on watchQuery.') : tsInvariant.invariant(!options.pollInterval,
|
|
5198
|
+
'in the query option.') : tsInvariant.invariant(options.query, 14);
|
|
5199
|
+
__DEV__ ? tsInvariant.invariant(options.query.kind === 'Document', 'You must wrap the query string in a "gql" tag.') : tsInvariant.invariant(options.query.kind === 'Document', 15);
|
|
5200
|
+
__DEV__ ? tsInvariant.invariant(!options.returnPartialData, 'returnPartialData option only supported on watchQuery.') : tsInvariant.invariant(!options.returnPartialData, 16);
|
|
5201
|
+
__DEV__ ? tsInvariant.invariant(!options.pollInterval, 'pollInterval option only supported on watchQuery.') : tsInvariant.invariant(!options.pollInterval, 17);
|
|
5026
5202
|
return this.fetchQuery(queryId, options).finally(function () { return _this.stopQuery(queryId); });
|
|
5027
5203
|
};
|
|
5028
5204
|
QueryManager.prototype.generateQueryId = function () {
|
|
@@ -5047,7 +5223,7 @@ var QueryManager = (function () {
|
|
|
5047
5223
|
if (options === void 0) { options = {
|
|
5048
5224
|
discardWatches: true,
|
|
5049
5225
|
}; }
|
|
5050
|
-
this.cancelPendingFetches(__DEV__ ? new tsInvariant.InvariantError('Store reset while query was in flight (not completed in link chain)') : new tsInvariant.InvariantError(
|
|
5226
|
+
this.cancelPendingFetches(__DEV__ ? new tsInvariant.InvariantError('Store reset while query was in flight (not completed in link chain)') : new tsInvariant.InvariantError(18));
|
|
5051
5227
|
this.queries.forEach(function (queryInfo) {
|
|
5052
5228
|
if (queryInfo.observableQuery) {
|
|
5053
5229
|
queryInfo.networkStatus = exports.NetworkStatus.loading;
|
|
@@ -5123,7 +5299,7 @@ var QueryManager = (function () {
|
|
|
5123
5299
|
if (__DEV__ && queryNamesAndDocs.size) {
|
|
5124
5300
|
queryNamesAndDocs.forEach(function (included, nameOrDoc) {
|
|
5125
5301
|
if (!included) {
|
|
5126
|
-
__DEV__ && tsInvariant.invariant.warn("Unknown query "
|
|
5302
|
+
__DEV__ && tsInvariant.invariant.warn("Unknown query ".concat(typeof nameOrDoc === "string" ? "named " : "").concat(JSON.stringify(nameOrDoc, null, 2), " requested in refetchQueries options.include array"));
|
|
5127
5303
|
}
|
|
5128
5304
|
});
|
|
5129
5305
|
}
|
|
@@ -5359,7 +5535,7 @@ var QueryManager = (function () {
|
|
|
5359
5535
|
if (result !== false) {
|
|
5360
5536
|
results.set(oq, result);
|
|
5361
5537
|
}
|
|
5362
|
-
return
|
|
5538
|
+
return result;
|
|
5363
5539
|
}
|
|
5364
5540
|
if (onQueryUpdated !== null) {
|
|
5365
5541
|
includedQueriesById.set(oq.queryId, { oq: oq, lastDiff: lastDiff, diff: diff });
|
|
@@ -5535,7 +5711,7 @@ var ApolloClient = (function () {
|
|
|
5535
5711
|
if (!cache) {
|
|
5536
5712
|
throw __DEV__ ? new tsInvariant.InvariantError("To initialize Apollo Client, you must specify a 'cache' property " +
|
|
5537
5713
|
"in the options object. \n" +
|
|
5538
|
-
"For more information, please visit: https://go.apollo.dev/c/docs") : new tsInvariant.InvariantError(
|
|
5714
|
+
"For more information, please visit: https://go.apollo.dev/c/docs") : new tsInvariant.InvariantError(7);
|
|
5539
5715
|
}
|
|
5540
5716
|
this.link = link;
|
|
5541
5717
|
this.cache = cache;
|
|
@@ -5631,7 +5807,7 @@ var ApolloClient = (function () {
|
|
|
5631
5807
|
__DEV__ ? tsInvariant.invariant(options.fetchPolicy !== 'cache-and-network', 'The cache-and-network fetchPolicy does not work with client.query, because ' +
|
|
5632
5808
|
'client.query can only return a single result. Please use client.watchQuery ' +
|
|
5633
5809
|
'to receive multiple results from the cache and the network, or consider ' +
|
|
5634
|
-
'using a different fetchPolicy, such as cache-first or network-only.') : tsInvariant.invariant(options.fetchPolicy !== 'cache-and-network',
|
|
5810
|
+
'using a different fetchPolicy, such as cache-first or network-only.') : tsInvariant.invariant(options.fetchPolicy !== 'cache-and-network', 8);
|
|
5635
5811
|
if (this.disableNetworkFetches && options.fetchPolicy === 'network-only') {
|
|
5636
5812
|
options = tslib.__assign(tslib.__assign({}, options), { fetchPolicy: 'cache-first' });
|
|
5637
5813
|
}
|
|
@@ -5714,7 +5890,7 @@ var ApolloClient = (function () {
|
|
|
5714
5890
|
result.queries = queries;
|
|
5715
5891
|
result.results = results;
|
|
5716
5892
|
result.catch(function (error) {
|
|
5717
|
-
__DEV__ && tsInvariant.invariant.debug("In client.refetchQueries, Promise.all promise rejected with error "
|
|
5893
|
+
__DEV__ && tsInvariant.invariant.debug("In client.refetchQueries, Promise.all promise rejected with error ".concat(error));
|
|
5718
5894
|
});
|
|
5719
5895
|
return result;
|
|
5720
5896
|
};
|
|
@@ -5767,7 +5943,7 @@ var ApolloConsumer = function (props) {
|
|
|
5767
5943
|
var ApolloContext = getApolloContext();
|
|
5768
5944
|
return React__namespace.createElement(ApolloContext.Consumer, null, function (context) {
|
|
5769
5945
|
__DEV__ ? tsInvariant.invariant(context && context.client, 'Could not find "client" in the context of ApolloConsumer. ' +
|
|
5770
|
-
'Wrap the root component in an <ApolloProvider>.') : tsInvariant.invariant(context && context.client,
|
|
5946
|
+
'Wrap the root component in an <ApolloProvider>.') : tsInvariant.invariant(context && context.client, 25);
|
|
5771
5947
|
return props.children(context.client);
|
|
5772
5948
|
});
|
|
5773
5949
|
};
|
|
@@ -5781,15 +5957,17 @@ var ApolloProvider = function (_a) {
|
|
|
5781
5957
|
context = Object.assign({}, context, { client: client });
|
|
5782
5958
|
}
|
|
5783
5959
|
__DEV__ ? tsInvariant.invariant(context.client, 'ApolloProvider was not passed a client instance. Make ' +
|
|
5784
|
-
'sure you pass in your client via the "client" prop.') : tsInvariant.invariant(context.client,
|
|
5960
|
+
'sure you pass in your client via the "client" prop.') : tsInvariant.invariant(context.client, 26);
|
|
5785
5961
|
return (React__namespace.createElement(ApolloContext.Provider, { value: context }, children));
|
|
5786
5962
|
});
|
|
5787
5963
|
};
|
|
5788
5964
|
|
|
5789
|
-
function useApolloClient() {
|
|
5790
|
-
var
|
|
5791
|
-
|
|
5792
|
-
|
|
5965
|
+
function useApolloClient(override) {
|
|
5966
|
+
var context = React.useContext(getApolloContext());
|
|
5967
|
+
var client = override || context.client;
|
|
5968
|
+
__DEV__ ? tsInvariant.invariant(!!client, 'Could not find "client" in the context or passed in as an option. ' +
|
|
5969
|
+
'Wrap the root component in an <ApolloProvider>, or pass an ApolloClient' +
|
|
5970
|
+
'ApolloClient instance in via options.') : tsInvariant.invariant(!!client, 29);
|
|
5793
5971
|
return client;
|
|
5794
5972
|
}
|
|
5795
5973
|
|
|
@@ -5820,9 +5998,9 @@ function parser(document) {
|
|
|
5820
5998
|
if (cached)
|
|
5821
5999
|
return cached;
|
|
5822
6000
|
var variables, type, name;
|
|
5823
|
-
__DEV__ ? tsInvariant.invariant(!!document && !!document.kind, "Argument of "
|
|
6001
|
+
__DEV__ ? tsInvariant.invariant(!!document && !!document.kind, "Argument of ".concat(document, " passed to parser was not a valid GraphQL ") +
|
|
5824
6002
|
"DocumentNode. You may need to use 'graphql-tag' or another method " +
|
|
5825
|
-
"to convert your operation into a document") : tsInvariant.invariant(!!document && !!document.kind,
|
|
6003
|
+
"to convert your operation into a document") : tsInvariant.invariant(!!document && !!document.kind, 30);
|
|
5826
6004
|
var fragments = document.definitions.filter(function (x) { return x.kind === 'FragmentDefinition'; });
|
|
5827
6005
|
var queries = document.definitions.filter(function (x) {
|
|
5828
6006
|
return x.kind === 'OperationDefinition' && x.operation === 'query';
|
|
@@ -5836,11 +6014,11 @@ function parser(document) {
|
|
|
5836
6014
|
__DEV__ ? tsInvariant.invariant(!fragments.length ||
|
|
5837
6015
|
(queries.length || mutations.length || subscriptions.length), "Passing only a fragment to 'graphql' is not yet supported. " +
|
|
5838
6016
|
"You must include a query, subscription or mutation as well") : tsInvariant.invariant(!fragments.length ||
|
|
5839
|
-
(queries.length || mutations.length || subscriptions.length),
|
|
6017
|
+
(queries.length || mutations.length || subscriptions.length), 31);
|
|
5840
6018
|
__DEV__ ? tsInvariant.invariant(queries.length + mutations.length + subscriptions.length <= 1, "react-apollo only supports a query, subscription, or a mutation per HOC. " +
|
|
5841
|
-
(document
|
|
5842
|
-
|
|
5843
|
-
"You can use 'compose' to join multiple operation types to a component") : tsInvariant.invariant(queries.length + mutations.length + subscriptions.length <= 1,
|
|
6019
|
+
"".concat(document, " had ").concat(queries.length, " queries, ").concat(subscriptions.length, " ") +
|
|
6020
|
+
"subscriptions and ".concat(mutations.length, " mutations. ") +
|
|
6021
|
+
"You can use 'compose' to join multiple operation types to a component") : tsInvariant.invariant(queries.length + mutations.length + subscriptions.length <= 1, 32);
|
|
5844
6022
|
type = queries.length ? exports.DocumentType.Query : exports.DocumentType.Mutation;
|
|
5845
6023
|
if (!queries.length && !mutations.length)
|
|
5846
6024
|
type = exports.DocumentType.Subscription;
|
|
@@ -5849,9 +6027,9 @@ function parser(document) {
|
|
|
5849
6027
|
: mutations.length
|
|
5850
6028
|
? mutations
|
|
5851
6029
|
: subscriptions;
|
|
5852
|
-
__DEV__ ? tsInvariant.invariant(definitions.length === 1, "react-apollo only supports one definition per HOC. "
|
|
5853
|
-
(definitions.length
|
|
5854
|
-
"You can use 'compose' to join multiple operation types to a component") : tsInvariant.invariant(definitions.length === 1,
|
|
6030
|
+
__DEV__ ? tsInvariant.invariant(definitions.length === 1, "react-apollo only supports one definition per HOC. ".concat(document, " had ") +
|
|
6031
|
+
"".concat(definitions.length, " definitions. ") +
|
|
6032
|
+
"You can use 'compose' to join multiple operation types to a component") : tsInvariant.invariant(definitions.length === 1, 33);
|
|
5855
6033
|
var definition = definitions[0];
|
|
5856
6034
|
variables = definition.variableDefinitions || [];
|
|
5857
6035
|
if (definition.name && definition.name.kind === 'Name') {
|
|
@@ -5864,711 +6042,470 @@ function parser(document) {
|
|
|
5864
6042
|
cache.set(document, payload);
|
|
5865
6043
|
return payload;
|
|
5866
6044
|
}
|
|
6045
|
+
function verifyDocumentType(document, type) {
|
|
6046
|
+
var operation = parser(document);
|
|
6047
|
+
var requiredOperationName = operationName(type);
|
|
6048
|
+
var usedOperationName = operationName(operation.type);
|
|
6049
|
+
__DEV__ ? tsInvariant.invariant(operation.type === type, "Running a ".concat(requiredOperationName, " requires a graphql ") +
|
|
6050
|
+
"".concat(requiredOperationName, ", but a ").concat(usedOperationName, " was used instead.")) : tsInvariant.invariant(operation.type === type, 34);
|
|
6051
|
+
}
|
|
5867
6052
|
|
|
5868
|
-
|
|
5869
|
-
|
|
5870
|
-
|
|
5871
|
-
|
|
5872
|
-
|
|
5873
|
-
|
|
5874
|
-
|
|
5875
|
-
|
|
5876
|
-
|
|
5877
|
-
|
|
5878
|
-
|
|
5879
|
-
|
|
5880
|
-
|
|
5881
|
-
|
|
5882
|
-
|
|
5883
|
-
|
|
5884
|
-
}
|
|
5885
|
-
|
|
5886
|
-
|
|
5887
|
-
|
|
5888
|
-
|
|
5889
|
-
|
|
5890
|
-
|
|
5891
|
-
|
|
5892
|
-
|
|
5893
|
-
|
|
5894
|
-
|
|
5895
|
-
|
|
5896
|
-
|
|
5897
|
-
|
|
5898
|
-
|
|
5899
|
-
|
|
5900
|
-
|
|
5901
|
-
|
|
5902
|
-
|
|
5903
|
-
|
|
5904
|
-
|
|
5905
|
-
|
|
5906
|
-
|
|
5907
|
-
|
|
5908
|
-
|
|
5909
|
-
var requiredOperationName = operationName(type);
|
|
5910
|
-
var usedOperationName = operationName(operation.type);
|
|
5911
|
-
__DEV__ ? tsInvariant.invariant(operation.type === type, "Running a " + requiredOperationName + " requires a graphql " +
|
|
5912
|
-
(requiredOperationName + ", but a " + usedOperationName + " was used instead.")) : tsInvariant.invariant(operation.type === type, 30);
|
|
5913
|
-
};
|
|
5914
|
-
return OperationData;
|
|
5915
|
-
}());
|
|
5916
|
-
|
|
5917
|
-
var SubscriptionData = (function (_super) {
|
|
5918
|
-
tslib.__extends(SubscriptionData, _super);
|
|
5919
|
-
function SubscriptionData(_a) {
|
|
5920
|
-
var options = _a.options, context = _a.context, setResult = _a.setResult;
|
|
5921
|
-
var _this = _super.call(this, options, context) || this;
|
|
5922
|
-
_this.currentObservable = {};
|
|
5923
|
-
_this.setResult = setResult;
|
|
5924
|
-
_this.initialize(options);
|
|
5925
|
-
return _this;
|
|
5926
|
-
}
|
|
5927
|
-
SubscriptionData.prototype.execute = function (result) {
|
|
5928
|
-
if (this.getOptions().skip === true) {
|
|
5929
|
-
this.cleanup();
|
|
5930
|
-
return {
|
|
5931
|
-
loading: false,
|
|
5932
|
-
error: undefined,
|
|
5933
|
-
data: undefined,
|
|
5934
|
-
variables: this.getOptions().variables
|
|
5935
|
-
};
|
|
5936
|
-
}
|
|
5937
|
-
var currentResult = result;
|
|
5938
|
-
if (this.refreshClient().isNew) {
|
|
5939
|
-
currentResult = this.getLoadingResult();
|
|
5940
|
-
}
|
|
5941
|
-
var shouldResubscribe = this.getOptions().shouldResubscribe;
|
|
5942
|
-
if (typeof shouldResubscribe === 'function') {
|
|
5943
|
-
shouldResubscribe = !!shouldResubscribe(this.getOptions());
|
|
5944
|
-
}
|
|
5945
|
-
if (shouldResubscribe !== false &&
|
|
5946
|
-
this.previousOptions &&
|
|
5947
|
-
Object.keys(this.previousOptions).length > 0 &&
|
|
5948
|
-
(this.previousOptions.subscription !== this.getOptions().subscription ||
|
|
5949
|
-
!equality.equal(this.previousOptions.variables, this.getOptions().variables) ||
|
|
5950
|
-
this.previousOptions.skip !== this.getOptions().skip)) {
|
|
5951
|
-
this.cleanup();
|
|
5952
|
-
currentResult = this.getLoadingResult();
|
|
5953
|
-
}
|
|
5954
|
-
this.initialize(this.getOptions());
|
|
5955
|
-
this.startSubscription();
|
|
5956
|
-
this.previousOptions = this.getOptions();
|
|
5957
|
-
return tslib.__assign(tslib.__assign({}, currentResult), { variables: this.getOptions().variables });
|
|
5958
|
-
};
|
|
5959
|
-
SubscriptionData.prototype.afterExecute = function () {
|
|
5960
|
-
this.isMounted = true;
|
|
5961
|
-
};
|
|
5962
|
-
SubscriptionData.prototype.cleanup = function () {
|
|
5963
|
-
this.endSubscription();
|
|
5964
|
-
delete this.currentObservable.query;
|
|
5965
|
-
};
|
|
5966
|
-
SubscriptionData.prototype.initialize = function (options) {
|
|
5967
|
-
if (this.currentObservable.query || this.getOptions().skip === true)
|
|
5968
|
-
return;
|
|
5969
|
-
this.currentObservable.query = this.refreshClient().client.subscribe({
|
|
5970
|
-
query: options.subscription,
|
|
5971
|
-
variables: options.variables,
|
|
5972
|
-
fetchPolicy: options.fetchPolicy,
|
|
5973
|
-
context: options.context,
|
|
5974
|
-
});
|
|
5975
|
-
};
|
|
5976
|
-
SubscriptionData.prototype.startSubscription = function () {
|
|
5977
|
-
if (this.currentObservable.subscription)
|
|
5978
|
-
return;
|
|
5979
|
-
this.currentObservable.subscription = this.currentObservable.query.subscribe({
|
|
5980
|
-
next: this.updateCurrentData.bind(this),
|
|
5981
|
-
error: this.updateError.bind(this),
|
|
5982
|
-
complete: this.completeSubscription.bind(this)
|
|
5983
|
-
});
|
|
5984
|
-
};
|
|
5985
|
-
SubscriptionData.prototype.getLoadingResult = function () {
|
|
5986
|
-
return {
|
|
5987
|
-
loading: true,
|
|
5988
|
-
error: undefined,
|
|
5989
|
-
data: undefined
|
|
5990
|
-
};
|
|
5991
|
-
};
|
|
5992
|
-
SubscriptionData.prototype.updateResult = function (result) {
|
|
5993
|
-
if (this.isMounted) {
|
|
5994
|
-
this.setResult(result);
|
|
5995
|
-
}
|
|
5996
|
-
};
|
|
5997
|
-
SubscriptionData.prototype.updateCurrentData = function (result) {
|
|
5998
|
-
var onSubscriptionData = this.getOptions().onSubscriptionData;
|
|
5999
|
-
this.updateResult({
|
|
6000
|
-
data: result.data,
|
|
6001
|
-
loading: false,
|
|
6002
|
-
error: undefined
|
|
6003
|
-
});
|
|
6004
|
-
if (onSubscriptionData) {
|
|
6005
|
-
onSubscriptionData({
|
|
6006
|
-
client: this.refreshClient().client,
|
|
6007
|
-
subscriptionData: result
|
|
6008
|
-
});
|
|
6009
|
-
}
|
|
6010
|
-
};
|
|
6011
|
-
SubscriptionData.prototype.updateError = function (error) {
|
|
6012
|
-
this.updateResult({
|
|
6013
|
-
error: error,
|
|
6014
|
-
loading: false
|
|
6015
|
-
});
|
|
6016
|
-
};
|
|
6017
|
-
SubscriptionData.prototype.completeSubscription = function () {
|
|
6018
|
-
var _this = this;
|
|
6019
|
-
Promise.resolve().then(function () {
|
|
6020
|
-
var onSubscriptionComplete = _this.getOptions().onSubscriptionComplete;
|
|
6021
|
-
if (onSubscriptionComplete)
|
|
6022
|
-
onSubscriptionComplete();
|
|
6023
|
-
_this.endSubscription();
|
|
6024
|
-
});
|
|
6025
|
-
};
|
|
6026
|
-
SubscriptionData.prototype.endSubscription = function () {
|
|
6027
|
-
if (this.currentObservable.subscription) {
|
|
6028
|
-
this.currentObservable.subscription.unsubscribe();
|
|
6029
|
-
delete this.currentObservable.subscription;
|
|
6030
|
-
}
|
|
6031
|
-
};
|
|
6032
|
-
return SubscriptionData;
|
|
6033
|
-
}(OperationData));
|
|
6034
|
-
|
|
6035
|
-
var MutationData = (function (_super) {
|
|
6036
|
-
tslib.__extends(MutationData, _super);
|
|
6037
|
-
function MutationData(_a) {
|
|
6038
|
-
var options = _a.options, context = _a.context, result = _a.result, setResult = _a.setResult;
|
|
6039
|
-
var _this = _super.call(this, options, context) || this;
|
|
6040
|
-
_this.runMutation = function (mutationFunctionOptions) {
|
|
6041
|
-
if (mutationFunctionOptions === void 0) { mutationFunctionOptions = {}; }
|
|
6042
|
-
_this.onMutationStart();
|
|
6043
|
-
var mutationId = _this.generateNewMutationId();
|
|
6044
|
-
return _this.mutate(mutationFunctionOptions)
|
|
6045
|
-
.then(function (response) {
|
|
6046
|
-
_this.onMutationCompleted(response, mutationId);
|
|
6047
|
-
return response;
|
|
6048
|
-
})
|
|
6049
|
-
.catch(function (error) {
|
|
6050
|
-
var onError = _this.getOptions().onError;
|
|
6051
|
-
_this.onMutationError(error, mutationId);
|
|
6052
|
-
if (onError) {
|
|
6053
|
-
onError(error);
|
|
6054
|
-
return {
|
|
6055
|
-
data: undefined,
|
|
6056
|
-
errors: error,
|
|
6057
|
-
};
|
|
6058
|
-
}
|
|
6059
|
-
else {
|
|
6060
|
-
throw error;
|
|
6061
|
-
}
|
|
6062
|
-
});
|
|
6063
|
-
};
|
|
6064
|
-
_this.verifyDocumentType(options.mutation, exports.DocumentType.Mutation);
|
|
6065
|
-
_this.result = result;
|
|
6066
|
-
_this.setResult = setResult;
|
|
6067
|
-
_this.mostRecentMutationId = 0;
|
|
6068
|
-
return _this;
|
|
6069
|
-
}
|
|
6070
|
-
MutationData.prototype.execute = function (result) {
|
|
6071
|
-
this.isMounted = true;
|
|
6072
|
-
this.verifyDocumentType(this.getOptions().mutation, exports.DocumentType.Mutation);
|
|
6073
|
-
return [
|
|
6074
|
-
this.runMutation,
|
|
6075
|
-
tslib.__assign(tslib.__assign({}, result), { client: this.refreshClient().client })
|
|
6076
|
-
];
|
|
6077
|
-
};
|
|
6078
|
-
MutationData.prototype.afterExecute = function () {
|
|
6079
|
-
this.isMounted = true;
|
|
6080
|
-
return this.unmount.bind(this);
|
|
6081
|
-
};
|
|
6082
|
-
MutationData.prototype.cleanup = function () {
|
|
6083
|
-
};
|
|
6084
|
-
MutationData.prototype.mutate = function (options) {
|
|
6085
|
-
return this.refreshClient().client.mutate(mergeOptions(this.getOptions(), options));
|
|
6086
|
-
};
|
|
6087
|
-
MutationData.prototype.onMutationStart = function () {
|
|
6088
|
-
if (!this.result.loading && !this.getOptions().ignoreResults) {
|
|
6089
|
-
this.updateResult({
|
|
6090
|
-
loading: true,
|
|
6091
|
-
error: undefined,
|
|
6092
|
-
data: undefined,
|
|
6093
|
-
called: true
|
|
6094
|
-
});
|
|
6095
|
-
}
|
|
6096
|
-
};
|
|
6097
|
-
MutationData.prototype.onMutationCompleted = function (response, mutationId) {
|
|
6098
|
-
var _a = this.getOptions(), onCompleted = _a.onCompleted, ignoreResults = _a.ignoreResults;
|
|
6099
|
-
var data = response.data, errors = response.errors;
|
|
6100
|
-
var error = errors && errors.length > 0
|
|
6101
|
-
? new ApolloError({ graphQLErrors: errors })
|
|
6102
|
-
: undefined;
|
|
6103
|
-
var callOncomplete = function () {
|
|
6104
|
-
return onCompleted ? onCompleted(data) : null;
|
|
6105
|
-
};
|
|
6106
|
-
if (this.isMostRecentMutation(mutationId) && !ignoreResults) {
|
|
6107
|
-
this.updateResult({
|
|
6108
|
-
called: true,
|
|
6109
|
-
loading: false,
|
|
6110
|
-
data: data,
|
|
6111
|
-
error: error
|
|
6112
|
-
});
|
|
6113
|
-
}
|
|
6114
|
-
callOncomplete();
|
|
6115
|
-
};
|
|
6116
|
-
MutationData.prototype.onMutationError = function (error, mutationId) {
|
|
6117
|
-
if (this.isMostRecentMutation(mutationId)) {
|
|
6118
|
-
this.updateResult({
|
|
6119
|
-
loading: false,
|
|
6120
|
-
error: error,
|
|
6121
|
-
data: undefined,
|
|
6122
|
-
called: true
|
|
6123
|
-
});
|
|
6124
|
-
}
|
|
6125
|
-
};
|
|
6126
|
-
MutationData.prototype.generateNewMutationId = function () {
|
|
6127
|
-
return ++this.mostRecentMutationId;
|
|
6128
|
-
};
|
|
6129
|
-
MutationData.prototype.isMostRecentMutation = function (mutationId) {
|
|
6130
|
-
return this.mostRecentMutationId === mutationId;
|
|
6131
|
-
};
|
|
6132
|
-
MutationData.prototype.updateResult = function (result) {
|
|
6133
|
-
if (this.isMounted &&
|
|
6134
|
-
(!this.previousResult || !equality.equal(this.previousResult, result))) {
|
|
6135
|
-
this.setResult(result);
|
|
6136
|
-
this.previousResult = result;
|
|
6137
|
-
return result;
|
|
6053
|
+
function useQuery(query, options) {
|
|
6054
|
+
var _a;
|
|
6055
|
+
var context = React.useContext(getApolloContext());
|
|
6056
|
+
var client = useApolloClient(options === null || options === void 0 ? void 0 : options.client);
|
|
6057
|
+
verifyDocumentType(query, exports.DocumentType.Query);
|
|
6058
|
+
var _b = React.useState(function () {
|
|
6059
|
+
var watchQueryOptions = createWatchQueryOptions(query, options);
|
|
6060
|
+
var obsQuery = null;
|
|
6061
|
+
if (context.renderPromises) {
|
|
6062
|
+
obsQuery = context.renderPromises.getSSRObservable(watchQueryOptions);
|
|
6063
|
+
}
|
|
6064
|
+
if (!obsQuery) {
|
|
6065
|
+
obsQuery = client.watchQuery(watchQueryOptions);
|
|
6066
|
+
if (context.renderPromises) {
|
|
6067
|
+
context.renderPromises.registerSSRObservable(obsQuery, watchQueryOptions);
|
|
6068
|
+
}
|
|
6069
|
+
}
|
|
6070
|
+
if (context.renderPromises &&
|
|
6071
|
+
(options === null || options === void 0 ? void 0 : options.ssr) !== false &&
|
|
6072
|
+
!(options === null || options === void 0 ? void 0 : options.skip) &&
|
|
6073
|
+
obsQuery.getCurrentResult().loading) {
|
|
6074
|
+
context.renderPromises.addQueryPromise({
|
|
6075
|
+
getOptions: function () { return createWatchQueryOptions(query, options); },
|
|
6076
|
+
fetchData: function () { return new Promise(function (resolve) {
|
|
6077
|
+
var sub = obsQuery.subscribe({
|
|
6078
|
+
next: function (result) {
|
|
6079
|
+
if (!result.loading) {
|
|
6080
|
+
resolve();
|
|
6081
|
+
sub.unsubscribe();
|
|
6082
|
+
}
|
|
6083
|
+
},
|
|
6084
|
+
error: function () {
|
|
6085
|
+
resolve();
|
|
6086
|
+
sub.unsubscribe();
|
|
6087
|
+
},
|
|
6088
|
+
complete: function () {
|
|
6089
|
+
resolve();
|
|
6090
|
+
},
|
|
6091
|
+
});
|
|
6092
|
+
}); },
|
|
6093
|
+
}, function () { return null; });
|
|
6138
6094
|
}
|
|
6139
|
-
|
|
6140
|
-
|
|
6141
|
-
|
|
6142
|
-
|
|
6143
|
-
var
|
|
6144
|
-
|
|
6145
|
-
|
|
6146
|
-
|
|
6147
|
-
var _this = _super.call(this, options, context) || this;
|
|
6148
|
-
_this.runLazy = false;
|
|
6149
|
-
_this.previous = Object.create(null);
|
|
6150
|
-
_this.runLazyQuery = function (options) {
|
|
6151
|
-
_this.cleanup();
|
|
6152
|
-
_this.runLazy = true;
|
|
6153
|
-
_this.lazyOptions = options;
|
|
6154
|
-
_this.onNewData();
|
|
6155
|
-
};
|
|
6156
|
-
_this.obsRefetch = function (variables) { var _a; return (_a = _this.currentObservable) === null || _a === void 0 ? void 0 : _a.refetch(variables); };
|
|
6157
|
-
_this.obsFetchMore = function (fetchMoreOptions) { var _a; return (_a = _this.currentObservable) === null || _a === void 0 ? void 0 : _a.fetchMore(fetchMoreOptions); };
|
|
6158
|
-
_this.obsUpdateQuery = function (mapFn) { var _a; return (_a = _this.currentObservable) === null || _a === void 0 ? void 0 : _a.updateQuery(mapFn); };
|
|
6159
|
-
_this.obsStartPolling = function (pollInterval) {
|
|
6160
|
-
var _a;
|
|
6161
|
-
(_a = _this.currentObservable) === null || _a === void 0 ? void 0 : _a.startPolling(pollInterval);
|
|
6162
|
-
};
|
|
6163
|
-
_this.obsStopPolling = function () {
|
|
6164
|
-
var _a;
|
|
6165
|
-
(_a = _this.currentObservable) === null || _a === void 0 ? void 0 : _a.stopPolling();
|
|
6166
|
-
};
|
|
6167
|
-
_this.obsSubscribeToMore = function (options) { var _a; return (_a = _this.currentObservable) === null || _a === void 0 ? void 0 : _a.subscribeToMore(options); };
|
|
6168
|
-
_this.onNewData = onNewData;
|
|
6169
|
-
return _this;
|
|
6170
|
-
}
|
|
6171
|
-
QueryData.prototype.execute = function () {
|
|
6172
|
-
this.refreshClient();
|
|
6173
|
-
var _a = this.getOptions(), skip = _a.skip, query = _a.query;
|
|
6174
|
-
if (skip || query !== this.previous.query) {
|
|
6175
|
-
this.removeQuerySubscription();
|
|
6176
|
-
this.removeObservable(!skip);
|
|
6177
|
-
this.previous.query = query;
|
|
6178
|
-
}
|
|
6179
|
-
this.updateObservableQuery();
|
|
6180
|
-
return this.getExecuteSsrResult() || this.getExecuteResult();
|
|
6181
|
-
};
|
|
6182
|
-
QueryData.prototype.executeLazy = function () {
|
|
6183
|
-
return !this.runLazy
|
|
6184
|
-
? [
|
|
6185
|
-
this.runLazyQuery,
|
|
6186
|
-
{
|
|
6187
|
-
loading: false,
|
|
6188
|
-
networkStatus: exports.NetworkStatus.ready,
|
|
6189
|
-
called: false,
|
|
6190
|
-
data: undefined
|
|
6191
|
-
}
|
|
6192
|
-
]
|
|
6193
|
-
: [this.runLazyQuery, this.execute()];
|
|
6194
|
-
};
|
|
6195
|
-
QueryData.prototype.fetchData = function () {
|
|
6196
|
-
var _this = this;
|
|
6197
|
-
var options = this.getOptions();
|
|
6198
|
-
if (options.skip || options.ssr === false)
|
|
6199
|
-
return false;
|
|
6200
|
-
return new Promise(function (resolve) { return _this.startQuerySubscription(resolve); });
|
|
6201
|
-
};
|
|
6202
|
-
QueryData.prototype.afterExecute = function (_a) {
|
|
6203
|
-
var _b = _a === void 0 ? {} : _a, _c = _b.lazy, lazy = _c === void 0 ? false : _c;
|
|
6204
|
-
this.isMounted = true;
|
|
6205
|
-
var options = this.getOptions();
|
|
6206
|
-
if (this.currentObservable && !this.ssrInitiated()) {
|
|
6207
|
-
this.startQuerySubscription();
|
|
6208
|
-
}
|
|
6209
|
-
if (!lazy || this.runLazy) {
|
|
6210
|
-
this.handleErrorOrCompleted();
|
|
6211
|
-
}
|
|
6212
|
-
this.previousOptions = options;
|
|
6213
|
-
return this.unmount.bind(this);
|
|
6214
|
-
};
|
|
6215
|
-
QueryData.prototype.cleanup = function () {
|
|
6216
|
-
this.removeQuerySubscription();
|
|
6217
|
-
this.removeObservable(true);
|
|
6218
|
-
delete this.previous.result;
|
|
6219
|
-
};
|
|
6220
|
-
QueryData.prototype.getOptions = function () {
|
|
6221
|
-
var options = _super.prototype.getOptions.call(this);
|
|
6222
|
-
if (this.lazyOptions) {
|
|
6223
|
-
options.variables = tslib.__assign(tslib.__assign({}, options.variables), this.lazyOptions.variables);
|
|
6224
|
-
options.context = tslib.__assign(tslib.__assign({}, options.context), this.lazyOptions.context);
|
|
6225
|
-
}
|
|
6226
|
-
if (this.runLazy) {
|
|
6227
|
-
delete options.skip;
|
|
6228
|
-
}
|
|
6229
|
-
return options;
|
|
6230
|
-
};
|
|
6231
|
-
QueryData.prototype.ssrInitiated = function () {
|
|
6232
|
-
return this.context && this.context.renderPromises;
|
|
6233
|
-
};
|
|
6234
|
-
QueryData.prototype.getExecuteSsrResult = function () {
|
|
6235
|
-
var _a = this.getOptions(), ssr = _a.ssr, skip = _a.skip;
|
|
6236
|
-
var ssrDisabled = ssr === false;
|
|
6237
|
-
var fetchDisabled = this.refreshClient().client.disableNetworkFetches;
|
|
6238
|
-
var ssrLoading = tslib.__assign({ loading: true, networkStatus: exports.NetworkStatus.loading, called: true, data: undefined, stale: false, client: this.client }, this.observableQueryFields());
|
|
6239
|
-
if (ssrDisabled && (this.ssrInitiated() || fetchDisabled)) {
|
|
6240
|
-
this.previous.result = ssrLoading;
|
|
6241
|
-
return ssrLoading;
|
|
6242
|
-
}
|
|
6243
|
-
if (this.ssrInitiated()) {
|
|
6244
|
-
var result = this.getExecuteResult() || ssrLoading;
|
|
6245
|
-
if (result.loading && !skip) {
|
|
6246
|
-
this.context.renderPromises.addQueryPromise(this, function () { return null; });
|
|
6095
|
+
return obsQuery;
|
|
6096
|
+
}), obsQuery = _b[0], setObsQuery = _b[1];
|
|
6097
|
+
var _c = React.useState(function () {
|
|
6098
|
+
var _a, _b;
|
|
6099
|
+
var result = obsQuery.getCurrentResult();
|
|
6100
|
+
if (!result.loading && options) {
|
|
6101
|
+
if (result.error) {
|
|
6102
|
+
(_a = options.onError) === null || _a === void 0 ? void 0 : _a.call(options, result.error);
|
|
6247
6103
|
}
|
|
6248
|
-
|
|
6249
|
-
|
|
6250
|
-
};
|
|
6251
|
-
QueryData.prototype.prepareObservableQueryOptions = function () {
|
|
6252
|
-
var options = this.getOptions();
|
|
6253
|
-
this.verifyDocumentType(options.query, exports.DocumentType.Query);
|
|
6254
|
-
var displayName = options.displayName || 'Query';
|
|
6255
|
-
if (this.ssrInitiated() &&
|
|
6256
|
-
(options.fetchPolicy === 'network-only' ||
|
|
6257
|
-
options.fetchPolicy === 'cache-and-network')) {
|
|
6258
|
-
options.fetchPolicy = 'cache-first';
|
|
6259
|
-
}
|
|
6260
|
-
return tslib.__assign(tslib.__assign({}, options), { displayName: displayName, context: options.context });
|
|
6261
|
-
};
|
|
6262
|
-
QueryData.prototype.initializeObservableQuery = function () {
|
|
6263
|
-
if (this.ssrInitiated()) {
|
|
6264
|
-
this.currentObservable = this.context.renderPromises.getSSRObservable(this.getOptions());
|
|
6265
|
-
}
|
|
6266
|
-
if (!this.currentObservable) {
|
|
6267
|
-
var observableQueryOptions = this.prepareObservableQueryOptions();
|
|
6268
|
-
this.previous.observableQueryOptions = tslib.__assign(tslib.__assign({}, observableQueryOptions), { children: void 0 });
|
|
6269
|
-
this.currentObservable = this.refreshClient().client.watchQuery(tslib.__assign({}, observableQueryOptions));
|
|
6270
|
-
if (this.ssrInitiated()) {
|
|
6271
|
-
this.context.renderPromises.registerSSRObservable(this.currentObservable, observableQueryOptions);
|
|
6104
|
+
else if (result.data) {
|
|
6105
|
+
(_b = options.onCompleted) === null || _b === void 0 ? void 0 : _b.call(options, result.data);
|
|
6272
6106
|
}
|
|
6273
6107
|
}
|
|
6274
|
-
|
|
6275
|
-
|
|
6276
|
-
|
|
6277
|
-
|
|
6278
|
-
|
|
6279
|
-
|
|
6280
|
-
|
|
6281
|
-
|
|
6282
|
-
|
|
6283
|
-
|
|
6284
|
-
|
|
6285
|
-
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6293
|
-
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
|
|
6298
|
-
|
|
6299
|
-
|
|
6300
|
-
|
|
6301
|
-
|
|
6302
|
-
|
|
6303
|
-
|
|
6304
|
-
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
|
|
6308
|
-
|
|
6309
|
-
|
|
6310
|
-
|
|
6311
|
-
|
|
6312
|
-
throw error;
|
|
6313
|
-
var previousResult = _this.previous.result;
|
|
6314
|
-
if ((previousResult && previousResult.loading) ||
|
|
6315
|
-
!equality.equal(error, _this.previous.error)) {
|
|
6316
|
-
_this.previous.error = error;
|
|
6317
|
-
onNewData();
|
|
6108
|
+
return result;
|
|
6109
|
+
}), result = _c[0], setResult = _c[1];
|
|
6110
|
+
var ref = React.useRef({
|
|
6111
|
+
client: client,
|
|
6112
|
+
query: query,
|
|
6113
|
+
options: options,
|
|
6114
|
+
result: result,
|
|
6115
|
+
previousData: void 0,
|
|
6116
|
+
watchQueryOptions: createWatchQueryOptions(query, options),
|
|
6117
|
+
});
|
|
6118
|
+
React.useEffect(function () {
|
|
6119
|
+
var _a, _b;
|
|
6120
|
+
var watchQueryOptions = createWatchQueryOptions(query, options);
|
|
6121
|
+
var nextResult;
|
|
6122
|
+
if (ref.current.client !== client || !equality.equal(ref.current.query, query)) {
|
|
6123
|
+
var obsQuery_1 = client.watchQuery(watchQueryOptions);
|
|
6124
|
+
setObsQuery(obsQuery_1);
|
|
6125
|
+
nextResult = obsQuery_1.getCurrentResult();
|
|
6126
|
+
}
|
|
6127
|
+
else if (!equality.equal(ref.current.watchQueryOptions, watchQueryOptions)) {
|
|
6128
|
+
obsQuery.setOptions(watchQueryOptions).catch(function () { });
|
|
6129
|
+
nextResult = obsQuery.getCurrentResult();
|
|
6130
|
+
ref.current.watchQueryOptions = watchQueryOptions;
|
|
6131
|
+
}
|
|
6132
|
+
if (nextResult) {
|
|
6133
|
+
var previousResult = ref.current.result;
|
|
6134
|
+
if (previousResult.data) {
|
|
6135
|
+
ref.current.previousData = previousResult.data;
|
|
6136
|
+
}
|
|
6137
|
+
setResult(ref.current.result = nextResult);
|
|
6138
|
+
if (!nextResult.loading && options) {
|
|
6139
|
+
if (!result.loading) {
|
|
6140
|
+
if (result.error) {
|
|
6141
|
+
(_a = options.onError) === null || _a === void 0 ? void 0 : _a.call(options, result.error);
|
|
6142
|
+
}
|
|
6143
|
+
else if (result.data) {
|
|
6144
|
+
(_b = options.onCompleted) === null || _b === void 0 ? void 0 : _b.call(options, result.data);
|
|
6145
|
+
}
|
|
6318
6146
|
}
|
|
6319
6147
|
}
|
|
6320
|
-
});
|
|
6321
|
-
};
|
|
6322
|
-
QueryData.prototype.resubscribeToQuery = function () {
|
|
6323
|
-
this.removeQuerySubscription();
|
|
6324
|
-
var currentObservable = this.currentObservable;
|
|
6325
|
-
if (currentObservable) {
|
|
6326
|
-
var last = currentObservable["last"];
|
|
6327
|
-
try {
|
|
6328
|
-
currentObservable.resetLastResults();
|
|
6329
|
-
this.startQuerySubscription();
|
|
6330
|
-
}
|
|
6331
|
-
finally {
|
|
6332
|
-
currentObservable["last"] = last;
|
|
6333
|
-
}
|
|
6334
6148
|
}
|
|
6335
|
-
|
|
6336
|
-
|
|
6337
|
-
|
|
6338
|
-
|
|
6339
|
-
|
|
6340
|
-
result = tslib.__assign(tslib.__assign({}, result), { data: undefined, error: undefined, loading: false, networkStatus: exports.NetworkStatus.ready, called: true });
|
|
6149
|
+
Object.assign(ref.current, { client: client, query: query });
|
|
6150
|
+
}, [obsQuery, client, query, options]);
|
|
6151
|
+
React.useEffect(function () {
|
|
6152
|
+
if (context.renderPromises) {
|
|
6153
|
+
return;
|
|
6341
6154
|
}
|
|
6342
|
-
|
|
6343
|
-
|
|
6344
|
-
var
|
|
6345
|
-
var
|
|
6346
|
-
|
|
6347
|
-
|
|
6155
|
+
var subscription = obsQuery.subscribe(onNext, onError);
|
|
6156
|
+
function onNext() {
|
|
6157
|
+
var _a, _b;
|
|
6158
|
+
var previousResult = ref.current.result;
|
|
6159
|
+
var result = obsQuery.getCurrentResult();
|
|
6160
|
+
if (previousResult &&
|
|
6161
|
+
previousResult.loading === result.loading &&
|
|
6162
|
+
previousResult.networkStatus === result.networkStatus &&
|
|
6163
|
+
equality.equal(previousResult.data, result.data)) {
|
|
6164
|
+
return;
|
|
6348
6165
|
}
|
|
6349
|
-
|
|
6350
|
-
|
|
6351
|
-
else if (error) {
|
|
6352
|
-
Object.assign(result, {
|
|
6353
|
-
data: (this.currentObservable.getLastResult() || {})
|
|
6354
|
-
.data
|
|
6355
|
-
});
|
|
6166
|
+
if (previousResult.data) {
|
|
6167
|
+
ref.current.previousData = previousResult.data;
|
|
6356
6168
|
}
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
if (partialRefetch &&
|
|
6361
|
-
partial &&
|
|
6362
|
-
(!data || Object.keys(data).length === 0) &&
|
|
6363
|
-
fetchPolicy !== 'cache-only') {
|
|
6364
|
-
Object.assign(result, {
|
|
6365
|
-
loading: true,
|
|
6366
|
-
networkStatus: exports.NetworkStatus.loading
|
|
6367
|
-
});
|
|
6368
|
-
result.refetch();
|
|
6369
|
-
return result;
|
|
6370
|
-
}
|
|
6169
|
+
setResult(ref.current.result = result);
|
|
6170
|
+
if (!result.loading) {
|
|
6171
|
+
(_b = (_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onCompleted) === null || _b === void 0 ? void 0 : _b.call(_a, result.data);
|
|
6371
6172
|
}
|
|
6372
6173
|
}
|
|
6373
|
-
|
|
6374
|
-
|
|
6375
|
-
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
this.previous.result = result;
|
|
6381
|
-
this.currentObservable && this.currentObservable.resetQueryStoreErrors();
|
|
6382
|
-
return result;
|
|
6383
|
-
};
|
|
6384
|
-
QueryData.prototype.handleErrorOrCompleted = function () {
|
|
6385
|
-
if (!this.currentObservable || !this.previous.result)
|
|
6386
|
-
return;
|
|
6387
|
-
var _a = this.previous.result, data = _a.data, loading = _a.loading, error = _a.error;
|
|
6388
|
-
if (!loading) {
|
|
6389
|
-
var _b = this.getOptions(), query = _b.query, variables = _b.variables, onCompleted = _b.onCompleted, onError = _b.onError, skip = _b.skip;
|
|
6390
|
-
if (this.previousOptions &&
|
|
6391
|
-
!this.previous.loading &&
|
|
6392
|
-
equality.equal(this.previousOptions.query, query) &&
|
|
6393
|
-
equality.equal(this.previousOptions.variables, variables)) {
|
|
6394
|
-
return;
|
|
6395
|
-
}
|
|
6396
|
-
if (onCompleted && !error && !skip) {
|
|
6397
|
-
onCompleted(data);
|
|
6174
|
+
function onError(error) {
|
|
6175
|
+
var _a, _b;
|
|
6176
|
+
var last = obsQuery["last"];
|
|
6177
|
+
subscription.unsubscribe();
|
|
6178
|
+
try {
|
|
6179
|
+
obsQuery.resetLastResults();
|
|
6180
|
+
subscription = obsQuery.subscribe(onNext, onError);
|
|
6398
6181
|
}
|
|
6399
|
-
|
|
6400
|
-
|
|
6182
|
+
finally {
|
|
6183
|
+
obsQuery["last"] = last;
|
|
6401
6184
|
}
|
|
6402
|
-
|
|
6403
|
-
|
|
6404
|
-
QueryData.prototype.removeQuerySubscription = function () {
|
|
6405
|
-
if (this.currentSubscription) {
|
|
6406
|
-
this.currentSubscription.unsubscribe();
|
|
6407
|
-
delete this.currentSubscription;
|
|
6408
|
-
}
|
|
6409
|
-
};
|
|
6410
|
-
QueryData.prototype.removeObservable = function (andDelete) {
|
|
6411
|
-
if (this.currentObservable) {
|
|
6412
|
-
this.currentObservable["tearDownQuery"]();
|
|
6413
|
-
if (andDelete) {
|
|
6414
|
-
delete this.currentObservable;
|
|
6185
|
+
if (!error.hasOwnProperty('graphQLErrors')) {
|
|
6186
|
+
throw error;
|
|
6415
6187
|
}
|
|
6416
|
-
|
|
6417
|
-
|
|
6418
|
-
|
|
6419
|
-
|
|
6420
|
-
|
|
6421
|
-
|
|
6422
|
-
|
|
6423
|
-
|
|
6424
|
-
|
|
6425
|
-
|
|
6426
|
-
|
|
6427
|
-
|
|
6188
|
+
var previousResult = ref.current.result;
|
|
6189
|
+
if ((previousResult && previousResult.loading) ||
|
|
6190
|
+
!equality.equal(error, previousResult.error)) {
|
|
6191
|
+
setResult(ref.current.result = {
|
|
6192
|
+
data: previousResult.data,
|
|
6193
|
+
error: error,
|
|
6194
|
+
loading: false,
|
|
6195
|
+
networkStatus: exports.NetworkStatus.error,
|
|
6196
|
+
});
|
|
6197
|
+
(_b = (_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onError) === null || _b === void 0 ? void 0 : _b.call(_a, error);
|
|
6198
|
+
}
|
|
6199
|
+
}
|
|
6200
|
+
return function () { return subscription.unsubscribe(); };
|
|
6201
|
+
}, [obsQuery, context.renderPromises, client.disableNetworkFetches]);
|
|
6202
|
+
var partial;
|
|
6203
|
+
(_a = result, partial = _a.partial, result = tslib.__rest(_a, ["partial"]));
|
|
6204
|
+
{
|
|
6205
|
+
if (partial &&
|
|
6206
|
+
(options === null || options === void 0 ? void 0 : options.partialRefetch) &&
|
|
6207
|
+
!result.loading &&
|
|
6208
|
+
(!result.data || Object.keys(result.data).length === 0) &&
|
|
6209
|
+
obsQuery.options.fetchPolicy !== 'cache-only') {
|
|
6210
|
+
result = tslib.__assign(tslib.__assign({}, result), { loading: true, networkStatus: exports.NetworkStatus.refetch });
|
|
6211
|
+
obsQuery.refetch();
|
|
6212
|
+
}
|
|
6213
|
+
if (context.renderPromises &&
|
|
6214
|
+
(options === null || options === void 0 ? void 0 : options.ssr) !== false &&
|
|
6215
|
+
!(options === null || options === void 0 ? void 0 : options.skip) &&
|
|
6216
|
+
result.loading) {
|
|
6217
|
+
obsQuery.setOptions(createWatchQueryOptions(query, options)).catch(function () { });
|
|
6218
|
+
}
|
|
6219
|
+
Object.assign(ref.current, { options: options });
|
|
6220
|
+
}
|
|
6221
|
+
if ((context.renderPromises || client.disableNetworkFetches) &&
|
|
6222
|
+
(options === null || options === void 0 ? void 0 : options.ssr) === false) {
|
|
6223
|
+
result = ref.current.result = {
|
|
6224
|
+
loading: true,
|
|
6225
|
+
data: void 0,
|
|
6226
|
+
error: void 0,
|
|
6227
|
+
networkStatus: exports.NetworkStatus.loading,
|
|
6428
6228
|
};
|
|
6429
|
-
};
|
|
6430
|
-
return QueryData;
|
|
6431
|
-
}(OperationData));
|
|
6432
|
-
|
|
6433
|
-
function useDeepMemo(memoFn, key) {
|
|
6434
|
-
var ref = React.useRef();
|
|
6435
|
-
if (!ref.current || !equality.equal(key, ref.current.key)) {
|
|
6436
|
-
ref.current = { key: key, value: memoFn() };
|
|
6437
6229
|
}
|
|
6438
|
-
|
|
6439
|
-
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
|
|
6230
|
+
else if ((options === null || options === void 0 ? void 0 : options.skip) || (options === null || options === void 0 ? void 0 : options.fetchPolicy) === 'standby') {
|
|
6231
|
+
result = {
|
|
6232
|
+
loading: false,
|
|
6233
|
+
data: void 0,
|
|
6234
|
+
error: void 0,
|
|
6235
|
+
networkStatus: exports.NetworkStatus.ready,
|
|
6236
|
+
};
|
|
6237
|
+
}
|
|
6238
|
+
if (result.errors && result.errors.length) {
|
|
6239
|
+
result = tslib.__assign(tslib.__assign({}, result), { error: result.error || new ApolloError({ graphQLErrors: result.errors }) });
|
|
6240
|
+
}
|
|
6241
|
+
var obsQueryFields = React.useMemo(function () { return ({
|
|
6242
|
+
refetch: obsQuery.refetch.bind(obsQuery),
|
|
6243
|
+
fetchMore: obsQuery.fetchMore.bind(obsQuery),
|
|
6244
|
+
updateQuery: obsQuery.updateQuery.bind(obsQuery),
|
|
6245
|
+
startPolling: obsQuery.startPolling.bind(obsQuery),
|
|
6246
|
+
stopPolling: obsQuery.stopPolling.bind(obsQuery),
|
|
6247
|
+
subscribeToMore: obsQuery.subscribeToMore.bind(obsQuery),
|
|
6248
|
+
}); }, [obsQuery]);
|
|
6249
|
+
return tslib.__assign(tslib.__assign(tslib.__assign({}, obsQueryFields), { variables: createWatchQueryOptions(query, options).variables, client: client, called: true, previousData: ref.current.previousData }), result);
|
|
6250
|
+
}
|
|
6251
|
+
function createWatchQueryOptions(query, options) {
|
|
6252
|
+
var _a;
|
|
6253
|
+
if (options === void 0) { options = {}; }
|
|
6254
|
+
var skip = options.skip; options.ssr; options.onCompleted; options.onError; options.displayName; var watchQueryOptions = tslib.__rest(options, ["skip", "ssr", "onCompleted", "onError", "displayName"]);
|
|
6255
|
+
if (skip) {
|
|
6256
|
+
watchQueryOptions.fetchPolicy = 'standby';
|
|
6257
|
+
}
|
|
6258
|
+
else if (((_a = watchQueryOptions.context) === null || _a === void 0 ? void 0 : _a.renderPromises) &&
|
|
6259
|
+
(watchQueryOptions.fetchPolicy === 'network-only' ||
|
|
6260
|
+
watchQueryOptions.fetchPolicy === 'cache-and-network')) {
|
|
6261
|
+
watchQueryOptions.fetchPolicy = 'cache-first';
|
|
6262
|
+
}
|
|
6263
|
+
else if (!watchQueryOptions.fetchPolicy) {
|
|
6264
|
+
watchQueryOptions.fetchPolicy = 'cache-first';
|
|
6455
6265
|
}
|
|
6266
|
+
if (!watchQueryOptions.variables) {
|
|
6267
|
+
watchQueryOptions.variables = {};
|
|
6268
|
+
}
|
|
6269
|
+
return tslib.__assign({ query: query }, watchQueryOptions);
|
|
6456
6270
|
}
|
|
6457
6271
|
|
|
6458
|
-
|
|
6459
|
-
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
|
|
6463
|
-
|
|
6464
|
-
|
|
6465
|
-
|
|
6466
|
-
|
|
6467
|
-
|
|
6468
|
-
|
|
6469
|
-
|
|
6470
|
-
|
|
6471
|
-
|
|
6472
|
-
|
|
6272
|
+
var EAGER_METHODS = [
|
|
6273
|
+
'refetch',
|
|
6274
|
+
'fetchMore',
|
|
6275
|
+
'updateQuery',
|
|
6276
|
+
'startPolling',
|
|
6277
|
+
'subscribeToMore',
|
|
6278
|
+
];
|
|
6279
|
+
function useLazyQuery(query, options) {
|
|
6280
|
+
var _a = React.useState({
|
|
6281
|
+
called: false,
|
|
6282
|
+
resolves: [],
|
|
6283
|
+
}), execution = _a[0], setExecution = _a[1];
|
|
6284
|
+
var execute = React.useCallback(function (executeOptions) {
|
|
6285
|
+
var resolve;
|
|
6286
|
+
var promise = new Promise(function (resolve1) { return (resolve = resolve1); });
|
|
6287
|
+
setExecution(function (execution) {
|
|
6288
|
+
if (execution.called) {
|
|
6289
|
+
result && result.refetch(executeOptions === null || executeOptions === void 0 ? void 0 : executeOptions.variables);
|
|
6473
6290
|
}
|
|
6474
|
-
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
|
|
6478
|
-
|
|
6479
|
-
|
|
6480
|
-
|
|
6481
|
-
|
|
6482
|
-
};
|
|
6483
|
-
var result = useDeepMemo(function () { return (lazy ? queryData.executeLazy() : queryData.execute()); }, memo);
|
|
6484
|
-
var queryResult = lazy
|
|
6485
|
-
? result[1]
|
|
6486
|
-
: result;
|
|
6487
|
-
if (__DEV__) {
|
|
6488
|
-
useAfterFastRefresh(forceUpdate);
|
|
6489
|
-
}
|
|
6291
|
+
return {
|
|
6292
|
+
called: true,
|
|
6293
|
+
resolves: tslib.__spreadArray(tslib.__spreadArray([], execution.resolves, true), [resolve], false),
|
|
6294
|
+
options: executeOptions,
|
|
6295
|
+
};
|
|
6296
|
+
});
|
|
6297
|
+
return promise;
|
|
6298
|
+
}, []);
|
|
6299
|
+
var result = useQuery(query, tslib.__assign(tslib.__assign(tslib.__assign({}, options), execution.options), { fetchPolicy: execution.called ? options === null || options === void 0 ? void 0 : options.fetchPolicy : 'standby', skip: undefined }));
|
|
6490
6300
|
React.useEffect(function () {
|
|
6491
|
-
|
|
6492
|
-
|
|
6493
|
-
|
|
6301
|
+
var resolves = execution.resolves;
|
|
6302
|
+
if (!result.loading && resolves.length) {
|
|
6303
|
+
setExecution(function (execution) { return (tslib.__assign(tslib.__assign({}, execution), { resolves: [] })); });
|
|
6304
|
+
resolves.forEach(function (resolve) { return resolve(result); });
|
|
6305
|
+
}
|
|
6306
|
+
}, [result, execution]);
|
|
6307
|
+
if (!execution.called) {
|
|
6308
|
+
result = tslib.__assign(tslib.__assign({}, result), { loading: false, data: void 0, error: void 0, called: false });
|
|
6309
|
+
var _loop_1 = function (key) {
|
|
6310
|
+
var method = result[key];
|
|
6311
|
+
result[key] = function () {
|
|
6312
|
+
var args = [];
|
|
6313
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
6314
|
+
args[_i] = arguments[_i];
|
|
6315
|
+
}
|
|
6316
|
+
setExecution(function (execution) { return (tslib.__assign(tslib.__assign({}, execution), { called: true })); });
|
|
6317
|
+
return method.apply(void 0, args);
|
|
6318
|
+
};
|
|
6494
6319
|
};
|
|
6495
|
-
|
|
6496
|
-
|
|
6497
|
-
|
|
6498
|
-
|
|
6499
|
-
|
|
6500
|
-
|
|
6501
|
-
queryData.currentObservable,
|
|
6502
|
-
]);
|
|
6503
|
-
return result;
|
|
6504
|
-
}
|
|
6505
|
-
|
|
6506
|
-
function useLazyQuery(query, options) {
|
|
6507
|
-
return useBaseQuery(query, options, true);
|
|
6320
|
+
for (var _i = 0, EAGER_METHODS_1 = EAGER_METHODS; _i < EAGER_METHODS_1.length; _i++) {
|
|
6321
|
+
var key = EAGER_METHODS_1[_i];
|
|
6322
|
+
_loop_1(key);
|
|
6323
|
+
}
|
|
6324
|
+
}
|
|
6325
|
+
return [execute, result];
|
|
6508
6326
|
}
|
|
6509
6327
|
|
|
6510
6328
|
function useMutation(mutation, options) {
|
|
6511
|
-
var
|
|
6512
|
-
|
|
6513
|
-
var
|
|
6514
|
-
|
|
6515
|
-
|
|
6516
|
-
|
|
6517
|
-
|
|
6518
|
-
|
|
6519
|
-
|
|
6520
|
-
|
|
6521
|
-
|
|
6329
|
+
var client = useApolloClient(options === null || options === void 0 ? void 0 : options.client);
|
|
6330
|
+
verifyDocumentType(mutation, exports.DocumentType.Mutation);
|
|
6331
|
+
var _a = React.useState({
|
|
6332
|
+
called: false,
|
|
6333
|
+
loading: false,
|
|
6334
|
+
client: client,
|
|
6335
|
+
}), result = _a[0], setResult = _a[1];
|
|
6336
|
+
var ref = React.useRef({
|
|
6337
|
+
result: result,
|
|
6338
|
+
mutationId: 0,
|
|
6339
|
+
isMounted: true,
|
|
6340
|
+
client: client,
|
|
6341
|
+
mutation: mutation,
|
|
6342
|
+
options: options,
|
|
6343
|
+
});
|
|
6344
|
+
{
|
|
6345
|
+
Object.assign(ref.current, { client: client, options: options, mutation: mutation });
|
|
6346
|
+
}
|
|
6347
|
+
var execute = React.useCallback(function (executeOptions) {
|
|
6348
|
+
if (executeOptions === void 0) { executeOptions = {}; }
|
|
6349
|
+
var _a = ref.current, client = _a.client, options = _a.options, mutation = _a.mutation;
|
|
6350
|
+
var baseOptions = tslib.__assign(tslib.__assign({}, options), { mutation: mutation });
|
|
6351
|
+
if (!ref.current.result.loading && !baseOptions.ignoreResults) {
|
|
6352
|
+
setResult(ref.current.result = {
|
|
6353
|
+
loading: true,
|
|
6354
|
+
error: void 0,
|
|
6355
|
+
data: void 0,
|
|
6356
|
+
called: true,
|
|
6357
|
+
client: client,
|
|
6522
6358
|
});
|
|
6523
6359
|
}
|
|
6524
|
-
|
|
6525
|
-
|
|
6526
|
-
|
|
6527
|
-
|
|
6528
|
-
|
|
6529
|
-
|
|
6530
|
-
|
|
6531
|
-
|
|
6532
|
-
|
|
6533
|
-
|
|
6534
|
-
|
|
6360
|
+
var mutationId = ++ref.current.mutationId;
|
|
6361
|
+
var clientOptions = mergeOptions(baseOptions, executeOptions);
|
|
6362
|
+
return client.mutate(clientOptions).then(function (response) {
|
|
6363
|
+
var _a, _b;
|
|
6364
|
+
var data = response.data, errors = response.errors;
|
|
6365
|
+
var error = errors && errors.length > 0
|
|
6366
|
+
? new ApolloError({ graphQLErrors: errors })
|
|
6367
|
+
: void 0;
|
|
6368
|
+
if (mutationId === ref.current.mutationId &&
|
|
6369
|
+
!clientOptions.ignoreResults) {
|
|
6370
|
+
var result_1 = {
|
|
6371
|
+
called: true,
|
|
6372
|
+
loading: false,
|
|
6373
|
+
data: data,
|
|
6374
|
+
error: error,
|
|
6375
|
+
client: client,
|
|
6376
|
+
};
|
|
6377
|
+
if (ref.current.isMounted && !equality.equal(ref.current.result, result_1)) {
|
|
6378
|
+
setResult(ref.current.result = result_1);
|
|
6379
|
+
}
|
|
6380
|
+
}
|
|
6381
|
+
(_a = baseOptions.onCompleted) === null || _a === void 0 ? void 0 : _a.call(baseOptions, response.data);
|
|
6382
|
+
(_b = executeOptions.onCompleted) === null || _b === void 0 ? void 0 : _b.call(executeOptions, response.data);
|
|
6383
|
+
return response;
|
|
6384
|
+
}).catch(function (error) {
|
|
6385
|
+
var _a, _b;
|
|
6386
|
+
if (mutationId === ref.current.mutationId &&
|
|
6387
|
+
ref.current.isMounted) {
|
|
6388
|
+
var result_2 = {
|
|
6389
|
+
loading: false,
|
|
6390
|
+
error: error,
|
|
6391
|
+
data: void 0,
|
|
6392
|
+
called: true,
|
|
6393
|
+
client: client,
|
|
6394
|
+
};
|
|
6395
|
+
if (!equality.equal(ref.current.result, result_2)) {
|
|
6396
|
+
setResult(ref.current.result = result_2);
|
|
6397
|
+
}
|
|
6398
|
+
}
|
|
6399
|
+
if (baseOptions.onError || clientOptions.onError) {
|
|
6400
|
+
(_a = baseOptions.onError) === null || _a === void 0 ? void 0 : _a.call(baseOptions, error);
|
|
6401
|
+
(_b = executeOptions.onError) === null || _b === void 0 ? void 0 : _b.call(executeOptions, error);
|
|
6402
|
+
return { data: void 0, errors: error };
|
|
6403
|
+
}
|
|
6404
|
+
throw error;
|
|
6405
|
+
});
|
|
6406
|
+
}, []);
|
|
6407
|
+
var reset = React.useCallback(function () {
|
|
6408
|
+
setResult({ called: false, loading: false, client: client });
|
|
6409
|
+
}, []);
|
|
6410
|
+
React.useEffect(function () { return function () {
|
|
6411
|
+
ref.current.isMounted = false;
|
|
6412
|
+
}; }, []);
|
|
6413
|
+
return [execute, tslib.__assign({ reset: reset }, result)];
|
|
6535
6414
|
}
|
|
6536
6415
|
|
|
6537
6416
|
function useSubscription(subscription, options) {
|
|
6538
|
-
var
|
|
6539
|
-
|
|
6540
|
-
var
|
|
6541
|
-
|
|
6542
|
-
var _b = React.useState({
|
|
6543
|
-
loading: !updatedOptions.skip,
|
|
6417
|
+
var client = useApolloClient(options === null || options === void 0 ? void 0 : options.client);
|
|
6418
|
+
verifyDocumentType(subscription, exports.DocumentType.Subscription);
|
|
6419
|
+
var _a = React.useState({
|
|
6420
|
+
loading: !(options === null || options === void 0 ? void 0 : options.skip),
|
|
6544
6421
|
error: void 0,
|
|
6545
6422
|
data: void 0,
|
|
6546
|
-
|
|
6547
|
-
|
|
6548
|
-
function
|
|
6549
|
-
if (
|
|
6550
|
-
|
|
6551
|
-
options: updatedOptions,
|
|
6552
|
-
context: context,
|
|
6553
|
-
setResult: setResult
|
|
6554
|
-
});
|
|
6423
|
+
variables: options === null || options === void 0 ? void 0 : options.variables,
|
|
6424
|
+
}), result = _a[0], setResult = _a[1];
|
|
6425
|
+
var _b = React.useState(function () {
|
|
6426
|
+
if (options === null || options === void 0 ? void 0 : options.skip) {
|
|
6427
|
+
return null;
|
|
6555
6428
|
}
|
|
6556
|
-
return
|
|
6557
|
-
|
|
6558
|
-
|
|
6559
|
-
|
|
6560
|
-
|
|
6561
|
-
|
|
6562
|
-
|
|
6563
|
-
}
|
|
6564
|
-
React.useEffect(function () {
|
|
6429
|
+
return client.subscribe({
|
|
6430
|
+
query: subscription,
|
|
6431
|
+
variables: options === null || options === void 0 ? void 0 : options.variables,
|
|
6432
|
+
fetchPolicy: options === null || options === void 0 ? void 0 : options.fetchPolicy,
|
|
6433
|
+
context: options === null || options === void 0 ? void 0 : options.context,
|
|
6434
|
+
});
|
|
6435
|
+
}), observable = _b[0], setObservable = _b[1];
|
|
6436
|
+
var ref = React.useRef({ client: client, subscription: subscription, options: options });
|
|
6437
|
+
React.useEffect(function () {
|
|
6438
|
+
var _a, _b, _c, _d;
|
|
6439
|
+
var shouldResubscribe = options === null || options === void 0 ? void 0 : options.shouldResubscribe;
|
|
6440
|
+
if (typeof shouldResubscribe === 'function') {
|
|
6441
|
+
shouldResubscribe = !!shouldResubscribe(options);
|
|
6442
|
+
}
|
|
6443
|
+
if ((options === null || options === void 0 ? void 0 : options.skip) && !(options === null || options === void 0 ? void 0 : options.skip) !== !((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.skip)) {
|
|
6444
|
+
setResult({
|
|
6445
|
+
loading: false,
|
|
6446
|
+
data: void 0,
|
|
6447
|
+
error: void 0,
|
|
6448
|
+
variables: options === null || options === void 0 ? void 0 : options.variables,
|
|
6449
|
+
});
|
|
6450
|
+
setObservable(null);
|
|
6451
|
+
}
|
|
6452
|
+
else if (shouldResubscribe !== false && (client !== ref.current.client ||
|
|
6453
|
+
subscription !== ref.current.subscription ||
|
|
6454
|
+
(options === null || options === void 0 ? void 0 : options.fetchPolicy) !== ((_b = ref.current.options) === null || _b === void 0 ? void 0 : _b.fetchPolicy) ||
|
|
6455
|
+
!(options === null || options === void 0 ? void 0 : options.skip) !== !((_c = ref.current.options) === null || _c === void 0 ? void 0 : _c.skip) ||
|
|
6456
|
+
!equality.equal(options === null || options === void 0 ? void 0 : options.variables, (_d = ref.current.options) === null || _d === void 0 ? void 0 : _d.variables))) {
|
|
6457
|
+
setResult({
|
|
6458
|
+
loading: true,
|
|
6459
|
+
data: void 0,
|
|
6460
|
+
error: void 0,
|
|
6461
|
+
variables: options === null || options === void 0 ? void 0 : options.variables,
|
|
6462
|
+
});
|
|
6463
|
+
setObservable(client.subscribe({
|
|
6464
|
+
query: subscription,
|
|
6465
|
+
variables: options === null || options === void 0 ? void 0 : options.variables,
|
|
6466
|
+
fetchPolicy: options === null || options === void 0 ? void 0 : options.fetchPolicy,
|
|
6467
|
+
context: options === null || options === void 0 ? void 0 : options.context,
|
|
6468
|
+
}));
|
|
6469
|
+
}
|
|
6470
|
+
Object.assign(ref.current, { client: client, subscription: subscription, options: options });
|
|
6471
|
+
}, [client, subscription, options]);
|
|
6565
6472
|
React.useEffect(function () {
|
|
6473
|
+
if (!observable) {
|
|
6474
|
+
return;
|
|
6475
|
+
}
|
|
6476
|
+
var subscription = observable.subscribe({
|
|
6477
|
+
next: function (fetchResult) {
|
|
6478
|
+
var _a, _b;
|
|
6479
|
+
var result = {
|
|
6480
|
+
loading: false,
|
|
6481
|
+
data: fetchResult.data,
|
|
6482
|
+
error: void 0,
|
|
6483
|
+
variables: options === null || options === void 0 ? void 0 : options.variables,
|
|
6484
|
+
};
|
|
6485
|
+
setResult(result);
|
|
6486
|
+
(_b = (_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onSubscriptionData) === null || _b === void 0 ? void 0 : _b.call(_a, {
|
|
6487
|
+
client: client,
|
|
6488
|
+
subscriptionData: result
|
|
6489
|
+
});
|
|
6490
|
+
},
|
|
6491
|
+
error: function (error) {
|
|
6492
|
+
setResult({
|
|
6493
|
+
loading: false,
|
|
6494
|
+
data: void 0,
|
|
6495
|
+
error: error,
|
|
6496
|
+
variables: options === null || options === void 0 ? void 0 : options.variables,
|
|
6497
|
+
});
|
|
6498
|
+
},
|
|
6499
|
+
complete: function () {
|
|
6500
|
+
var _a, _b;
|
|
6501
|
+
(_b = (_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onSubscriptionComplete) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
6502
|
+
},
|
|
6503
|
+
});
|
|
6566
6504
|
return function () {
|
|
6567
|
-
|
|
6568
|
-
subscriptionDataRef.current = void 0;
|
|
6505
|
+
subscription.unsubscribe();
|
|
6569
6506
|
};
|
|
6570
|
-
}, []);
|
|
6571
|
-
return
|
|
6507
|
+
}, [observable]);
|
|
6508
|
+
return result;
|
|
6572
6509
|
}
|
|
6573
6510
|
|
|
6574
6511
|
function useReactiveVar(rv) {
|
|
@@ -6609,6 +6546,7 @@ exports.concat = concat;
|
|
|
6609
6546
|
exports.createHttpLink = createHttpLink;
|
|
6610
6547
|
exports.createSignalIfSupported = createSignalIfSupported;
|
|
6611
6548
|
exports.defaultDataIdFromObject = defaultDataIdFromObject;
|
|
6549
|
+
exports.defaultPrinter = defaultPrinter;
|
|
6612
6550
|
exports.empty = empty;
|
|
6613
6551
|
exports.execute = execute;
|
|
6614
6552
|
exports.fallbackHttpConfig = fallbackHttpConfig;
|
|
@@ -6627,6 +6565,7 @@ exports.parser = parser;
|
|
|
6627
6565
|
exports.resetApolloContext = getApolloContext;
|
|
6628
6566
|
exports.rewriteURIForGET = rewriteURIForGET;
|
|
6629
6567
|
exports.selectHttpOptionsAndBody = selectHttpOptionsAndBody;
|
|
6568
|
+
exports.selectHttpOptionsAndBodyInternal = selectHttpOptionsAndBodyInternal;
|
|
6630
6569
|
exports.selectURI = selectURI;
|
|
6631
6570
|
exports.serializeFetchParameter = serializeFetchParameter;
|
|
6632
6571
|
exports.split = split;
|
|
@@ -6638,4 +6577,4 @@ exports.useMutation = useMutation;
|
|
|
6638
6577
|
exports.useQuery = useQuery;
|
|
6639
6578
|
exports.useReactiveVar = useReactiveVar;
|
|
6640
6579
|
exports.useSubscription = useSubscription;
|
|
6641
|
-
//# sourceMappingURL=apollo-client.cjs.
|
|
6580
|
+
//# sourceMappingURL=apollo-client.cjs.map
|