@apollo/client 3.8.1 → 3.8.3
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/apollo-client.cjs +708 -575
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +253 -191
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +253 -191
- package/cache/core/cache.d.ts +4 -4
- package/cache/core/cache.d.ts.map +1 -1
- package/cache/core/cache.js +10 -7
- package/cache/core/cache.js.map +1 -1
- package/cache/core/types/Cache.d.ts +3 -3
- package/cache/core/types/Cache.d.ts.map +1 -1
- package/cache/core/types/Cache.js +0 -1
- package/cache/core/types/Cache.js.map +1 -1
- package/cache/core/types/DataProxy.d.ts +6 -6
- 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 +3 -3
- package/cache/core/types/common.d.ts.map +1 -1
- package/cache/core/types/common.js.map +1 -1
- package/cache/index.d.ts +20 -20
- package/cache/index.d.ts.map +1 -1
- package/cache/index.js +13 -13
- package/cache/index.js.map +1 -1
- package/cache/inmemory/entityStore.d.ts +6 -6
- package/cache/inmemory/entityStore.d.ts.map +1 -1
- package/cache/inmemory/entityStore.js +38 -30
- package/cache/inmemory/entityStore.js.map +1 -1
- package/cache/inmemory/fixPolyfills.native.d.ts.map +1 -1
- package/cache/inmemory/fixPolyfills.native.js +10 -9
- package/cache/inmemory/fixPolyfills.native.js.map +1 -1
- package/cache/inmemory/fragmentRegistry.d.ts.map +1 -1
- package/cache/inmemory/fragmentRegistry.js +6 -4
- package/cache/inmemory/fragmentRegistry.js.map +1 -1
- package/cache/inmemory/helpers.d.ts +6 -6
- package/cache/inmemory/helpers.d.ts.map +1 -1
- package/cache/inmemory/helpers.js +16 -14
- package/cache/inmemory/helpers.js.map +1 -1
- package/cache/inmemory/inMemoryCache.d.ts +9 -9
- package/cache/inmemory/inMemoryCache.d.ts.map +1 -1
- package/cache/inmemory/inMemoryCache.js +29 -33
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/key-extractor.d.ts.map +1 -1
- package/cache/inmemory/key-extractor.js +55 -49
- package/cache/inmemory/key-extractor.js.map +1 -1
- package/cache/inmemory/object-canon.d.ts.map +1 -1
- package/cache/inmemory/object-canon.js +5 -5
- package/cache/inmemory/object-canon.js.map +1 -1
- package/cache/inmemory/policies.d.ts +6 -6
- package/cache/inmemory/policies.d.ts.map +1 -1
- package/cache/inmemory/policies.js +74 -45
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/reactiveVars.d.ts +1 -1
- package/cache/inmemory/reactiveVars.d.ts.map +1 -1
- package/cache/inmemory/reactiveVars.js +5 -5
- package/cache/inmemory/reactiveVars.js.map +1 -1
- package/cache/inmemory/readFromStore.d.ts +7 -7
- package/cache/inmemory/readFromStore.d.ts.map +1 -1
- package/cache/inmemory/readFromStore.js +21 -17
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/types.d.ts +7 -7
- package/cache/inmemory/types.d.ts.map +1 -1
- package/cache/inmemory/types.js +0 -2
- package/cache/inmemory/types.js.map +1 -1
- package/cache/inmemory/writeToStore.d.ts +7 -7
- package/cache/inmemory/writeToStore.d.ts.map +1 -1
- package/cache/inmemory/writeToStore.js +40 -30
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/config/jest/setup.d.ts +2 -2
- package/config/jest/setup.js +5 -5
- package/config/jest/setup.js.map +1 -1
- package/core/ApolloClient.d.ts +12 -11
- package/core/ApolloClient.d.ts.map +1 -1
- package/core/ApolloClient.js +75 -57
- package/core/ApolloClient.js.map +1 -1
- package/core/LocalState.d.ts +6 -6
- package/core/LocalState.d.ts.map +1 -1
- package/core/LocalState.js +17 -16
- package/core/LocalState.js.map +1 -1
- package/core/ObservableQuery.d.ts +12 -10
- package/core/ObservableQuery.d.ts.map +1 -1
- package/core/ObservableQuery.js +57 -38
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +11 -11
- package/core/QueryInfo.d.ts.map +1 -1
- package/core/QueryInfo.js +28 -34
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +10 -10
- package/core/QueryManager.d.ts.map +1 -1
- package/core/QueryManager.js +117 -93
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +266 -206
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +266 -206
- package/core/networkStatus.js.map +1 -1
- package/core/types.d.ts +13 -13
- package/core/types.d.ts.map +1 -1
- package/core/types.js +0 -1
- package/core/types.js.map +1 -1
- package/core/watchQueryOptions.d.ts +11 -11
- package/core/watchQueryOptions.d.ts.map +1 -1
- package/core/watchQueryOptions.js.map +1 -1
- package/dev/dev.cjs +44 -40
- package/dev/dev.cjs.map +1 -1
- package/dev/dev.cjs.native.js +44 -40
- package/errors/errors.cjs +7 -5
- package/errors/errors.cjs.map +1 -1
- package/errors/errors.cjs.native.js +7 -5
- package/errors/index.d.ts +4 -4
- package/errors/index.d.ts.map +1 -1
- package/errors/index.js +9 -7
- package/errors/index.js.map +1 -1
- package/index.d.ts +2 -2
- package/index.js +2 -2
- package/index.js.map +1 -1
- package/invariantErrorCodes.d.ts.map +1 -1
- package/invariantErrorCodes.js +36 -36
- package/invariantErrorCodes.js.map +1 -1
- package/link/batch/batch.cjs +4 -4
- package/link/batch/batch.cjs.map +1 -1
- package/link/batch/batch.cjs.native.js +4 -4
- package/link/batch/batchLink.d.ts +6 -6
- package/link/batch/batchLink.d.ts.map +1 -1
- package/link/batch/batchLink.js +4 -4
- package/link/batch/batchLink.js.map +1 -1
- package/link/batch/batching.d.ts +2 -2
- package/link/batch/batching.d.ts.map +1 -1
- package/link/batch/batching.js +4 -4
- package/link/batch/batching.js.map +1 -1
- package/link/batch/index.d.ts +1 -1
- package/link/batch/index.js +1 -1
- package/link/batch/index.js.map +1 -1
- package/link/batch-http/batch-http.cjs +13 -11
- package/link/batch-http/batch-http.cjs.map +1 -1
- package/link/batch-http/batch-http.cjs.native.js +13 -11
- package/link/batch-http/batchHttpLink.d.ts +6 -6
- package/link/batch-http/batchHttpLink.d.ts.map +1 -1
- package/link/batch-http/batchHttpLink.js +17 -15
- package/link/batch-http/batchHttpLink.js.map +1 -1
- package/link/batch-http/index.d.ts +1 -1
- package/link/batch-http/index.js +1 -1
- package/link/batch-http/index.js.map +1 -1
- package/link/context/context.cjs.map +1 -1
- package/link/context/index.d.ts +3 -3
- package/link/context/index.js +2 -2
- package/link/context/index.js.map +1 -1
- package/link/core/ApolloLink.d.ts +3 -3
- package/link/core/ApolloLink.js +4 -4
- package/link/core/ApolloLink.js.map +1 -1
- package/link/core/concat.d.ts +1 -1
- package/link/core/concat.js +1 -1
- package/link/core/concat.js.map +1 -1
- package/link/core/core.cjs +1 -1
- package/link/core/core.cjs.map +1 -1
- package/link/core/core.cjs.native.js +1 -1
- package/link/core/empty.d.ts +1 -1
- package/link/core/empty.js +1 -1
- package/link/core/empty.js.map +1 -1
- package/link/core/execute.d.ts +1 -1
- package/link/core/execute.js +1 -1
- package/link/core/execute.js.map +1 -1
- package/link/core/from.d.ts +1 -1
- package/link/core/from.js +1 -1
- package/link/core/from.js.map +1 -1
- package/link/core/index.d.ts +8 -8
- package/link/core/index.js +8 -8
- package/link/core/index.js.map +1 -1
- package/link/core/split.d.ts +1 -1
- package/link/core/split.js +1 -1
- package/link/core/split.js.map +1 -1
- package/link/core/types.js.map +1 -1
- package/link/error/error.cjs.map +1 -1
- package/link/error/index.d.ts +5 -5
- package/link/error/index.js +2 -2
- package/link/error/index.js.map +1 -1
- package/link/http/HttpLink.d.ts +3 -3
- package/link/http/HttpLink.js +2 -2
- package/link/http/HttpLink.js.map +1 -1
- package/link/http/checkFetcher.d.ts +1 -1
- package/link/http/checkFetcher.d.ts.map +1 -1
- package/link/http/checkFetcher.js +2 -2
- package/link/http/checkFetcher.js.map +1 -1
- package/link/http/createHttpLink.d.ts +2 -2
- package/link/http/createHttpLink.d.ts.map +1 -1
- package/link/http/createHttpLink.js +27 -26
- package/link/http/createHttpLink.js.map +1 -1
- package/link/http/createSignalIfSupported.js +1 -1
- package/link/http/createSignalIfSupported.js.map +1 -1
- package/link/http/http.cjs +39 -35
- package/link/http/http.cjs.map +1 -1
- package/link/http/http.cjs.native.js +39 -35
- package/link/http/index.d.ts +13 -13
- package/link/http/index.js +10 -10
- package/link/http/index.js.map +1 -1
- package/link/http/iterators/nodeStream.d.ts.map +1 -1
- package/link/http/iterators/nodeStream.js.map +1 -1
- package/link/http/parseAndCheckHttpResponse.d.ts.map +1 -1
- package/link/http/parseAndCheckHttpResponse.js +2 -2
- package/link/http/parseAndCheckHttpResponse.js.map +1 -1
- package/link/http/rewriteURIForGET.d.ts +1 -1
- package/link/http/rewriteURIForGET.js +12 -12
- package/link/http/rewriteURIForGET.js.map +1 -1
- package/link/http/selectHttpOptionsAndBody.d.ts +5 -5
- package/link/http/selectHttpOptionsAndBody.d.ts.map +1 -1
- package/link/http/selectHttpOptionsAndBody.js +8 -7
- package/link/http/selectHttpOptionsAndBody.js.map +1 -1
- package/link/http/selectURI.d.ts +1 -1
- package/link/http/selectURI.js +2 -2
- package/link/http/selectURI.js.map +1 -1
- package/link/http/serializeFetchParameter.d.ts +1 -1
- package/link/http/serializeFetchParameter.js +1 -1
- package/link/http/serializeFetchParameter.js.map +1 -1
- package/link/persisted-queries/index.d.ts +4 -4
- package/link/persisted-queries/index.d.ts.map +1 -1
- package/link/persisted-queries/index.js +26 -25
- package/link/persisted-queries/index.js.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs +22 -17
- package/link/persisted-queries/persisted-queries.cjs.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs.native.js +22 -17
- package/link/retry/delayFunction.d.ts +1 -1
- package/link/retry/delayFunction.js.map +1 -1
- package/link/retry/index.d.ts +1 -1
- package/link/retry/index.js +1 -1
- package/link/retry/index.js.map +1 -1
- package/link/retry/retry.cjs +2 -2
- package/link/retry/retry.cjs.map +1 -1
- package/link/retry/retry.cjs.native.js +2 -2
- package/link/retry/retryFunction.d.ts +1 -1
- package/link/retry/retryFunction.js.map +1 -1
- package/link/retry/retryLink.d.ts +5 -5
- package/link/retry/retryLink.d.ts.map +1 -1
- package/link/retry/retryLink.js +6 -6
- package/link/retry/retryLink.js.map +1 -1
- package/link/schema/index.d.ts +4 -4
- package/link/schema/index.d.ts.map +1 -1
- package/link/schema/index.js +13 -8
- package/link/schema/index.js.map +1 -1
- package/link/schema/schema.cjs +10 -5
- package/link/schema/schema.cjs.map +1 -1
- package/link/schema/schema.cjs.native.js +10 -5
- package/link/subscriptions/index.js +1 -1
- package/link/subscriptions/index.js.map +1 -1
- package/link/subscriptions/subscriptions.cjs.map +1 -1
- package/link/utils/createOperation.d.ts +1 -1
- package/link/utils/createOperation.js +3 -3
- package/link/utils/createOperation.js.map +1 -1
- package/link/utils/filterOperationVariables.d.ts +1 -1
- package/link/utils/filterOperationVariables.js +2 -2
- package/link/utils/filterOperationVariables.js.map +1 -1
- package/link/utils/fromError.d.ts +1 -1
- package/link/utils/fromError.js +1 -1
- package/link/utils/fromError.js.map +1 -1
- package/link/utils/fromPromise.d.ts +1 -1
- package/link/utils/fromPromise.js +1 -1
- package/link/utils/fromPromise.js.map +1 -1
- package/link/utils/index.d.ts +10 -10
- package/link/utils/index.js +9 -9
- package/link/utils/index.js.map +1 -1
- package/link/utils/throwServerError.js +1 -1
- package/link/utils/throwServerError.js.map +1 -1
- package/link/utils/toPromise.d.ts +1 -1
- package/link/utils/toPromise.js +1 -1
- package/link/utils/toPromise.js.map +1 -1
- package/link/utils/transformOperation.d.ts +1 -1
- package/link/utils/transformOperation.js +3 -3
- package/link/utils/transformOperation.js.map +1 -1
- package/link/utils/utils.cjs +12 -12
- package/link/utils/utils.cjs.map +1 -1
- package/link/utils/utils.cjs.native.js +12 -12
- package/link/utils/validateOperation.d.ts +1 -1
- package/link/utils/validateOperation.js +6 -6
- package/link/utils/validateOperation.js.map +1 -1
- package/link/ws/index.d.ts +5 -5
- package/link/ws/index.js +2 -2
- package/link/ws/index.js.map +1 -1
- package/link/ws/ws.cjs.map +1 -1
- package/package.json +22 -22
- package/react/cache/QueryReference.d.ts +1 -1
- package/react/cache/QueryReference.d.ts.map +1 -1
- package/react/cache/QueryReference.js +2 -0
- package/react/cache/QueryReference.js.map +1 -1
- package/react/hooks/constants.js +1 -1
- package/react/hooks/constants.js.map +1 -1
- package/react/hooks/hooks.cjs +10 -21
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +10 -21
- package/react/hooks/useBackgroundQuery.d.ts +1 -1
- package/react/hooks/useBackgroundQuery.d.ts.map +1 -1
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useQuery.d.ts.map +1 -1
- package/react/hooks/useQuery.js +1 -8
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useReactiveVar.d.ts.map +1 -1
- package/react/hooks/useReactiveVar.js +7 -12
- package/react/hooks/useReactiveVar.js.map +1 -1
- package/react/hooks/useReadQuery.d.ts +1 -1
- package/react/hooks/useReadQuery.d.ts.map +1 -1
- package/react/hooks/useReadQuery.js +1 -1
- package/react/hooks/useReadQuery.js.map +1 -1
- package/react/hooks/useSuspenseQuery.d.ts +1 -1
- package/react/hooks/useSuspenseQuery.d.ts.map +1 -1
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/react.cjs +2 -0
- package/react/react.cjs.map +1 -1
- package/react/react.cjs.native.js +2 -0
- package/react/types/types.js.map +1 -1
- package/testing/core/core.cjs +37 -28
- package/testing/core/core.cjs.map +1 -1
- package/testing/core/core.cjs.native.js +37 -28
- package/testing/core/itAsync.d.ts.map +1 -1
- package/testing/core/itAsync.js +8 -4
- package/testing/core/itAsync.js.map +1 -1
- package/testing/core/mocking/mockClient.d.ts +3 -3
- package/testing/core/mocking/mockClient.d.ts.map +1 -1
- package/testing/core/mocking/mockClient.js +6 -4
- package/testing/core/mocking/mockClient.js.map +1 -1
- package/testing/core/mocking/mockFetch.d.ts +1 -1
- package/testing/core/mocking/mockFetch.d.ts.map +1 -1
- package/testing/core/mocking/mockFetch.js +3 -3
- package/testing/core/mocking/mockFetch.js.map +1 -1
- package/testing/core/mocking/mockLink.d.ts +3 -3
- package/testing/core/mocking/mockLink.d.ts.map +1 -1
- package/testing/core/mocking/mockLink.js +24 -23
- package/testing/core/mocking/mockLink.js.map +1 -1
- package/testing/core/mocking/mockQueryManager.d.ts +2 -2
- package/testing/core/mocking/mockQueryManager.js +3 -3
- package/testing/core/mocking/mockQueryManager.js.map +1 -1
- package/testing/core/mocking/mockSubscriptionLink.d.ts +3 -3
- package/testing/core/mocking/mockSubscriptionLink.js +4 -4
- package/testing/core/mocking/mockSubscriptionLink.js.map +1 -1
- package/testing/core/mocking/mockWatchQuery.d.ts +2 -2
- package/testing/core/mocking/mockWatchQuery.js +2 -2
- package/testing/core/mocking/mockWatchQuery.js.map +1 -1
- package/testing/core/observableToPromise.d.ts +3 -3
- package/testing/core/observableToPromise.d.ts.map +1 -1
- package/testing/core/observableToPromise.js +8 -4
- package/testing/core/observableToPromise.js.map +1 -1
- package/testing/core/subscribeAndCount.d.ts +1 -1
- package/testing/core/subscribeAndCount.d.ts.map +1 -1
- package/testing/core/subscribeAndCount.js +5 -3
- package/testing/core/subscribeAndCount.js.map +1 -1
- package/testing/core/wait.js.map +1 -1
- package/testing/core/withConsoleSpy.d.ts.map +1 -1
- package/testing/core/withConsoleSpy.js.map +1 -1
- package/testing/core/wrap.d.ts.map +1 -1
- package/testing/core/wrap.js +14 -12
- package/testing/core/wrap.js.map +1 -1
- package/testing/index.d.ts +4 -4
- package/testing/index.js +3 -3
- package/testing/index.js.map +1 -1
- package/testing/react/MockedProvider.d.ts +7 -7
- package/testing/react/MockedProvider.d.ts.map +1 -1
- package/testing/react/MockedProvider.js +10 -11
- package/testing/react/MockedProvider.js.map +1 -1
- package/testing/testing.cjs +3 -5
- package/testing/testing.cjs.map +1 -1
- package/testing/testing.cjs.native.js +3 -5
- package/utilities/common/canUse.d.ts.map +1 -1
- package/utilities/common/canUse.js +4 -5
- package/utilities/common/canUse.js.map +1 -1
- package/utilities/common/cloneDeep.js +2 -2
- package/utilities/common/cloneDeep.js.map +1 -1
- package/utilities/common/compact.d.ts +1 -1
- package/utilities/common/compact.js.map +1 -1
- package/utilities/common/filterInPlace.js.map +1 -1
- package/utilities/common/maybeDeepFreeze.js +1 -1
- package/utilities/common/maybeDeepFreeze.js.map +1 -1
- package/utilities/common/mergeDeep.d.ts.map +1 -1
- package/utilities/common/mergeDeep.js +3 -1
- package/utilities/common/mergeDeep.js.map +1 -1
- package/utilities/common/mergeOptions.d.ts.map +1 -1
- package/utilities/common/mergeOptions.js.map +1 -1
- package/utilities/common/objects.js +2 -2
- package/utilities/common/objects.js.map +1 -1
- package/utilities/common/stringifyForDisplay.d.ts.map +1 -1
- package/utilities/common/stringifyForDisplay.js +3 -1
- package/utilities/common/stringifyForDisplay.js.map +1 -1
- package/utilities/globals/global.d.ts.map +1 -1
- package/utilities/globals/global.js +3 -1
- package/utilities/globals/global.js.map +1 -1
- package/utilities/globals/globals.cjs +8 -4
- package/utilities/globals/globals.cjs.map +1 -1
- package/utilities/globals/globals.cjs.native.js +8 -4
- package/utilities/globals/index.d.ts.map +1 -1
- package/utilities/globals/index.js +1 -1
- package/utilities/globals/index.js.map +1 -1
- package/utilities/globals/invariantWrappers.js +1 -1
- package/utilities/globals/invariantWrappers.js.map +1 -1
- package/utilities/globals/maybe.d.ts.map +1 -1
- package/utilities/globals/maybe.js.map +1 -1
- package/utilities/graphql/directives.d.ts +1 -1
- package/utilities/graphql/directives.d.ts.map +1 -1
- package/utilities/graphql/directives.js +17 -13
- package/utilities/graphql/directives.js.map +1 -1
- package/utilities/graphql/fragments.d.ts +1 -1
- package/utilities/graphql/fragments.d.ts.map +1 -1
- package/utilities/graphql/fragments.js +12 -12
- package/utilities/graphql/fragments.js.map +1 -1
- package/utilities/graphql/getFromAST.d.ts +1 -1
- package/utilities/graphql/getFromAST.js +16 -16
- package/utilities/graphql/getFromAST.js.map +1 -1
- package/utilities/graphql/storeUtils.d.ts +2 -2
- package/utilities/graphql/storeUtils.d.ts.map +1 -1
- package/utilities/graphql/storeUtils.js +36 -34
- package/utilities/graphql/storeUtils.js.map +1 -1
- package/utilities/graphql/transform.d.ts +1 -1
- package/utilities/graphql/transform.d.ts.map +1 -1
- package/utilities/graphql/transform.js +48 -32
- package/utilities/graphql/transform.js.map +1 -1
- package/utilities/observables/Concast.d.ts.map +1 -1
- package/utilities/observables/Concast.js +5 -9
- package/utilities/observables/Concast.js.map +1 -1
- package/utilities/observables/Observable.d.ts +4 -4
- package/utilities/observables/Observable.d.ts.map +1 -1
- package/utilities/observables/Observable.js +6 -4
- package/utilities/observables/Observable.js.map +1 -1
- package/utilities/observables/asyncMap.d.ts.map +1 -1
- package/utilities/observables/asyncMap.js +5 -2
- package/utilities/observables/asyncMap.js.map +1 -1
- package/utilities/observables/iteration.js.map +1 -1
- package/utilities/policies/pagination.d.ts +1 -1
- package/utilities/policies/pagination.d.ts.map +1 -1
- package/utilities/policies/pagination.js +9 -7
- package/utilities/policies/pagination.js.map +1 -1
- package/utilities/types/IsStrictlyAny.d.ts +2 -2
- package/utilities/types/IsStrictlyAny.d.ts.map +1 -1
- package/utilities/types/IsStrictlyAny.js.map +1 -1
- package/utilities/utilities.cjs +147 -121
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +147 -121
- package/version.js +1 -1
- package/version.js.map +1 -1
package/cache/cache.cjs
CHANGED
|
@@ -18,10 +18,13 @@ var ApolloCache = (function () {
|
|
|
18
18
|
}
|
|
19
19
|
ApolloCache.prototype.batch = function (options) {
|
|
20
20
|
var _this = this;
|
|
21
|
-
var optimisticId = typeof options.optimistic === "string"
|
|
22
|
-
options.optimistic
|
|
21
|
+
var optimisticId = typeof options.optimistic === "string"
|
|
22
|
+
? options.optimistic
|
|
23
|
+
: options.optimistic === false
|
|
24
|
+
? null
|
|
25
|
+
: void 0;
|
|
23
26
|
var updateResult;
|
|
24
|
-
this.performTransaction(function () { return updateResult = options.update(_this); }, optimisticId);
|
|
27
|
+
this.performTransaction(function () { return (updateResult = options.update(_this)); }, optimisticId);
|
|
25
28
|
return updateResult;
|
|
26
29
|
};
|
|
27
30
|
ApolloCache.prototype.recordOptimisticTransaction = function (transaction, optimisticId) {
|
|
@@ -44,7 +47,7 @@ var ApolloCache = (function () {
|
|
|
44
47
|
};
|
|
45
48
|
ApolloCache.prototype.readQuery = function (options, optimistic) {
|
|
46
49
|
if (optimistic === void 0) { optimistic = !!options.optimistic; }
|
|
47
|
-
return this.read(tslib.__assign(tslib.__assign({}, options), { rootId: options.id ||
|
|
50
|
+
return this.read(tslib.__assign(tslib.__assign({}, options), { rootId: options.id || "ROOT_QUERY", optimistic: optimistic }));
|
|
48
51
|
};
|
|
49
52
|
ApolloCache.prototype.readFragment = function (options, optimistic) {
|
|
50
53
|
if (optimistic === void 0) { optimistic = !!options.optimistic; }
|
|
@@ -53,7 +56,7 @@ var ApolloCache = (function () {
|
|
|
53
56
|
ApolloCache.prototype.writeQuery = function (_a) {
|
|
54
57
|
var id = _a.id, data = _a.data, options = tslib.__rest(_a, ["id", "data"]);
|
|
55
58
|
return this.write(Object.assign(options, {
|
|
56
|
-
dataId: id ||
|
|
59
|
+
dataId: id || "ROOT_QUERY",
|
|
57
60
|
result: data,
|
|
58
61
|
}));
|
|
59
62
|
};
|
|
@@ -128,17 +131,19 @@ function defaultDataIdFromObject(_a, context) {
|
|
|
128
131
|
var __typename = _a.__typename, id = _a.id, _id = _a._id;
|
|
129
132
|
if (typeof __typename === "string") {
|
|
130
133
|
if (context) {
|
|
131
|
-
context.keyObject =
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
134
|
+
context.keyObject = !isNullish(id)
|
|
135
|
+
? { id: id }
|
|
136
|
+
: !isNullish(_id)
|
|
137
|
+
? { _id: _id }
|
|
138
|
+
: void 0;
|
|
135
139
|
}
|
|
136
140
|
if (isNullish(id) && !isNullish(_id)) {
|
|
137
141
|
id = _id;
|
|
138
142
|
}
|
|
139
143
|
if (!isNullish(id)) {
|
|
140
|
-
return "".concat(__typename, ":").concat(
|
|
141
|
-
|
|
144
|
+
return "".concat(__typename, ":").concat(typeof id === "number" || typeof id === "string"
|
|
145
|
+
? id
|
|
146
|
+
: JSON.stringify(id));
|
|
142
147
|
}
|
|
143
148
|
}
|
|
144
149
|
}
|
|
@@ -168,13 +173,15 @@ function fieldNameFromStoreName(storeFieldName) {
|
|
|
168
173
|
function selectionSetMatchesResult(selectionSet, result, variables) {
|
|
169
174
|
if (utilities.isNonNullObject(result)) {
|
|
170
175
|
return utilities.isArray(result)
|
|
171
|
-
? result.every(function (item) {
|
|
176
|
+
? result.every(function (item) {
|
|
177
|
+
return selectionSetMatchesResult(selectionSet, item, variables);
|
|
178
|
+
})
|
|
172
179
|
: selectionSet.selections.every(function (field) {
|
|
173
180
|
if (utilities.isField(field) && utilities.shouldInclude(field, variables)) {
|
|
174
181
|
var key = utilities.resultKeyNameFromField(field);
|
|
175
|
-
return hasOwn.call(result, key) &&
|
|
182
|
+
return (hasOwn.call(result, key) &&
|
|
176
183
|
(!field.selectionSet ||
|
|
177
|
-
selectionSetMatchesResult(field.selectionSet, result[key], variables));
|
|
184
|
+
selectionSetMatchesResult(field.selectionSet, result[key], variables)));
|
|
178
185
|
}
|
|
179
186
|
return true;
|
|
180
187
|
});
|
|
@@ -182,12 +189,10 @@ function selectionSetMatchesResult(selectionSet, result, variables) {
|
|
|
182
189
|
return false;
|
|
183
190
|
}
|
|
184
191
|
function storeValueIsStoreObject(value) {
|
|
185
|
-
return utilities.isNonNullObject(value) &&
|
|
186
|
-
!utilities.isReference(value) &&
|
|
187
|
-
!utilities.isArray(value);
|
|
192
|
+
return utilities.isNonNullObject(value) && !utilities.isReference(value) && !utilities.isArray(value);
|
|
188
193
|
}
|
|
189
194
|
function makeProcessedFieldsMerger() {
|
|
190
|
-
return new utilities.DeepMerger;
|
|
195
|
+
return new utilities.DeepMerger();
|
|
191
196
|
}
|
|
192
197
|
function extractFragmentContext(document, fragments) {
|
|
193
198
|
var fragmentMap = utilities.createFragmentMap(utilities.getFragmentDefinitions(document));
|
|
@@ -214,9 +219,11 @@ exports.EntityStore = (function () {
|
|
|
214
219
|
this.data = Object.create(null);
|
|
215
220
|
this.rootIds = Object.create(null);
|
|
216
221
|
this.refs = Object.create(null);
|
|
217
|
-
this.getFieldValue = function (objectOrReference, storeFieldName) {
|
|
218
|
-
|
|
219
|
-
|
|
222
|
+
this.getFieldValue = function (objectOrReference, storeFieldName) {
|
|
223
|
+
return utilities.maybeDeepFreeze(utilities.isReference(objectOrReference)
|
|
224
|
+
? _this.get(objectOrReference.__ref, storeFieldName)
|
|
225
|
+
: objectOrReference && objectOrReference[storeFieldName]);
|
|
226
|
+
};
|
|
220
227
|
this.canRead = function (objOrRef) {
|
|
221
228
|
return utilities.isReference(objOrRef)
|
|
222
229
|
? _this.has(objOrRef.__ref)
|
|
@@ -281,12 +288,8 @@ exports.EntityStore = (function () {
|
|
|
281
288
|
older = older.__ref;
|
|
282
289
|
if (utilities.isReference(newer))
|
|
283
290
|
newer = newer.__ref;
|
|
284
|
-
var existing = typeof older === "string"
|
|
285
|
-
|
|
286
|
-
: older;
|
|
287
|
-
var incoming = typeof newer === "string"
|
|
288
|
-
? this.lookup(dataId = newer)
|
|
289
|
-
: newer;
|
|
291
|
+
var existing = typeof older === "string" ? this.lookup((dataId = older)) : older;
|
|
292
|
+
var incoming = typeof newer === "string" ? this.lookup((dataId = newer)) : newer;
|
|
290
293
|
if (!incoming)
|
|
291
294
|
return;
|
|
292
295
|
globals.invariant(typeof dataId === "string", 1);
|
|
@@ -299,7 +302,8 @@ exports.EntityStore = (function () {
|
|
|
299
302
|
if (!existing)
|
|
300
303
|
fieldsToDirty_1.__exists = 1;
|
|
301
304
|
Object.keys(incoming).forEach(function (storeFieldName) {
|
|
302
|
-
if (!existing ||
|
|
305
|
+
if (!existing ||
|
|
306
|
+
existing[storeFieldName] !== merged[storeFieldName]) {
|
|
303
307
|
fieldsToDirty_1[storeFieldName] = 1;
|
|
304
308
|
var fieldName = fieldNameFromStoreName(storeFieldName);
|
|
305
309
|
if (fieldName !== storeFieldName &&
|
|
@@ -316,7 +320,9 @@ exports.EntityStore = (function () {
|
|
|
316
320
|
this.policies.rootTypenamesById[dataId] === merged.__typename) {
|
|
317
321
|
delete fieldsToDirty_1.__typename;
|
|
318
322
|
}
|
|
319
|
-
Object.keys(fieldsToDirty_1).forEach(function (fieldName) {
|
|
323
|
+
Object.keys(fieldsToDirty_1).forEach(function (fieldName) {
|
|
324
|
+
return _this.group.dirty(dataId, fieldName);
|
|
325
|
+
});
|
|
320
326
|
}
|
|
321
327
|
}
|
|
322
328
|
};
|
|
@@ -333,10 +339,14 @@ exports.EntityStore = (function () {
|
|
|
333
339
|
isReference: utilities.isReference,
|
|
334
340
|
toReference: this.toReference,
|
|
335
341
|
canRead: this.canRead,
|
|
336
|
-
readField: function (fieldNameOrOptions, from) {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
342
|
+
readField: function (fieldNameOrOptions, from) {
|
|
343
|
+
return _this.policies.readField(typeof fieldNameOrOptions === "string"
|
|
344
|
+
? {
|
|
345
|
+
fieldName: fieldNameOrOptions,
|
|
346
|
+
from: from || utilities.makeReference(dataId),
|
|
347
|
+
}
|
|
348
|
+
: fieldNameOrOptions, { store: _this });
|
|
349
|
+
},
|
|
340
350
|
};
|
|
341
351
|
Object.keys(storeObject).forEach(function (storeFieldName) {
|
|
342
352
|
var fieldName = fieldNameFromStoreName(storeFieldName);
|
|
@@ -347,8 +357,9 @@ exports.EntityStore = (function () {
|
|
|
347
357
|
? fields
|
|
348
358
|
: fields[storeFieldName] || fields[fieldName];
|
|
349
359
|
if (modify) {
|
|
350
|
-
var newValue = modify === delModifier
|
|
351
|
-
|
|
360
|
+
var newValue = modify === delModifier
|
|
361
|
+
? DELETE
|
|
362
|
+
: modify(utilities.maybeDeepFreeze(fieldValue), tslib.__assign(tslib.__assign({}, sharedDetails_1), { fieldName: fieldName, storeFieldName: storeFieldName, storage: _this.getStorage(dataId, storeFieldName) }));
|
|
352
363
|
if (newValue === INVALIDATE) {
|
|
353
364
|
_this.group.dirty(dataId, storeFieldName);
|
|
354
365
|
}
|
|
@@ -390,9 +401,10 @@ exports.EntityStore = (function () {
|
|
|
390
401
|
var storeFieldName = fieldName && args
|
|
391
402
|
? this.policies.getStoreFieldName({ typename: typename, fieldName: fieldName, args: args })
|
|
392
403
|
: fieldName;
|
|
393
|
-
return this.modify(dataId, storeFieldName
|
|
394
|
-
_a
|
|
395
|
-
|
|
404
|
+
return this.modify(dataId, storeFieldName
|
|
405
|
+
? (_a = {},
|
|
406
|
+
_a[storeFieldName] = delModifier,
|
|
407
|
+
_a) : delModifier);
|
|
396
408
|
}
|
|
397
409
|
return false;
|
|
398
410
|
};
|
|
@@ -446,7 +458,7 @@ exports.EntityStore = (function () {
|
|
|
446
458
|
}
|
|
447
459
|
};
|
|
448
460
|
EntityStore.prototype.retain = function (rootId) {
|
|
449
|
-
return this.rootIds[rootId] = (this.rootIds[rootId] || 0) + 1;
|
|
461
|
+
return (this.rootIds[rootId] = (this.rootIds[rootId] || 0) + 1);
|
|
450
462
|
};
|
|
451
463
|
EntityStore.prototype.release = function (rootId) {
|
|
452
464
|
if (this.rootIds[rootId] > 0) {
|
|
@@ -489,7 +501,7 @@ exports.EntityStore = (function () {
|
|
|
489
501
|
};
|
|
490
502
|
EntityStore.prototype.findChildRefIds = function (dataId) {
|
|
491
503
|
if (!hasOwn.call(this.refs, dataId)) {
|
|
492
|
-
var found_1 = this.refs[dataId] = Object.create(null);
|
|
504
|
+
var found_1 = (this.refs[dataId] = Object.create(null));
|
|
493
505
|
var root = this.data[dataId];
|
|
494
506
|
if (!root)
|
|
495
507
|
return found_1;
|
|
@@ -547,7 +559,7 @@ var CacheGroup = (function () {
|
|
|
547
559
|
return CacheGroup;
|
|
548
560
|
}());
|
|
549
561
|
function makeDepKey(dataId, storeFieldName) {
|
|
550
|
-
return storeFieldName +
|
|
562
|
+
return storeFieldName + "#" + dataId;
|
|
551
563
|
}
|
|
552
564
|
function maybeDependOnExistenceOfEntity(store, entityId) {
|
|
553
565
|
if (supportsResultCaching(store)) {
|
|
@@ -630,7 +642,8 @@ var Layer = (function (_super) {
|
|
|
630
642
|
};
|
|
631
643
|
Layer.prototype.findChildRefIds = function (dataId) {
|
|
632
644
|
var fromParent = this.parent.findChildRefIds(dataId);
|
|
633
|
-
return hasOwn.call(this.data, dataId)
|
|
645
|
+
return hasOwn.call(this.data, dataId)
|
|
646
|
+
? tslib.__assign(tslib.__assign({}, fromParent), _super.prototype.findChildRefIds.call(this, dataId)) : fromParent;
|
|
634
647
|
};
|
|
635
648
|
Layer.prototype.getStorage = function () {
|
|
636
649
|
var p = this.parent;
|
|
@@ -703,7 +716,7 @@ var ObjectCanon = (function () {
|
|
|
703
716
|
var array = value.map(this.admit, this);
|
|
704
717
|
var node = this.pool.lookupArray(array);
|
|
705
718
|
if (!node.array) {
|
|
706
|
-
this.known.add(node.array = array);
|
|
719
|
+
this.known.add((node.array = array));
|
|
707
720
|
if (globalThis.__DEV__ !== false) {
|
|
708
721
|
Object.freeze(array);
|
|
709
722
|
}
|
|
@@ -724,7 +737,7 @@ var ObjectCanon = (function () {
|
|
|
724
737
|
});
|
|
725
738
|
var node = this.pool.lookupArray(array_1);
|
|
726
739
|
if (!node.object) {
|
|
727
|
-
var obj_1 = node.object = Object.create(proto_1);
|
|
740
|
+
var obj_1 = (node.object = Object.create(proto_1));
|
|
728
741
|
this.known.add(obj_1);
|
|
729
742
|
keys.sorted.forEach(function (key, i) {
|
|
730
743
|
obj_1[key] = array_1[firstValueIndex_1 + i];
|
|
@@ -746,7 +759,7 @@ var ObjectCanon = (function () {
|
|
|
746
759
|
keys.sort();
|
|
747
760
|
var json = JSON.stringify(keys);
|
|
748
761
|
if (!(node.keys = this.keysByJSON.get(json))) {
|
|
749
|
-
this.keysByJSON.set(json, node.keys = { sorted: keys, json: json });
|
|
762
|
+
this.keysByJSON.set(json, (node.keys = { sorted: keys, json: json }));
|
|
750
763
|
}
|
|
751
764
|
}
|
|
752
765
|
return node.keys;
|
|
@@ -761,7 +774,7 @@ var canonicalStringify = Object.assign(function (value) {
|
|
|
761
774
|
var canonical = stringifyCanon.admit(value);
|
|
762
775
|
var json = stringifyCache.get(canonical);
|
|
763
776
|
if (json === void 0) {
|
|
764
|
-
stringifyCache.set(canonical, json = JSON.stringify(canonical));
|
|
777
|
+
stringifyCache.set(canonical, (json = JSON.stringify(canonical)));
|
|
765
778
|
}
|
|
766
779
|
return json;
|
|
767
780
|
}
|
|
@@ -772,7 +785,7 @@ var canonicalStringify = Object.assign(function (value) {
|
|
|
772
785
|
var stringifyCanon;
|
|
773
786
|
var stringifyCache;
|
|
774
787
|
function resetCanonicalStringify() {
|
|
775
|
-
stringifyCanon = new ObjectCanon;
|
|
788
|
+
stringifyCanon = new ObjectCanon();
|
|
776
789
|
stringifyCache = new (utilities.canUseWeakMap ? WeakMap : Map)();
|
|
777
790
|
}
|
|
778
791
|
|
|
@@ -792,7 +805,7 @@ var StoreReader = (function () {
|
|
|
792
805
|
addTypename: config.addTypename !== false,
|
|
793
806
|
canonizeResults: shouldCanonizeResults(config),
|
|
794
807
|
});
|
|
795
|
-
this.canon = config.canon || new ObjectCanon;
|
|
808
|
+
this.canon = config.canon || new ObjectCanon();
|
|
796
809
|
this.executeSelectionSet = optimism.wrap(function (options) {
|
|
797
810
|
var _a;
|
|
798
811
|
var canonizeResults = options.context.canonizeResults;
|
|
@@ -814,7 +827,7 @@ var StoreReader = (function () {
|
|
|
814
827
|
if (supportsResultCaching(context.store)) {
|
|
815
828
|
return context.store.makeCacheKey(selectionSet, utilities.isReference(parent) ? parent.__ref : parent, context.varString, canonizeResults);
|
|
816
829
|
}
|
|
817
|
-
}
|
|
830
|
+
},
|
|
818
831
|
});
|
|
819
832
|
this.executeSubSelectedArray = optimism.wrap(function (options) {
|
|
820
833
|
maybeDependOnExistenceOfEntity(options.context.store, options.enclosingRef.__ref);
|
|
@@ -826,14 +839,14 @@ var StoreReader = (function () {
|
|
|
826
839
|
if (supportsResultCaching(context.store)) {
|
|
827
840
|
return context.store.makeCacheKey(field, array, context.varString);
|
|
828
841
|
}
|
|
829
|
-
}
|
|
842
|
+
},
|
|
830
843
|
});
|
|
831
844
|
}
|
|
832
845
|
StoreReader.prototype.resetCanon = function () {
|
|
833
|
-
this.canon = new ObjectCanon;
|
|
846
|
+
this.canon = new ObjectCanon();
|
|
834
847
|
};
|
|
835
848
|
StoreReader.prototype.diffQueryAgainstStore = function (_a) {
|
|
836
|
-
var store = _a.store, query = _a.query, _b = _a.rootId, rootId = _b === void 0 ?
|
|
849
|
+
var store = _a.store, query = _a.query, _b = _a.rootId, rootId = _b === void 0 ? "ROOT_QUERY" : _b, variables = _a.variables, _c = _a.returnPartialData, returnPartialData = _c === void 0 ? true : _c, _d = _a.canonizeResults, canonizeResults = _d === void 0 ? this.config.canonizeResults : _d;
|
|
837
850
|
var policies = this.config.cache.policies;
|
|
838
851
|
variables = tslib.__assign(tslib.__assign({}, utilities.getDefaultValues(utilities.getQueryDefinition(query))), variables);
|
|
839
852
|
var rootRef = utilities.makeReference(rootId);
|
|
@@ -845,7 +858,9 @@ var StoreReader = (function () {
|
|
|
845
858
|
});
|
|
846
859
|
var missing;
|
|
847
860
|
if (execResult.missing) {
|
|
848
|
-
missing = [
|
|
861
|
+
missing = [
|
|
862
|
+
new MissingFieldError(firstMissing(execResult.missing), execResult.missing, query, variables),
|
|
863
|
+
];
|
|
849
864
|
if (!returnPartialData) {
|
|
850
865
|
throw missing[0];
|
|
851
866
|
}
|
|
@@ -890,7 +905,9 @@ var StoreReader = (function () {
|
|
|
890
905
|
function handleMissing(result, resultName) {
|
|
891
906
|
var _a;
|
|
892
907
|
if (result.missing) {
|
|
893
|
-
missing = missingMerger.merge(missing, (_a = {},
|
|
908
|
+
missing = missingMerger.merge(missing, (_a = {},
|
|
909
|
+
_a[resultName] = result.missing,
|
|
910
|
+
_a));
|
|
894
911
|
}
|
|
895
912
|
return result.result;
|
|
896
913
|
}
|
|
@@ -955,7 +972,8 @@ var StoreReader = (function () {
|
|
|
955
972
|
var finalResult = { result: result, missing: missing };
|
|
956
973
|
var frozen = context.canonizeResults
|
|
957
974
|
? this.canon.admit(finalResult)
|
|
958
|
-
:
|
|
975
|
+
:
|
|
976
|
+
utilities.maybeDeepFreeze(finalResult);
|
|
959
977
|
if (frozen.result) {
|
|
960
978
|
this.knownResults.set(frozen.result, selectionSet);
|
|
961
979
|
}
|
|
@@ -1042,10 +1060,10 @@ var cacheInfoMap = new WeakMap();
|
|
|
1042
1060
|
function getCacheInfo(cache) {
|
|
1043
1061
|
var info = cacheInfoMap.get(cache);
|
|
1044
1062
|
if (!info) {
|
|
1045
|
-
cacheInfoMap.set(cache, info = {
|
|
1046
|
-
vars: new Set,
|
|
1063
|
+
cacheInfoMap.set(cache, (info = {
|
|
1064
|
+
vars: new Set(),
|
|
1047
1065
|
dep: optimism.dep(),
|
|
1048
|
-
});
|
|
1066
|
+
}));
|
|
1049
1067
|
}
|
|
1050
1068
|
return info;
|
|
1051
1069
|
}
|
|
@@ -1086,11 +1104,11 @@ function makeVar(value) {
|
|
|
1086
1104
|
listeners.delete(listener);
|
|
1087
1105
|
};
|
|
1088
1106
|
};
|
|
1089
|
-
var attach = rv.attachCache = function (cache) {
|
|
1107
|
+
var attach = (rv.attachCache = function (cache) {
|
|
1090
1108
|
caches.add(cache);
|
|
1091
1109
|
getCacheInfo(cache).vars.add(rv);
|
|
1092
1110
|
return rv;
|
|
1093
|
-
};
|
|
1111
|
+
});
|
|
1094
1112
|
rv.forgetCache = function (cache) { return caches.delete(cache); };
|
|
1095
1113
|
return rv;
|
|
1096
1114
|
}
|
|
@@ -1103,64 +1121,68 @@ function broadcast(cache) {
|
|
|
1103
1121
|
var specifierInfoCache = Object.create(null);
|
|
1104
1122
|
function lookupSpecifierInfo(spec) {
|
|
1105
1123
|
var cacheKey = JSON.stringify(spec);
|
|
1106
|
-
return specifierInfoCache[cacheKey] ||
|
|
1107
|
-
(specifierInfoCache[cacheKey] = Object.create(null));
|
|
1124
|
+
return (specifierInfoCache[cacheKey] ||
|
|
1125
|
+
(specifierInfoCache[cacheKey] = Object.create(null)));
|
|
1108
1126
|
}
|
|
1109
1127
|
function keyFieldsFnFromSpecifier(specifier) {
|
|
1110
1128
|
var info = lookupSpecifierInfo(specifier);
|
|
1111
|
-
return info.keyFieldsFn || (info.keyFieldsFn = function (object, context) {
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1129
|
+
return (info.keyFieldsFn || (info.keyFieldsFn = function (object, context) {
|
|
1130
|
+
var extract = function (from, key) {
|
|
1131
|
+
return context.readField(key, from);
|
|
1132
|
+
};
|
|
1133
|
+
var keyObject = (context.keyObject = collectSpecifierPaths(specifier, function (schemaKeyPath) {
|
|
1134
|
+
var extracted = extractKeyPath(context.storeObject, schemaKeyPath, extract);
|
|
1135
|
+
if (extracted === void 0 &&
|
|
1136
|
+
object !== context.storeObject &&
|
|
1137
|
+
hasOwn.call(object, schemaKeyPath[0])) {
|
|
1138
|
+
extracted = extractKeyPath(object, schemaKeyPath, extractKey);
|
|
1139
|
+
}
|
|
1140
|
+
globals.invariant(extracted !== void 0, 2, schemaKeyPath.join("."), object);
|
|
1141
|
+
return extracted;
|
|
1142
|
+
}));
|
|
1143
|
+
return "".concat(context.typename, ":").concat(JSON.stringify(keyObject));
|
|
1144
|
+
}));
|
|
1125
1145
|
}
|
|
1126
1146
|
function keyArgsFnFromSpecifier(specifier) {
|
|
1127
1147
|
var info = lookupSpecifierInfo(specifier);
|
|
1128
|
-
return info.keyArgsFn ||
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
var
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
if (
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1148
|
+
return (info.keyArgsFn ||
|
|
1149
|
+
(info.keyArgsFn = function (args, _a) {
|
|
1150
|
+
var field = _a.field, variables = _a.variables, fieldName = _a.fieldName;
|
|
1151
|
+
var collected = collectSpecifierPaths(specifier, function (keyPath) {
|
|
1152
|
+
var firstKey = keyPath[0];
|
|
1153
|
+
var firstChar = firstKey.charAt(0);
|
|
1154
|
+
if (firstChar === "@") {
|
|
1155
|
+
if (field && utilities.isNonEmptyArray(field.directives)) {
|
|
1156
|
+
var directiveName_1 = firstKey.slice(1);
|
|
1157
|
+
var d = field.directives.find(function (d) { return d.name.value === directiveName_1; });
|
|
1158
|
+
var directiveArgs = d && utilities.argumentsObjectFromField(d, variables);
|
|
1159
|
+
return (directiveArgs &&
|
|
1160
|
+
extractKeyPath(directiveArgs, keyPath.slice(1)));
|
|
1161
|
+
}
|
|
1162
|
+
return;
|
|
1139
1163
|
}
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
return
|
|
1164
|
+
if (firstChar === "$") {
|
|
1165
|
+
var variableName = firstKey.slice(1);
|
|
1166
|
+
if (variables && hasOwn.call(variables, variableName)) {
|
|
1167
|
+
var varKeyPath = keyPath.slice(0);
|
|
1168
|
+
varKeyPath[0] = variableName;
|
|
1169
|
+
return extractKeyPath(variables, varKeyPath);
|
|
1170
|
+
}
|
|
1171
|
+
return;
|
|
1148
1172
|
}
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1173
|
+
if (args) {
|
|
1174
|
+
return extractKeyPath(args, keyPath);
|
|
1175
|
+
}
|
|
1176
|
+
});
|
|
1177
|
+
var suffix = JSON.stringify(collected);
|
|
1178
|
+
if (args || suffix !== "{}") {
|
|
1179
|
+
fieldName += ":" + suffix;
|
|
1153
1180
|
}
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
if (args || suffix !== "{}") {
|
|
1157
|
-
fieldName += ":" + suffix;
|
|
1158
|
-
}
|
|
1159
|
-
return fieldName;
|
|
1160
|
-
});
|
|
1181
|
+
return fieldName;
|
|
1182
|
+
}));
|
|
1161
1183
|
}
|
|
1162
1184
|
function collectSpecifierPaths(specifier, extractor) {
|
|
1163
|
-
var merger = new utilities.DeepMerger;
|
|
1185
|
+
var merger = new utilities.DeepMerger();
|
|
1164
1186
|
return getSpecifierPaths(specifier).reduce(function (collected, path) {
|
|
1165
1187
|
var _a;
|
|
1166
1188
|
var toMerge = extractor(path);
|
|
@@ -1176,7 +1198,7 @@ function collectSpecifierPaths(specifier, extractor) {
|
|
|
1176
1198
|
function getSpecifierPaths(spec) {
|
|
1177
1199
|
var info = lookupSpecifierInfo(spec);
|
|
1178
1200
|
if (!info.paths) {
|
|
1179
|
-
var paths_1 = info.paths = [];
|
|
1201
|
+
var paths_1 = (info.paths = []);
|
|
1180
1202
|
var currentPath_1 = [];
|
|
1181
1203
|
spec.forEach(function (s, i) {
|
|
1182
1204
|
if (utilities.isArray(s)) {
|
|
@@ -1210,15 +1232,20 @@ function normalize(value) {
|
|
|
1210
1232
|
if (utilities.isArray(value)) {
|
|
1211
1233
|
return value.map(normalize);
|
|
1212
1234
|
}
|
|
1213
|
-
return collectSpecifierPaths(Object.keys(value).sort(), function (path) {
|
|
1235
|
+
return collectSpecifierPaths(Object.keys(value).sort(), function (path) {
|
|
1236
|
+
return extractKeyPath(value, path);
|
|
1237
|
+
});
|
|
1214
1238
|
}
|
|
1215
1239
|
return value;
|
|
1216
1240
|
}
|
|
1217
1241
|
|
|
1218
1242
|
utilities.getStoreKeyName.setStringify(canonicalStringify);
|
|
1219
1243
|
function argsFromFieldSpecifier(spec) {
|
|
1220
|
-
return spec.args !== void 0
|
|
1221
|
-
|
|
1244
|
+
return spec.args !== void 0
|
|
1245
|
+
? spec.args
|
|
1246
|
+
: spec.field
|
|
1247
|
+
? utilities.argumentsObjectFromField(spec.field, spec.variables)
|
|
1248
|
+
: null;
|
|
1222
1249
|
}
|
|
1223
1250
|
var nullKeyFieldsFn = function () { return void 0; };
|
|
1224
1251
|
var simpleKeyArgsFn = function (_args, context) { return context.fieldName; };
|
|
@@ -1252,22 +1279,24 @@ var Policies = (function () {
|
|
|
1252
1279
|
Policies.prototype.identify = function (object, partialContext) {
|
|
1253
1280
|
var _a;
|
|
1254
1281
|
var policies = this;
|
|
1255
|
-
var typename = partialContext &&
|
|
1256
|
-
((_a = partialContext.storeObject) === null || _a === void 0 ? void 0 : _a.__typename)) ||
|
|
1282
|
+
var typename = (partialContext &&
|
|
1283
|
+
(partialContext.typename || ((_a = partialContext.storeObject) === null || _a === void 0 ? void 0 : _a.__typename))) ||
|
|
1284
|
+
object.__typename;
|
|
1257
1285
|
if (typename === this.rootTypenamesById.ROOT_QUERY) {
|
|
1258
1286
|
return ["ROOT_QUERY"];
|
|
1259
1287
|
}
|
|
1260
|
-
var storeObject = partialContext && partialContext.storeObject || object;
|
|
1261
|
-
var context = tslib.__assign(tslib.__assign({}, partialContext), { typename: typename, storeObject: storeObject, readField: partialContext && partialContext.readField ||
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1288
|
+
var storeObject = (partialContext && partialContext.storeObject) || object;
|
|
1289
|
+
var context = tslib.__assign(tslib.__assign({}, partialContext), { typename: typename, storeObject: storeObject, readField: (partialContext && partialContext.readField) ||
|
|
1290
|
+
function () {
|
|
1291
|
+
var options = normalizeReadFieldOptions(arguments, storeObject);
|
|
1292
|
+
return policies.readField(options, {
|
|
1293
|
+
store: policies.cache["data"],
|
|
1294
|
+
variables: options.variables,
|
|
1295
|
+
});
|
|
1296
|
+
} });
|
|
1268
1297
|
var id;
|
|
1269
1298
|
var policy = typename && this.getTypePolicy(typename);
|
|
1270
|
-
var keyFn = policy && policy.keyFn || this.config.dataIdFromObject;
|
|
1299
|
+
var keyFn = (policy && policy.keyFn) || this.config.dataIdFromObject;
|
|
1271
1300
|
while (keyFn) {
|
|
1272
1301
|
var specifierOrId = keyFn(tslib.__assign(tslib.__assign({}, object), storeObject), context);
|
|
1273
1302
|
if (utilities.isArray(specifierOrId)) {
|
|
@@ -1305,17 +1334,28 @@ var Policies = (function () {
|
|
|
1305
1334
|
var keyFields = incoming.keyFields, fields = incoming.fields;
|
|
1306
1335
|
function setMerge(existing, merge) {
|
|
1307
1336
|
existing.merge =
|
|
1308
|
-
typeof merge === "function"
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1337
|
+
typeof merge === "function"
|
|
1338
|
+
? merge
|
|
1339
|
+
:
|
|
1340
|
+
merge === true
|
|
1341
|
+
? mergeTrueFn
|
|
1342
|
+
:
|
|
1343
|
+
merge === false
|
|
1344
|
+
? mergeFalseFn
|
|
1345
|
+
: existing.merge;
|
|
1312
1346
|
}
|
|
1313
1347
|
setMerge(existing, incoming.merge);
|
|
1314
1348
|
existing.keyFn =
|
|
1315
|
-
keyFields === false
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1349
|
+
keyFields === false
|
|
1350
|
+
? nullKeyFieldsFn
|
|
1351
|
+
:
|
|
1352
|
+
utilities.isArray(keyFields)
|
|
1353
|
+
? keyFieldsFnFromSpecifier(keyFields)
|
|
1354
|
+
:
|
|
1355
|
+
typeof keyFields === "function"
|
|
1356
|
+
? keyFields
|
|
1357
|
+
:
|
|
1358
|
+
existing.keyFn;
|
|
1319
1359
|
if (fields) {
|
|
1320
1360
|
Object.keys(fields).forEach(function (fieldName) {
|
|
1321
1361
|
var existing = _this.getFieldPolicy(typename, fieldName, true);
|
|
@@ -1326,10 +1366,16 @@ var Policies = (function () {
|
|
|
1326
1366
|
else {
|
|
1327
1367
|
var keyArgs = incoming.keyArgs, read = incoming.read, merge = incoming.merge;
|
|
1328
1368
|
existing.keyFn =
|
|
1329
|
-
keyArgs === false
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1369
|
+
keyArgs === false
|
|
1370
|
+
? simpleKeyArgsFn
|
|
1371
|
+
:
|
|
1372
|
+
utilities.isArray(keyArgs)
|
|
1373
|
+
? keyArgsFnFromSpecifier(keyArgs)
|
|
1374
|
+
:
|
|
1375
|
+
typeof keyArgs === "function"
|
|
1376
|
+
? keyArgs
|
|
1377
|
+
:
|
|
1378
|
+
existing.keyFn;
|
|
1333
1379
|
if (typeof read === "function") {
|
|
1334
1380
|
existing.read = read;
|
|
1335
1381
|
}
|
|
@@ -1370,7 +1416,7 @@ var Policies = (function () {
|
|
|
1370
1416
|
Policies.prototype.getTypePolicy = function (typename) {
|
|
1371
1417
|
var _this = this;
|
|
1372
1418
|
if (!hasOwn.call(this.typePolicies, typename)) {
|
|
1373
|
-
var policy_1 = this.typePolicies[typename] = Object.create(null);
|
|
1419
|
+
var policy_1 = (this.typePolicies[typename] = Object.create(null));
|
|
1374
1420
|
policy_1.fields = Object.create(null);
|
|
1375
1421
|
var supertypes_1 = this.supertypeMap.get(typename);
|
|
1376
1422
|
if (!supertypes_1 && this.fuzzySubtypes.size) {
|
|
@@ -1379,7 +1425,9 @@ var Policies = (function () {
|
|
|
1379
1425
|
if (regExp.test(typename)) {
|
|
1380
1426
|
var fuzzySupertypes = _this.supertypeMap.get(fuzzy);
|
|
1381
1427
|
if (fuzzySupertypes) {
|
|
1382
|
-
fuzzySupertypes.forEach(function (supertype) {
|
|
1428
|
+
fuzzySupertypes.forEach(function (supertype) {
|
|
1429
|
+
return supertypes_1.add(supertype);
|
|
1430
|
+
});
|
|
1383
1431
|
}
|
|
1384
1432
|
}
|
|
1385
1433
|
});
|
|
@@ -1403,13 +1451,14 @@ var Policies = (function () {
|
|
|
1403
1451
|
Policies.prototype.getFieldPolicy = function (typename, fieldName, createIfMissing) {
|
|
1404
1452
|
if (typename) {
|
|
1405
1453
|
var fieldPolicies = this.getTypePolicy(typename).fields;
|
|
1406
|
-
return fieldPolicies[fieldName] ||
|
|
1454
|
+
return (fieldPolicies[fieldName] ||
|
|
1455
|
+
(createIfMissing && (fieldPolicies[fieldName] = Object.create(null))));
|
|
1407
1456
|
}
|
|
1408
1457
|
};
|
|
1409
1458
|
Policies.prototype.getSupertypeSet = function (subtype, createIfMissing) {
|
|
1410
1459
|
var supertypeSet = this.supertypeMap.get(subtype);
|
|
1411
1460
|
if (!supertypeSet && createIfMissing) {
|
|
1412
|
-
this.supertypeMap.set(subtype, supertypeSet = new Set());
|
|
1461
|
+
this.supertypeMap.set(subtype, (supertypeSet = new Set()));
|
|
1413
1462
|
}
|
|
1414
1463
|
return supertypeSet;
|
|
1415
1464
|
};
|
|
@@ -1422,8 +1471,7 @@ var Policies = (function () {
|
|
|
1422
1471
|
var supertype = fragment.typeCondition.name.value;
|
|
1423
1472
|
if (typename === supertype)
|
|
1424
1473
|
return true;
|
|
1425
|
-
if (this.usingPossibleTypes &&
|
|
1426
|
-
this.supertypeMap.has(supertype)) {
|
|
1474
|
+
if (this.usingPossibleTypes && this.supertypeMap.has(supertype)) {
|
|
1427
1475
|
var typenameSupertypeSet = this.getSupertypeSet(typename, true);
|
|
1428
1476
|
var workQueue_1 = [typenameSupertypeSet];
|
|
1429
1477
|
var maybeEnqueue_1 = function (subtype) {
|
|
@@ -1525,7 +1573,10 @@ var Policies = (function () {
|
|
|
1525
1573
|
var readOptions = makeFieldFunctionOptions(this, objectOrReference, options, context, context.store.getStorage(utilities.isReference(objectOrReference)
|
|
1526
1574
|
? objectOrReference.__ref
|
|
1527
1575
|
: objectOrReference, storeFieldName));
|
|
1528
|
-
return cacheSlot.withValue(this.cache, read, [
|
|
1576
|
+
return cacheSlot.withValue(this.cache, read, [
|
|
1577
|
+
existing,
|
|
1578
|
+
readOptions,
|
|
1579
|
+
]);
|
|
1529
1580
|
}
|
|
1530
1581
|
return existing;
|
|
1531
1582
|
};
|
|
@@ -1553,7 +1604,12 @@ var Policies = (function () {
|
|
|
1553
1604
|
if (context.overwrite) {
|
|
1554
1605
|
existing = void 0;
|
|
1555
1606
|
}
|
|
1556
|
-
return merge(existing, incoming, makeFieldFunctionOptions(this, void 0, {
|
|
1607
|
+
return merge(existing, incoming, makeFieldFunctionOptions(this, void 0, {
|
|
1608
|
+
typename: typename,
|
|
1609
|
+
fieldName: field.name.value,
|
|
1610
|
+
field: field,
|
|
1611
|
+
variables: context.variables,
|
|
1612
|
+
}, context, storage || Object.create(null)));
|
|
1557
1613
|
};
|
|
1558
1614
|
return Policies;
|
|
1559
1615
|
}());
|
|
@@ -1607,21 +1663,18 @@ function makeMergeObjectsFunction(store) {
|
|
|
1607
1663
|
if (utilities.isArray(existing) || utilities.isArray(incoming)) {
|
|
1608
1664
|
throw globals.newInvariantError(6);
|
|
1609
1665
|
}
|
|
1610
|
-
if (utilities.isNonNullObject(existing) &&
|
|
1611
|
-
utilities.isNonNullObject(incoming)) {
|
|
1666
|
+
if (utilities.isNonNullObject(existing) && utilities.isNonNullObject(incoming)) {
|
|
1612
1667
|
var eType = store.getFieldValue(existing, "__typename");
|
|
1613
1668
|
var iType = store.getFieldValue(incoming, "__typename");
|
|
1614
1669
|
var typesDiffer = eType && iType && eType !== iType;
|
|
1615
1670
|
if (typesDiffer) {
|
|
1616
1671
|
return incoming;
|
|
1617
1672
|
}
|
|
1618
|
-
if (utilities.isReference(existing) &&
|
|
1619
|
-
storeValueIsStoreObject(incoming)) {
|
|
1673
|
+
if (utilities.isReference(existing) && storeValueIsStoreObject(incoming)) {
|
|
1620
1674
|
store.merge(existing.__ref, incoming);
|
|
1621
1675
|
return existing;
|
|
1622
1676
|
}
|
|
1623
|
-
if (storeValueIsStoreObject(existing) &&
|
|
1624
|
-
utilities.isReference(incoming)) {
|
|
1677
|
+
if (storeValueIsStoreObject(existing) && utilities.isReference(incoming)) {
|
|
1625
1678
|
store.merge(existing, incoming.__ref);
|
|
1626
1679
|
return incoming;
|
|
1627
1680
|
}
|
|
@@ -1638,8 +1691,10 @@ function getContextFlavor(context, clientOnly, deferred) {
|
|
|
1638
1691
|
var key = "".concat(clientOnly).concat(deferred);
|
|
1639
1692
|
var flavored = context.flavors.get(key);
|
|
1640
1693
|
if (!flavored) {
|
|
1641
|
-
context.flavors.set(key, flavored =
|
|
1642
|
-
context.
|
|
1694
|
+
context.flavors.set(key, (flavored =
|
|
1695
|
+
context.clientOnly === clientOnly && context.deferred === deferred
|
|
1696
|
+
? context
|
|
1697
|
+
: tslib.__assign(tslib.__assign({}, context), { clientOnly: clientOnly, deferred: deferred })));
|
|
1643
1698
|
}
|
|
1644
1699
|
return flavored;
|
|
1645
1700
|
}
|
|
@@ -1657,12 +1712,12 @@ var StoreWriter = (function () {
|
|
|
1657
1712
|
variables = tslib.__assign(tslib.__assign({}, utilities.getDefaultValues(operationDefinition)), variables);
|
|
1658
1713
|
var context = tslib.__assign(tslib.__assign({ store: store, written: Object.create(null), merge: function (existing, incoming) {
|
|
1659
1714
|
return merger.merge(existing, incoming);
|
|
1660
|
-
}, variables: variables, varString: canonicalStringify(variables) }, extractFragmentContext(query, this.fragments)), { overwrite: !!overwrite, incomingById: new Map, clientOnly: false, deferred: false, flavors: new Map });
|
|
1715
|
+
}, variables: variables, varString: canonicalStringify(variables) }, extractFragmentContext(query, this.fragments)), { overwrite: !!overwrite, incomingById: new Map(), clientOnly: false, deferred: false, flavors: new Map() });
|
|
1661
1716
|
var ref = this.processSelectionSet({
|
|
1662
1717
|
result: result || Object.create(null),
|
|
1663
1718
|
dataId: dataId,
|
|
1664
1719
|
selectionSet: operationDefinition.selectionSet,
|
|
1665
|
-
mergeTree: { map: new Map },
|
|
1720
|
+
mergeTree: { map: new Map() },
|
|
1666
1721
|
context: context,
|
|
1667
1722
|
});
|
|
1668
1723
|
if (!utilities.isReference(ref)) {
|
|
@@ -1686,7 +1741,8 @@ var StoreWriter = (function () {
|
|
|
1686
1741
|
}
|
|
1687
1742
|
});
|
|
1688
1743
|
var hasSelectionSet_1 = function (storeFieldName) {
|
|
1689
|
-
return fieldsWithSelectionSets_1[fieldNameFromStoreName(storeFieldName)] ===
|
|
1744
|
+
return fieldsWithSelectionSets_1[fieldNameFromStoreName(storeFieldName)] ===
|
|
1745
|
+
true;
|
|
1690
1746
|
};
|
|
1691
1747
|
var hasMergeFunction_1 = function (storeFieldName) {
|
|
1692
1748
|
var childTree = mergeTree && mergeTree.map.get(storeFieldName);
|
|
@@ -1747,8 +1803,7 @@ var StoreWriter = (function () {
|
|
|
1747
1803
|
: context, childTree);
|
|
1748
1804
|
var childTypename = void 0;
|
|
1749
1805
|
if (field.selectionSet &&
|
|
1750
|
-
(utilities.isReference(incomingValue) ||
|
|
1751
|
-
storeValueIsStoreObject(incomingValue))) {
|
|
1806
|
+
(utilities.isReference(incomingValue) || storeValueIsStoreObject(incomingValue))) {
|
|
1752
1807
|
childTypename = readField("__typename", incomingValue);
|
|
1753
1808
|
}
|
|
1754
1809
|
var merge = policies.getMergeFunction(typename, field.name.value, childTypename);
|
|
@@ -1797,7 +1852,8 @@ var StoreWriter = (function () {
|
|
|
1797
1852
|
if (sets.indexOf(selectionSet) >= 0)
|
|
1798
1853
|
return dataRef;
|
|
1799
1854
|
sets.push(selectionSet);
|
|
1800
|
-
if (this.reader &&
|
|
1855
|
+
if (this.reader &&
|
|
1856
|
+
this.reader.isFresh(result, dataRef, selectionSet, context)) {
|
|
1801
1857
|
return dataRef;
|
|
1802
1858
|
}
|
|
1803
1859
|
var previous_1 = context.incomingById.get(dataId);
|
|
@@ -1890,8 +1946,10 @@ var StoreWriter = (function () {
|
|
|
1890
1946
|
var _a;
|
|
1891
1947
|
var _this = this;
|
|
1892
1948
|
if (mergeTree.map.size && !utilities.isReference(incoming)) {
|
|
1893
|
-
var e_1 =
|
|
1894
|
-
(utilities.isReference(existing) || storeValueIsStoreObject(existing))
|
|
1949
|
+
var e_1 = !utilities.isArray(incoming) &&
|
|
1950
|
+
(utilities.isReference(existing) || storeValueIsStoreObject(existing))
|
|
1951
|
+
? existing
|
|
1952
|
+
: void 0;
|
|
1895
1953
|
var i_1 = incoming;
|
|
1896
1954
|
if (e_1 && !getStorageArgs) {
|
|
1897
1955
|
getStorageArgs = [utilities.isReference(e_1) ? e_1.__ref : e_1];
|
|
@@ -1899,7 +1957,9 @@ var StoreWriter = (function () {
|
|
|
1899
1957
|
var changedFields_1;
|
|
1900
1958
|
var getValue_1 = function (from, name) {
|
|
1901
1959
|
return utilities.isArray(from)
|
|
1902
|
-
?
|
|
1960
|
+
? typeof name === "number"
|
|
1961
|
+
? from[name]
|
|
1962
|
+
: void 0
|
|
1903
1963
|
: context.store.getFieldValue(from, String(name));
|
|
1904
1964
|
};
|
|
1905
1965
|
mergeTree.map.forEach(function (childTree, storeFieldName) {
|
|
@@ -1912,7 +1972,7 @@ var StoreWriter = (function () {
|
|
|
1912
1972
|
}
|
|
1913
1973
|
var aVal = _this.applyMerges(childTree, eVal, iVal, context, getStorageArgs);
|
|
1914
1974
|
if (aVal !== iVal) {
|
|
1915
|
-
changedFields_1 = changedFields_1 || new Map;
|
|
1975
|
+
changedFields_1 = changedFields_1 || new Map();
|
|
1916
1976
|
changedFields_1.set(storeFieldName, aVal);
|
|
1917
1977
|
}
|
|
1918
1978
|
if (getStorageArgs) {
|
|
@@ -1937,7 +1997,7 @@ var emptyMergeTreePool = [];
|
|
|
1937
1997
|
function getChildMergeTree(_a, name) {
|
|
1938
1998
|
var map = _a.map;
|
|
1939
1999
|
if (!map.has(name)) {
|
|
1940
|
-
map.set(name, emptyMergeTreePool.pop() || { map: new Map });
|
|
2000
|
+
map.set(name, emptyMergeTreePool.pop() || { map: new Map() });
|
|
1941
2001
|
}
|
|
1942
2002
|
return map.get(name);
|
|
1943
2003
|
}
|
|
@@ -1946,10 +2006,14 @@ function mergeMergeTrees(left, right) {
|
|
|
1946
2006
|
return left;
|
|
1947
2007
|
if (!left || mergeTreeIsEmpty(left))
|
|
1948
2008
|
return right;
|
|
1949
|
-
var info = left.info && right.info
|
|
2009
|
+
var info = left.info && right.info
|
|
2010
|
+
? tslib.__assign(tslib.__assign({}, left.info), right.info) : left.info || right.info;
|
|
1950
2011
|
var needToMergeMaps = left.map.size && right.map.size;
|
|
1951
|
-
var map = needToMergeMaps
|
|
1952
|
-
|
|
2012
|
+
var map = needToMergeMaps
|
|
2013
|
+
? new Map()
|
|
2014
|
+
: left.map.size
|
|
2015
|
+
? left.map
|
|
2016
|
+
: right.map;
|
|
1953
2017
|
var merged = { info: info, map: map };
|
|
1954
2018
|
if (needToMergeMaps) {
|
|
1955
2019
|
var remainingRightKeys_1 = new Set(right.map.keys());
|
|
@@ -2001,18 +2065,18 @@ function warnAboutDataLoss(existingRef, incomingObj, storeFieldName, store) {
|
|
|
2001
2065
|
return;
|
|
2002
2066
|
warnings.add(typeDotName);
|
|
2003
2067
|
var childTypenames = [];
|
|
2004
|
-
if (!utilities.isArray(existing) &&
|
|
2005
|
-
!utilities.isArray(incoming)) {
|
|
2068
|
+
if (!utilities.isArray(existing) && !utilities.isArray(incoming)) {
|
|
2006
2069
|
[existing, incoming].forEach(function (child) {
|
|
2007
2070
|
var typename = store.getFieldValue(child, "__typename");
|
|
2008
|
-
if (typeof typename === "string" &&
|
|
2009
|
-
!childTypenames.includes(typename)) {
|
|
2071
|
+
if (typeof typename === "string" && !childTypenames.includes(typename)) {
|
|
2010
2072
|
childTypenames.push(typename);
|
|
2011
2073
|
}
|
|
2012
2074
|
});
|
|
2013
2075
|
}
|
|
2014
2076
|
globalThis.__DEV__ !== false && globals.invariant.warn(12, fieldName, parentType, childTypenames.length
|
|
2015
|
-
? "either ensure all objects of type " +
|
|
2077
|
+
? "either ensure all objects of type " +
|
|
2078
|
+
childTypenames.join(" and ") +
|
|
2079
|
+
" have an ID or a custom merge function, or "
|
|
2016
2080
|
: "", typeDotName, existing, incoming);
|
|
2017
2081
|
}
|
|
2018
2082
|
|
|
@@ -2038,10 +2102,10 @@ var InMemoryCache = (function (_super) {
|
|
|
2038
2102
|
return _this;
|
|
2039
2103
|
}
|
|
2040
2104
|
InMemoryCache.prototype.init = function () {
|
|
2041
|
-
var rootStore = this.data = new exports.EntityStore.Root({
|
|
2105
|
+
var rootStore = (this.data = new exports.EntityStore.Root({
|
|
2042
2106
|
policies: this.policies,
|
|
2043
2107
|
resultCaching: this.config.resultCaching,
|
|
2044
|
-
});
|
|
2108
|
+
}));
|
|
2045
2109
|
this.optimisticData = rootStore.stump;
|
|
2046
2110
|
this.resetResultCache();
|
|
2047
2111
|
};
|
|
@@ -2049,7 +2113,7 @@ var InMemoryCache = (function (_super) {
|
|
|
2049
2113
|
var _this = this;
|
|
2050
2114
|
var previousReader = this.storeReader;
|
|
2051
2115
|
var fragments = this.config.fragments;
|
|
2052
|
-
this.storeWriter = new StoreWriter(this, this.storeReader = new StoreReader({
|
|
2116
|
+
this.storeWriter = new StoreWriter(this, (this.storeReader = new StoreReader({
|
|
2053
2117
|
cache: this,
|
|
2054
2118
|
addTypename: this.addTypename,
|
|
2055
2119
|
resultCacheMaxSize: this.config.resultCacheMaxSize,
|
|
@@ -2058,7 +2122,7 @@ var InMemoryCache = (function (_super) {
|
|
|
2058
2122
|
? void 0
|
|
2059
2123
|
: previousReader && previousReader.canon,
|
|
2060
2124
|
fragments: fragments,
|
|
2061
|
-
}), fragments);
|
|
2125
|
+
})), fragments);
|
|
2062
2126
|
this.maybeBroadcastWatch = optimism.wrap(function (c, options) {
|
|
2063
2127
|
return _this.broadcastWatch(c, options);
|
|
2064
2128
|
}, {
|
|
@@ -2069,12 +2133,11 @@ var InMemoryCache = (function (_super) {
|
|
|
2069
2133
|
var optimistic = c.optimistic, id = c.id, variables = c.variables;
|
|
2070
2134
|
return store.makeCacheKey(c.query, c.callback, canonicalStringify({ optimistic: optimistic, id: id, variables: variables }));
|
|
2071
2135
|
}
|
|
2072
|
-
}
|
|
2136
|
+
},
|
|
2137
|
+
});
|
|
2138
|
+
new Set([this.data.group, this.optimisticData.group]).forEach(function (group) {
|
|
2139
|
+
return group.resetCaching();
|
|
2073
2140
|
});
|
|
2074
|
-
new Set([
|
|
2075
|
-
this.data.group,
|
|
2076
|
-
this.optimisticData.group,
|
|
2077
|
-
]).forEach(function (group) { return group.resetCaching(); });
|
|
2078
2141
|
};
|
|
2079
2142
|
InMemoryCache.prototype.restore = function (data) {
|
|
2080
2143
|
this.init();
|
|
@@ -2089,7 +2152,7 @@ var InMemoryCache = (function (_super) {
|
|
|
2089
2152
|
InMemoryCache.prototype.read = function (options) {
|
|
2090
2153
|
var _a = options.returnPartialData, returnPartialData = _a === void 0 ? false : _a;
|
|
2091
2154
|
try {
|
|
2092
|
-
return this.storeReader.diffQueryAgainstStore(tslib.__assign(tslib.__assign({}, options), { store: options.optimistic ? this.optimisticData : this.data, config: this.config, returnPartialData: returnPartialData })).result || null;
|
|
2155
|
+
return (this.storeReader.diffQueryAgainstStore(tslib.__assign(tslib.__assign({}, options), { store: options.optimistic ? this.optimisticData : this.data, config: this.config, returnPartialData: returnPartialData })).result || null);
|
|
2093
2156
|
}
|
|
2094
2157
|
catch (e) {
|
|
2095
2158
|
if (e instanceof MissingFieldError) {
|
|
@@ -2223,7 +2286,7 @@ var InMemoryCache = (function (_super) {
|
|
|
2223
2286
|
_this.data = _this.optimisticData = layer;
|
|
2224
2287
|
}
|
|
2225
2288
|
try {
|
|
2226
|
-
return updateResult = update(_this);
|
|
2289
|
+
return (updateResult = update(_this));
|
|
2227
2290
|
}
|
|
2228
2291
|
finally {
|
|
2229
2292
|
--_this.txCount;
|
|
@@ -2238,7 +2301,7 @@ var InMemoryCache = (function (_super) {
|
|
|
2238
2301
|
return false;
|
|
2239
2302
|
} }));
|
|
2240
2303
|
}
|
|
2241
|
-
if (typeof optimistic ===
|
|
2304
|
+
if (typeof optimistic === "string") {
|
|
2242
2305
|
this.optimisticData = this.optimisticData.addLayer(optimistic, perform);
|
|
2243
2306
|
}
|
|
2244
2307
|
else if (optimistic === false) {
|
|
@@ -2270,7 +2333,7 @@ var InMemoryCache = (function (_super) {
|
|
|
2270
2333
|
InMemoryCache.prototype.performTransaction = function (update, optimisticId) {
|
|
2271
2334
|
return this.batch({
|
|
2272
2335
|
update: update,
|
|
2273
|
-
optimistic: optimisticId ||
|
|
2336
|
+
optimistic: optimisticId || optimisticId !== null,
|
|
2274
2337
|
});
|
|
2275
2338
|
};
|
|
2276
2339
|
InMemoryCache.prototype.transformDocument = function (document) {
|
|
@@ -2284,9 +2347,7 @@ var InMemoryCache = (function (_super) {
|
|
|
2284
2347
|
};
|
|
2285
2348
|
InMemoryCache.prototype.addFragmentsToDocument = function (document) {
|
|
2286
2349
|
var fragments = this.config.fragments;
|
|
2287
|
-
return fragments
|
|
2288
|
-
? fragments.transform(document)
|
|
2289
|
-
: document;
|
|
2350
|
+
return fragments ? fragments.transform(document) : document;
|
|
2290
2351
|
};
|
|
2291
2352
|
InMemoryCache.prototype.addTypenameToDocument = function (document) {
|
|
2292
2353
|
if (this.addTypename) {
|
|
@@ -2298,8 +2359,7 @@ var InMemoryCache = (function (_super) {
|
|
|
2298
2359
|
var lastDiff = c.lastDiff;
|
|
2299
2360
|
var diff = this.diff(c);
|
|
2300
2361
|
if (options) {
|
|
2301
|
-
if (c.optimistic &&
|
|
2302
|
-
typeof options.optimistic === "string") {
|
|
2362
|
+
if (c.optimistic && typeof options.optimistic === "string") {
|
|
2303
2363
|
diff.fromOptimisticTransaction = true;
|
|
2304
2364
|
}
|
|
2305
2365
|
if (options.onWatchUpdated &&
|
|
@@ -2308,7 +2368,7 @@ var InMemoryCache = (function (_super) {
|
|
|
2308
2368
|
}
|
|
2309
2369
|
}
|
|
2310
2370
|
if (!lastDiff || !equality.equal(lastDiff.result, diff.result)) {
|
|
2311
|
-
c.callback(c.lastDiff = diff, lastDiff);
|
|
2371
|
+
c.callback((c.lastDiff = diff), lastDiff);
|
|
2312
2372
|
}
|
|
2313
2373
|
};
|
|
2314
2374
|
return InMemoryCache;
|
|
@@ -2380,20 +2440,22 @@ var FragmentRegistry = (function () {
|
|
|
2380
2440
|
unbound.add(spreadName);
|
|
2381
2441
|
}
|
|
2382
2442
|
};
|
|
2383
|
-
var enqueueChildSpreads = function (node) {
|
|
2443
|
+
var enqueueChildSpreads = function (node) {
|
|
2444
|
+
return Object.keys(_this.findFragmentSpreads(node)).forEach(enqueue);
|
|
2445
|
+
};
|
|
2384
2446
|
enqueueChildSpreads(document);
|
|
2385
2447
|
var missing = [];
|
|
2386
2448
|
var map = Object.create(null);
|
|
2387
2449
|
unbound.forEach(function (fragmentName) {
|
|
2388
2450
|
var knownFragmentDef = defined.get(fragmentName);
|
|
2389
2451
|
if (knownFragmentDef) {
|
|
2390
|
-
enqueueChildSpreads(map[fragmentName] = knownFragmentDef);
|
|
2452
|
+
enqueueChildSpreads((map[fragmentName] = knownFragmentDef));
|
|
2391
2453
|
}
|
|
2392
2454
|
else {
|
|
2393
2455
|
missing.push(fragmentName);
|
|
2394
2456
|
var def = _this.lookup(fragmentName);
|
|
2395
2457
|
if (def) {
|
|
2396
|
-
enqueueChildSpreads(map[fragmentName] = def);
|
|
2458
|
+
enqueueChildSpreads((map[fragmentName] = def));
|
|
2397
2459
|
}
|
|
2398
2460
|
}
|
|
2399
2461
|
});
|