relay-runtime 20.1.1 → 21.0.1
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/experimental.d.ts +34 -0
- package/experimental.js +1 -1
- package/experimental.js.flow +11 -11
- package/handlers/RelayDefaultHandlerProvider.d.ts +12 -0
- package/handlers/connection/ConnectionHandler.d.ts +51 -0
- package/handlers/connection/ConnectionHandler.js.flow +5 -5
- package/handlers/connection/ConnectionInterface.d.ts +40 -0
- package/handlers/connection/ConnectionInterface.js.flow +1 -1
- package/handlers/connection/MutationHandlers.d.ts +17 -0
- package/index.d.ts +274 -0
- package/index.js +1 -1
- package/index.js.flow +125 -62
- package/lib/experimental.js +3 -3
- package/lib/index.js +105 -57
- package/lib/multi-actor-environment/ActorIdentifier.js +2 -2
- package/lib/multi-actor-environment/MultiActorEnvironment.js +3 -1
- package/lib/mutations/commitMutation.js +8 -8
- package/lib/mutations/validateMutation.js +4 -4
- package/lib/query/GraphQLTag.js +3 -3
- package/lib/query/fetchQuery.js +15 -3
- package/lib/store/DataChecker.js +38 -4
- package/lib/store/NormalizationEngine.js +373 -0
- package/lib/store/OperationExecutor.js +172 -113
- package/lib/store/RelayConcreteVariables.js +1 -1
- package/lib/store/RelayErrorTrie.js +2 -2
- package/lib/store/RelayExperimentalGraphResponseTransform.js +8 -8
- package/lib/store/RelayModernEnvironment.js +26 -19
- package/lib/store/RelayModernRecord.js +18 -8
- package/lib/store/RelayModernSelector.js +9 -9
- package/lib/store/RelayModernStore.js +152 -43
- package/lib/store/RelayPublishQueue.js +1 -1
- package/lib/store/RelayReader.js +76 -38
- package/lib/store/RelayRecordSource.js +6 -0
- package/lib/store/RelayReferenceMarker.js +2 -1
- package/lib/store/RelayResponseNormalizer.js +88 -55
- package/lib/store/RelayStoreSubscriptions.js +34 -10
- package/lib/store/RelayStoreUtils.js +8 -1
- package/lib/store/ResolverFragments.js +2 -2
- package/lib/store/live-resolvers/LiveResolverCache.js +25 -9
- package/lib/store/observeFragmentExperimental.js +17 -1
- package/lib/store/observeQueryExperimental.js +2 -2
- package/lib/subscription/requestSubscription.js +3 -3
- package/lib/util/RelayError.js +3 -0
- package/lib/util/RelayFeatureFlags.js +6 -2
- package/lib/util/RelayReplaySubject.js +4 -4
- package/lib/util/handlePotentialSnapshotErrors.js +2 -2
- package/lib/util/stableCopy.js +2 -2
- package/llm-docs/api-reference/entrypoint-apis/entrypoint-container.mdx +38 -0
- package/llm-docs/api-reference/entrypoint-apis/load-entrypoint.mdx +77 -0
- package/llm-docs/api-reference/entrypoint-apis/use-entrypoint-loader.mdx +99 -0
- package/llm-docs/api-reference/graphql/graphql-directives.mdx +378 -0
- package/llm-docs/api-reference/hooks/_use-lazy-load-query-extra.mdx +16 -0
- package/llm-docs/api-reference/hooks/load-query.mdx +84 -0
- package/llm-docs/api-reference/hooks/relay-environment-provider.mdx +78 -0
- package/llm-docs/api-reference/hooks/use-client-query.mdx +65 -0
- package/llm-docs/api-reference/hooks/use-fragment.mdx +69 -0
- package/llm-docs/api-reference/hooks/use-lazy-load-query.mdx +62 -0
- package/llm-docs/api-reference/hooks/use-mutation.mdx +94 -0
- package/llm-docs/api-reference/hooks/use-pagination-fragment.mdx +166 -0
- package/llm-docs/api-reference/hooks/use-prefetchable-forward-pagination-fragment.mdx +134 -0
- package/llm-docs/api-reference/hooks/use-preloaded-query.mdx +84 -0
- package/llm-docs/api-reference/hooks/use-query-loader.mdx +95 -0
- package/llm-docs/api-reference/hooks/use-refetchable-fragment.mdx +122 -0
- package/llm-docs/api-reference/hooks/use-relay-environment.mdx +37 -0
- package/llm-docs/api-reference/hooks/use-subscription.mdx +66 -0
- package/llm-docs/api-reference/relay-resolvers/docblock-format.mdx +321 -0
- package/llm-docs/api-reference/relay-resolvers/runtime-functions.mdx +94 -0
- package/llm-docs/api-reference/relay-runtime/commit-mutation.mdx +65 -0
- package/llm-docs/api-reference/relay-runtime/fetch-query.mdx +118 -0
- package/llm-docs/api-reference/relay-runtime/field-logger.mdx +170 -0
- package/llm-docs/api-reference/relay-runtime/observe-fragment.mdx +92 -0
- package/llm-docs/api-reference/relay-runtime/relay-environment.mdx +53 -0
- package/llm-docs/api-reference/relay-runtime/request-subscription.mdx +54 -0
- package/llm-docs/api-reference/relay-runtime/runtime-configuration.mdx +52 -0
- package/llm-docs/api-reference/relay-runtime/store.mdx +734 -0
- package/llm-docs/api-reference/relay-runtime/wait-for-fragment-data.mdx +89 -0
- package/llm-docs/api-reference/types/CacheConfig.mdx +8 -0
- package/llm-docs/api-reference/types/Disposable.mdx +4 -0
- package/llm-docs/api-reference/types/GraphQLSubscriptionConfig.mdx +17 -0
- package/llm-docs/api-reference/types/MutationConfig.mdx +31 -0
- package/llm-docs/api-reference/types/SelectorStoreUpdater.mdx +6 -0
- package/llm-docs/api-reference/types/UploadableMap.mdx +3 -0
- package/llm-docs/community/learning-resources.mdx +64 -0
- package/llm-docs/debugging/declarative-mutation-directives.mdx +34 -0
- package/llm-docs/debugging/disallowed-id-types-error.mdx +43 -0
- package/llm-docs/debugging/inconsistent-typename-error.mdx +47 -0
- package/llm-docs/debugging/relay-devtools.mdx +73 -0
- package/llm-docs/debugging/why-null.mdx +116 -0
- package/llm-docs/editor-support.mdx +55 -0
- package/llm-docs/error-reference/unknown-field.mdx +36 -0
- package/llm-docs/getting-started/babel-plugin.mdx +31 -0
- package/llm-docs/getting-started/compiler-config.mdx +25 -0
- package/llm-docs/getting-started/compiler.mdx +98 -0
- package/llm-docs/getting-started/lint-rules.mdx +87 -0
- package/llm-docs/getting-started/production.mdx +30 -0
- package/llm-docs/getting-started/quick-start.mdx +216 -0
- package/llm-docs/glossary/glossary.mdx +1040 -0
- package/llm-docs/guided-tour/list-data/advanced-pagination.mdx +157 -0
- package/llm-docs/guided-tour/list-data/connections.mdx +81 -0
- package/llm-docs/guided-tour/list-data/pagination.mdx +193 -0
- package/llm-docs/guided-tour/list-data/rendering-connections.mdx +112 -0
- package/llm-docs/guided-tour/list-data/streaming-pagination.mdx +87 -0
- package/llm-docs/guided-tour/managing-data-outside-react/retaining-queries.mdx +51 -0
- package/llm-docs/guided-tour/refetching/refetching-queries-with-different-data.mdx +337 -0
- package/llm-docs/guided-tour/refetching/refreshing-queries.mdx +350 -0
- package/llm-docs/guided-tour/rendering/environment.mdx +59 -0
- package/llm-docs/guided-tour/rendering/error-states.mdx +295 -0
- package/llm-docs/guided-tour/rendering/fragments.mdx +354 -0
- package/llm-docs/guided-tour/rendering/loading-states.mdx +245 -0
- package/llm-docs/guided-tour/rendering/queries.mdx +261 -0
- package/llm-docs/guided-tour/rendering/variables.mdx +233 -0
- package/llm-docs/guided-tour/reusing-cached-data/fetch-policies.mdx +56 -0
- package/llm-docs/guided-tour/reusing-cached-data/filling-in-missing-data.mdx +102 -0
- package/llm-docs/guided-tour/reusing-cached-data/introduction.mdx +22 -0
- package/llm-docs/guided-tour/reusing-cached-data/presence-of-data.mdx +93 -0
- package/llm-docs/guided-tour/reusing-cached-data/rendering-partially-cached-data.mdx +175 -0
- package/llm-docs/guided-tour/reusing-cached-data/staleness-of-data.mdx +116 -0
- package/llm-docs/guided-tour/updating-data/client-only-data.mdx +115 -0
- package/llm-docs/guided-tour/updating-data/graphql-mutations.mdx +334 -0
- package/llm-docs/guided-tour/updating-data/graphql-subscriptions.mdx +279 -0
- package/llm-docs/guided-tour/updating-data/imperatively-modifying-linked-fields.mdx +511 -0
- package/llm-docs/guided-tour/updating-data/imperatively-modifying-store-data-legacy.mdx +142 -0
- package/llm-docs/guided-tour/updating-data/imperatively-modifying-store-data.mdx +275 -0
- package/llm-docs/guided-tour/updating-data/introduction.mdx +25 -0
- package/llm-docs/guided-tour/updating-data/local-data-updates.mdx +71 -0
- package/llm-docs/guided-tour/updating-data/typesafe-updaters-faq.mdx +83 -0
- package/llm-docs/guided-tour/updating-data/updating-connections.mdx +592 -0
- package/llm-docs/guides/alias-directive.mdx +160 -0
- package/llm-docs/guides/catch-directive.mdx +167 -0
- package/llm-docs/guides/client-schema-extensions.mdx +208 -0
- package/llm-docs/guides/codemods.mdx +79 -0
- package/llm-docs/guides/data-driven-dependencies/client-3d.mdx +255 -0
- package/llm-docs/guides/data-driven-dependencies/configuration.mdx +127 -0
- package/llm-docs/guides/data-driven-dependencies/introduction.mdx +39 -0
- package/llm-docs/guides/data-driven-dependencies/server-3d.mdx +664 -0
- package/llm-docs/guides/document-comparison.mdx +106 -0
- package/llm-docs/guides/graphql-server-specification.mdx +453 -0
- package/llm-docs/guides/network-layer.mdx +69 -0
- package/llm-docs/guides/persisted-queries.mdx +328 -0
- package/llm-docs/guides/relay-resolvers/context.mdx +99 -0
- package/llm-docs/guides/relay-resolvers/defining-fields.mdx +151 -0
- package/llm-docs/guides/relay-resolvers/defining-types.mdx +164 -0
- package/llm-docs/guides/relay-resolvers/deprecated.mdx +27 -0
- package/llm-docs/guides/relay-resolvers/derived-fields.mdx +127 -0
- package/llm-docs/guides/relay-resolvers/descriptions.mdx +44 -0
- package/llm-docs/guides/relay-resolvers/enabling.mdx +41 -0
- package/llm-docs/guides/relay-resolvers/errors.mdx +64 -0
- package/llm-docs/guides/relay-resolvers/field-arguments.mdx +63 -0
- package/llm-docs/guides/relay-resolvers/introduction.mdx +62 -0
- package/llm-docs/guides/relay-resolvers/limitations.mdx +30 -0
- package/llm-docs/guides/relay-resolvers/live-fields.mdx +164 -0
- package/llm-docs/guides/relay-resolvers/return-types.mdx +161 -0
- package/llm-docs/guides/relay-resolvers/suspense.mdx +41 -0
- package/llm-docs/guides/required-directive.mdx +240 -0
- package/llm-docs/guides/semantic-nullability.mdx +93 -0
- package/llm-docs/guides/testing-relay-components.mdx +642 -0
- package/llm-docs/guides/testing-relay-with-preloaded-queries.mdx +160 -0
- package/llm-docs/guides/throw-on-field-error-directive.mdx +58 -0
- package/llm-docs/guides/type-emission.mdx +414 -0
- package/llm-docs/home.mdx +32 -0
- package/llm-docs/principles-and-architecture/architecture-overview.mdx +24 -0
- package/llm-docs/principles-and-architecture/compiler-architecture.mdx +106 -0
- package/llm-docs/principles-and-architecture/runtime-architecture.mdx +249 -0
- package/llm-docs/principles-and-architecture/thinking-in-graphql.mdx +309 -0
- package/llm-docs/principles-and-architecture/thinking-in-relay.mdx +104 -0
- package/llm-docs/principles-and-architecture/videos.mdx +50 -0
- package/llm-docs/tutorial/arrays-lists.mdx +126 -0
- package/llm-docs/tutorial/fragments-1.mdx +487 -0
- package/llm-docs/tutorial/graphql.mdx +172 -0
- package/llm-docs/tutorial/interfaces-polymorphism.mdx +161 -0
- package/llm-docs/tutorial/intro.mdx +58 -0
- package/llm-docs/tutorial/mutations-updates.mdx +624 -0
- package/llm-docs/tutorial/organizing-mutations-queries-and-subscriptions.mdx +13 -0
- package/llm-docs/tutorial/queries-1.mdx +267 -0
- package/llm-docs/tutorial/queries-2.mdx +389 -0
- package/llm-docs/tutorial/refetchable-fragments.mdx +352 -0
- package/multi-actor-environment/ActorIdentifier.d.ts +17 -0
- package/multi-actor-environment/ActorIdentifier.js.flow +2 -2
- package/multi-actor-environment/ActorSpecificEnvironment.js.flow +15 -15
- package/multi-actor-environment/ActorUtils.js.flow +1 -1
- package/multi-actor-environment/MultiActorEnvironment.d.ts +123 -0
- package/multi-actor-environment/MultiActorEnvironment.js.flow +32 -24
- package/multi-actor-environment/MultiActorEnvironmentTypes.d.ts +225 -0
- package/multi-actor-environment/MultiActorEnvironmentTypes.js.flow +6 -6
- package/multi-actor-environment/index.d.ts +14 -0
- package/multi-actor-environment.d.ts +8 -0
- package/mutations/RelayDeclarativeMutationConfig.d.ts +70 -0
- package/mutations/RelayDeclarativeMutationConfig.js.flow +9 -9
- package/mutations/RelayRecordProxy.js.flow +8 -11
- package/mutations/RelayRecordSourceMutator.js.flow +4 -4
- package/mutations/RelayRecordSourceProxy.js.flow +4 -4
- package/mutations/RelayRecordSourceSelectorProxy.js.flow +6 -6
- package/mutations/applyOptimisticMutation.d.ts +25 -0
- package/mutations/applyOptimisticMutation.js.flow +2 -2
- package/mutations/commitLocalUpdate.d.ts +10 -0
- package/mutations/commitMutation.d.ts +48 -0
- package/mutations/commitMutation.js.flow +21 -17
- package/mutations/createUpdatableProxy.js.flow +19 -19
- package/mutations/readUpdatableFragment.js.flow +3 -3
- package/mutations/readUpdatableQuery.js.flow +3 -3
- package/mutations/validateMutation.js.flow +7 -7
- package/network/RelayNetwork.d.ts +12 -0
- package/network/RelayNetworkTypes.d.ts +145 -0
- package/network/RelayNetworkTypes.js.flow +18 -18
- package/network/RelayObservable.d.ts +197 -0
- package/network/RelayObservable.js.flow +32 -30
- package/network/RelayQueryResponseCache.d.ts +16 -0
- package/network/RelayQueryResponseCache.js.flow +3 -3
- package/network/wrapNetworkWithLogObserver.js.flow +1 -1
- package/package.json +2 -1
- package/query/GraphQLTag.d.ts +45 -0
- package/query/GraphQLTag.js.flow +22 -10
- package/query/fetchQuery.d.ts +21 -0
- package/query/fetchQuery.js.flow +23 -10
- package/query/fetchQueryInternal.d.ts +26 -0
- package/query/fetchQueryInternal.js.flow +4 -4
- package/query/fetchQuery_DEPRECATED.d.ts +17 -0
- package/query/fetchQuery_DEPRECATED.js.flow +1 -1
- package/store/ClientID.d.ts +14 -0
- package/store/DataChecker.js.flow +51 -15
- package/store/NormalizationEngine.js.flow +782 -0
- package/store/OperationExecutor.d.ts +51 -0
- package/store/OperationExecutor.js.flow +204 -98
- package/store/RelayConcreteVariables.js.flow +5 -5
- package/store/RelayErrorTrie.js.flow +12 -12
- package/store/RelayExperimentalGraphResponseHandler.js.flow +3 -3
- package/store/RelayExperimentalGraphResponseTransform.js.flow +10 -10
- package/store/RelayModernEnvironment.d.ts +97 -0
- package/store/RelayModernEnvironment.js.flow +58 -43
- package/store/RelayModernFragmentSpecResolver.js.flow +1 -1
- package/store/RelayModernOperationDescriptor.d.ts +28 -0
- package/store/RelayModernOperationDescriptor.js.flow +1 -1
- package/store/RelayModernRecord.d.ts +92 -0
- package/store/RelayModernRecord.js.flow +44 -20
- package/store/RelayModernSelector.d.ts +123 -0
- package/store/RelayModernSelector.js.flow +21 -21
- package/store/RelayModernStore.d.ts +57 -0
- package/store/RelayModernStore.js.flow +219 -58
- package/store/RelayOperationTracker.d.ts +29 -0
- package/store/RelayOperationTracker.js.flow +2 -2
- package/store/RelayOptimisticRecordSource.js.flow +2 -2
- package/store/RelayPublishQueue.js.flow +29 -20
- package/store/RelayReader.js.flow +129 -57
- package/store/RelayRecordSource.d.ts +26 -0
- package/store/RelayRecordSource.js.flow +10 -0
- package/store/RelayRecordState.d.ts +28 -0
- package/store/RelayRecordState.js.flow +1 -1
- package/store/RelayReferenceMarker.js.flow +5 -4
- package/store/RelayResponseNormalizer.d.ts +28 -0
- package/store/RelayResponseNormalizer.js.flow +130 -62
- package/store/RelayStoreSubscriptions.js.flow +52 -8
- package/store/RelayStoreTypes.d.ts +1327 -0
- package/store/RelayStoreTypes.js.flow +371 -278
- package/store/RelayStoreUtils.d.ts +86 -0
- package/store/RelayStoreUtils.js.flow +16 -8
- package/store/ResolverCache.js.flow +2 -2
- package/store/ResolverFragments.d.ts +43 -0
- package/store/ResolverFragments.js.flow +22 -14
- package/store/StoreInspector.js.flow +7 -8
- package/store/ViewerPattern.d.ts +11 -0
- package/store/cloneRelayHandleSourceField.js.flow +1 -1
- package/store/cloneRelayScalarHandleSourceField.js.flow +1 -1
- package/store/createFragmentSpecResolver.d.ts +16 -0
- package/store/createRelayContext.js.flow +1 -1
- package/store/createRelayLoggingContext.js.flow +4 -4
- package/store/defaultGetDataID.js.flow +2 -2
- package/store/isRelayModernEnvironment.d.ts +8 -0
- package/store/isRelayModernEnvironment.js.flow +4 -2
- package/store/live-resolvers/LiveResolverCache.js.flow +55 -20
- package/store/live-resolvers/LiveResolverSuspenseSentinel.js.flow +3 -3
- package/store/live-resolvers/getOutputTypeRecordIDs.js.flow +1 -1
- package/store/live-resolvers/isLiveStateValue.js.flow +2 -2
- package/store/live-resolvers/resolverDataInjector.d.ts +27 -0
- package/store/live-resolvers/resolverDataInjector.js.flow +8 -5
- package/store/observeFragmentExperimental.d.ts +46 -0
- package/store/observeFragmentExperimental.js.flow +50 -21
- package/store/observeQueryExperimental.d.ts +30 -0
- package/store/observeQueryExperimental.js.flow +5 -5
- package/store/readInlineData.d.ts +19 -0
- package/store/readInlineData.js.flow +5 -5
- package/store/waitForFragmentExperimental.d.ts +49 -0
- package/store/waitForFragmentExperimental.js.flow +3 -3
- package/subscription/requestSubscription.d.ts +27 -0
- package/subscription/requestSubscription.js.flow +10 -10
- package/util/JSResourceTypes.flow.js.flow +4 -4
- package/util/NormalizationNode.d.ts +235 -0
- package/util/NormalizationNode.js.flow +127 -123
- package/util/ReaderNode.d.ts +264 -0
- package/util/ReaderNode.js.flow +156 -151
- package/util/RelayConcreteNode.d.ts +120 -0
- package/util/RelayConcreteNode.js.flow +32 -32
- package/util/RelayError.d.ts +13 -0
- package/util/RelayError.js.flow +4 -1
- package/util/RelayFeatureFlags.d.ts +40 -0
- package/util/RelayFeatureFlags.js.flow +21 -1
- package/util/RelayProfiler.d.ts +121 -0
- package/util/RelayProfiler.js.flow +1 -1
- package/util/RelayReplaySubject.d.ts +25 -0
- package/util/RelayReplaySubject.js.flow +3 -3
- package/util/RelayRuntimeTypes.d.ts +59 -0
- package/util/RelayRuntimeTypes.js.flow +36 -33
- package/util/createPayloadFor3DField.d.ts +17 -0
- package/util/createPayloadFor3DField.js.flow +9 -5
- package/util/deepFreeze.d.ts +8 -0
- package/util/deepFreeze.js.flow +2 -2
- package/util/getFragmentIdentifier.d.ts +10 -0
- package/util/getFragmentIdentifier.js.flow +1 -1
- package/util/getPaginationMetadata.d.ts +20 -0
- package/util/getPaginationMetadata.js.flow +1 -1
- package/util/getPaginationVariables.d.ts +20 -0
- package/util/getPaginationVariables.js.flow +1 -1
- package/util/getPendingOperationsForFragment.d.ts +18 -0
- package/util/getPendingOperationsForFragment.js.flow +2 -2
- package/util/getRefetchMetadata.d.ts +19 -0
- package/util/getRefetchMetadata.js.flow +6 -5
- package/util/getRelayHandleKey.d.ts +8 -0
- package/util/getRequestIdentifier.d.ts +17 -0
- package/util/getValueAtPath.d.ts +8 -0
- package/util/getValueAtPath.js.flow +3 -3
- package/util/handlePotentialSnapshotErrors.d.ts +14 -0
- package/util/handlePotentialSnapshotErrors.js.flow +5 -5
- package/util/isEmptyObject.js.flow +1 -1
- package/util/isPromise.d.ts +8 -0
- package/util/isPromise.js.flow +2 -2
- package/util/isScalarAndEqual.d.ts +8 -0
- package/util/isScalarAndEqual.js.flow +1 -1
- package/util/recycleNodesInto.d.ts +8 -0
- package/util/recycleNodesInto.js.flow +2 -2
- package/util/registerEnvironmentWithDevTools.js.flow +1 -1
- package/util/shallowFreeze.js.flow +1 -1
- package/util/stableCopy.d.ts +8 -0
- package/util/stableCopy.js.flow +5 -5
- package/util/withProvidedVariables.d.ts +19 -0
- package/util/withProvidedVariables.js.flow +14 -10
|
@@ -71,25 +71,31 @@ const {ROOT_TYPE, TYPENAME_KEY, getStorageKey} = require('./RelayStoreUtils');
|
|
|
71
71
|
const invariant = require('invariant');
|
|
72
72
|
const warning = require('warning');
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
74
|
+
// A network response OR a pre-normalized payload from the network layer.
|
|
75
|
+
// RelayObservable<+T> is covariant, so Observable<GraphQLResponse> is
|
|
76
|
+
// assignable to Observable<NetworkResponse> automatically.
|
|
77
|
+
type NetworkResponse = GraphQLResponse | RelayResponsePayload;
|
|
78
|
+
|
|
79
|
+
export type ExecuteConfig<TMutation extends MutationParameters> = {
|
|
80
|
+
readonly actorIdentifier: ActorIdentifier,
|
|
81
|
+
readonly getDataID: GetDataID,
|
|
82
|
+
readonly getPublishQueue: (actorIdentifier: ActorIdentifier) => PublishQueue,
|
|
83
|
+
readonly getStore: (actorIdentifier: ActorIdentifier) => Store,
|
|
84
|
+
readonly normalizeResponse: NormalizeResponseFunction,
|
|
85
|
+
readonly isClientPayload?: boolean,
|
|
86
|
+
readonly operation: OperationDescriptor,
|
|
87
|
+
readonly operationExecutions: Map<string, ActiveState>,
|
|
88
|
+
readonly operationLoader: ?OperationLoader,
|
|
89
|
+
readonly operationTracker: OperationTracker,
|
|
90
|
+
readonly optimisticConfig: ?OptimisticResponseConfig<TMutation>,
|
|
91
|
+
readonly scheduler?: ?TaskScheduler,
|
|
92
|
+
readonly shouldProcessClientComponents?: ?boolean,
|
|
93
|
+
readonly sink: Sink<GraphQLResponse>,
|
|
94
|
+
readonly source: RelayObservable<NetworkResponse>,
|
|
95
|
+
readonly treatMissingFieldsAsNull: boolean,
|
|
96
|
+
readonly deferDeduplicatedFields: boolean,
|
|
97
|
+
readonly updater?: ?SelectorStoreUpdater<TMutation['response']>,
|
|
98
|
+
readonly log: LogFunction,
|
|
93
99
|
};
|
|
94
100
|
|
|
95
101
|
export type ActiveState = 'active' | 'inactive';
|
|
@@ -98,21 +104,21 @@ type Label = string;
|
|
|
98
104
|
type PathKey = string;
|
|
99
105
|
type IncrementalResults =
|
|
100
106
|
| {
|
|
101
|
-
|
|
102
|
-
|
|
107
|
+
readonly kind: 'placeholder',
|
|
108
|
+
readonly placeholder: IncrementalDataPlaceholder,
|
|
103
109
|
}
|
|
104
110
|
| {
|
|
105
|
-
|
|
106
|
-
|
|
111
|
+
readonly kind: 'response',
|
|
112
|
+
readonly responses: Array<IncrementalGraphQLResponse>,
|
|
107
113
|
};
|
|
108
114
|
|
|
109
115
|
type IncrementalGraphQLResponse = {
|
|
110
116
|
label: string,
|
|
111
|
-
path:
|
|
117
|
+
path: ReadonlyArray<unknown>,
|
|
112
118
|
response: GraphQLResponseWithData,
|
|
113
119
|
};
|
|
114
120
|
|
|
115
|
-
function execute<TMutation
|
|
121
|
+
function execute<TMutation extends MutationParameters>(
|
|
116
122
|
config: ExecuteConfig<TMutation>,
|
|
117
123
|
): Executor<TMutation> {
|
|
118
124
|
return new Executor(config);
|
|
@@ -123,10 +129,11 @@ function execute<TMutation: MutationParameters>(
|
|
|
123
129
|
* including optimistic payloads, standard payloads, resolution of match
|
|
124
130
|
* dependencies, etc.
|
|
125
131
|
*/
|
|
126
|
-
class Executor<TMutation
|
|
132
|
+
class Executor<TMutation extends MutationParameters> {
|
|
127
133
|
_actorIdentifier: ActorIdentifier;
|
|
128
134
|
_getDataID: GetDataID;
|
|
129
135
|
_treatMissingFieldsAsNull: boolean;
|
|
136
|
+
_deferDeduplicatedFields: boolean;
|
|
130
137
|
_incrementalPayloadsPending: boolean;
|
|
131
138
|
_incrementalResults: Map<Label, Map<PathKey, IncrementalResults>>;
|
|
132
139
|
_log: LogFunction;
|
|
@@ -140,26 +147,30 @@ class Executor<TMutation: MutationParameters> {
|
|
|
140
147
|
_optimisticUpdates: null | Array<OptimisticUpdate<TMutation>>;
|
|
141
148
|
_useExecTimeResolvers: boolean;
|
|
142
149
|
_pendingModulePayloadsCount: number;
|
|
143
|
-
|
|
150
|
+
readonly _getPublishQueue: (actorIdentifier: ActorIdentifier) => PublishQueue;
|
|
144
151
|
_shouldProcessClientComponents: ?boolean;
|
|
145
152
|
_scheduler: ?TaskScheduler;
|
|
146
153
|
_sink: Sink<GraphQLResponse>;
|
|
147
154
|
_source: Map<
|
|
148
155
|
string,
|
|
149
|
-
{
|
|
156
|
+
{
|
|
157
|
+
readonly record: Record,
|
|
158
|
+
readonly fieldPayloads: Array<HandleFieldPayload>,
|
|
159
|
+
},
|
|
150
160
|
>;
|
|
151
161
|
_state: 'started' | 'loading_incremental' | 'loading_final' | 'completed';
|
|
152
|
-
|
|
162
|
+
readonly _getStore: (actorIdentifier: ActorIdentifier) => Store;
|
|
153
163
|
_subscriptions: Map<number, Subscription>;
|
|
154
164
|
_updater: ?SelectorStoreUpdater<TMutation['response']>;
|
|
155
165
|
_asyncStoreUpdateDisposable: ?Disposable;
|
|
156
166
|
_completeFns: Array<() => void>;
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
167
|
+
readonly _retainDisposables: Map<ActorIdentifier, Disposable>;
|
|
168
|
+
readonly _isClientPayload: boolean;
|
|
169
|
+
readonly _isSubscriptionOperation: boolean;
|
|
170
|
+
readonly _seenActors: Set<ActorIdentifier>;
|
|
161
171
|
_normalizeResponse: NormalizeResponseFunction;
|
|
162
172
|
_execTimeResolverResponseComplete: boolean;
|
|
173
|
+
_isClientQuery: boolean;
|
|
163
174
|
|
|
164
175
|
constructor({
|
|
165
176
|
actorIdentifier,
|
|
@@ -177,6 +188,7 @@ class Executor<TMutation: MutationParameters> {
|
|
|
177
188
|
sink,
|
|
178
189
|
source,
|
|
179
190
|
treatMissingFieldsAsNull,
|
|
191
|
+
deferDeduplicatedFields,
|
|
180
192
|
updater,
|
|
181
193
|
log,
|
|
182
194
|
normalizeResponse,
|
|
@@ -184,6 +196,7 @@ class Executor<TMutation: MutationParameters> {
|
|
|
184
196
|
this._actorIdentifier = actorIdentifier;
|
|
185
197
|
this._getDataID = getDataID;
|
|
186
198
|
this._treatMissingFieldsAsNull = treatMissingFieldsAsNull;
|
|
199
|
+
this._deferDeduplicatedFields = deferDeduplicatedFields;
|
|
187
200
|
this._incrementalPayloadsPending = false;
|
|
188
201
|
this._incrementalResults = new Map();
|
|
189
202
|
this._log = log;
|
|
@@ -218,6 +231,9 @@ class Executor<TMutation: MutationParameters> {
|
|
|
218
231
|
this._seenActors = new Set();
|
|
219
232
|
this._completeFns = [];
|
|
220
233
|
this._normalizeResponse = normalizeResponse;
|
|
234
|
+
this._isClientQuery =
|
|
235
|
+
this._operation.request.node.params.id == null &&
|
|
236
|
+
this._operation.request.node.params.text == null;
|
|
221
237
|
|
|
222
238
|
const id = this._nextSubscriptionId++;
|
|
223
239
|
|
|
@@ -246,17 +262,17 @@ class Executor<TMutation: MutationParameters> {
|
|
|
246
262
|
start: subscription => {
|
|
247
263
|
this._start(id, subscription);
|
|
248
264
|
this._log({
|
|
249
|
-
|
|
265
|
+
cacheConfig: this._operation.request.cacheConfig ?? {},
|
|
250
266
|
executeId: this._executeId,
|
|
267
|
+
name: 'execute.start',
|
|
251
268
|
params: this._operation.request.node.params,
|
|
252
269
|
variables: this._operation.request.variables,
|
|
253
|
-
cacheConfig: this._operation.request.cacheConfig ?? {},
|
|
254
270
|
});
|
|
255
271
|
},
|
|
256
272
|
unsubscribe: () => {
|
|
257
273
|
this._log({
|
|
258
|
-
name: 'execute.unsubscribe',
|
|
259
274
|
executeId: this._executeId,
|
|
275
|
+
name: 'execute.unsubscribe',
|
|
260
276
|
});
|
|
261
277
|
},
|
|
262
278
|
});
|
|
@@ -331,7 +347,7 @@ class Executor<TMutation: MutationParameters> {
|
|
|
331
347
|
break;
|
|
332
348
|
}
|
|
333
349
|
default:
|
|
334
|
-
|
|
350
|
+
this._state as empty;
|
|
335
351
|
invariant(false, 'OperationExecutor: invalid executor state.');
|
|
336
352
|
}
|
|
337
353
|
this._operationExecutions.set(
|
|
@@ -370,8 +386,8 @@ class Executor<TMutation: MutationParameters> {
|
|
|
370
386
|
this.cancel();
|
|
371
387
|
this._sink.complete();
|
|
372
388
|
this._log({
|
|
373
|
-
name: 'execute.complete',
|
|
374
389
|
executeId: this._executeId,
|
|
390
|
+
name: 'execute.complete',
|
|
375
391
|
});
|
|
376
392
|
}
|
|
377
393
|
}
|
|
@@ -380,9 +396,9 @@ class Executor<TMutation: MutationParameters> {
|
|
|
380
396
|
this.cancel();
|
|
381
397
|
this._sink.error(error);
|
|
382
398
|
this._log({
|
|
383
|
-
name: 'execute.error',
|
|
384
|
-
executeId: this._executeId,
|
|
385
399
|
error,
|
|
400
|
+
executeId: this._executeId,
|
|
401
|
+
name: 'execute.error',
|
|
386
402
|
});
|
|
387
403
|
}
|
|
388
404
|
|
|
@@ -391,30 +407,48 @@ class Executor<TMutation: MutationParameters> {
|
|
|
391
407
|
this._updateActiveState();
|
|
392
408
|
}
|
|
393
409
|
|
|
394
|
-
// Handle a raw GraphQL response
|
|
395
|
-
|
|
410
|
+
// Handle a raw GraphQL response or a pre-normalized payload from the
|
|
411
|
+
// network layer. Pre-normalized payloads bypass the normal GraphQL pipeline.
|
|
412
|
+
_next(_id: number, response: NetworkResponse): void {
|
|
396
413
|
const priority = this._state === 'loading_incremental' ? 'low' : 'default';
|
|
397
414
|
this._schedule(() => {
|
|
415
|
+
// Pre-normalized payloads from the network layer have isPreNormalized
|
|
416
|
+
// set by NormalizationEngine. Route them to a dedicated handler that
|
|
417
|
+
// commits directly to the store, bypassing normalizeResponse().
|
|
418
|
+
if (
|
|
419
|
+
!Array.isArray(response) &&
|
|
420
|
+
// $FlowFixMe[prop-missing] isPreNormalized exists on RelayResponsePayload branch
|
|
421
|
+
response.isPreNormalized === true
|
|
422
|
+
) {
|
|
423
|
+
// $FlowFixMe[incompatible-type] narrowed by isPreNormalized check
|
|
424
|
+
this._handlePreNormalizedPayload(response);
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
// After the pre-normalized early return, response is a standard
|
|
428
|
+
// GraphQLResponse (Flow cannot narrow this automatically because
|
|
429
|
+
// isPreNormalized is optional, so we cast once here at the boundary).
|
|
430
|
+
// $FlowFixMe[incompatible-type] narrowed by isPreNormalized check above
|
|
431
|
+
const graphQLResponse: GraphQLResponse = response;
|
|
398
432
|
this._log({
|
|
399
|
-
name: 'execute.next.start',
|
|
400
433
|
executeId: this._executeId,
|
|
401
|
-
|
|
434
|
+
name: 'execute.next.start',
|
|
402
435
|
operation: this._operation,
|
|
436
|
+
response: graphQLResponse,
|
|
403
437
|
});
|
|
404
|
-
this._handleNext(
|
|
438
|
+
this._handleNext(graphQLResponse);
|
|
405
439
|
this._maybeCompleteSubscriptionOperationTracking();
|
|
406
440
|
this._log({
|
|
407
|
-
name: 'execute.next.end',
|
|
408
441
|
executeId: this._executeId,
|
|
409
|
-
|
|
442
|
+
name: 'execute.next.end',
|
|
410
443
|
operation: this._operation,
|
|
444
|
+
response: graphQLResponse,
|
|
411
445
|
});
|
|
412
446
|
}, priority);
|
|
413
447
|
}
|
|
414
448
|
|
|
415
449
|
_handleErrorResponse(
|
|
416
|
-
responses:
|
|
417
|
-
):
|
|
450
|
+
responses: ReadonlyArray<GraphQLSingularResponse>,
|
|
451
|
+
): ReadonlyArray<GraphQLResponseWithData> {
|
|
418
452
|
const results = [];
|
|
419
453
|
responses.forEach(response => {
|
|
420
454
|
if (
|
|
@@ -442,7 +476,7 @@ class Executor<TMutation: MutationParameters> {
|
|
|
442
476
|
messages +
|
|
443
477
|
'\n\nSee the error `source` property for more information.',
|
|
444
478
|
);
|
|
445
|
-
(error
|
|
479
|
+
(error as $FlowFixMe).source = {
|
|
446
480
|
errors,
|
|
447
481
|
operation: this._operation.request.node,
|
|
448
482
|
variables: this._operation.request.variables,
|
|
@@ -453,7 +487,7 @@ class Executor<TMutation: MutationParameters> {
|
|
|
453
487
|
throw error;
|
|
454
488
|
} else {
|
|
455
489
|
const responseWithData: GraphQLResponseWithData =
|
|
456
|
-
|
|
490
|
+
response as $FlowFixMe;
|
|
457
491
|
results.push(responseWithData);
|
|
458
492
|
}
|
|
459
493
|
});
|
|
@@ -465,7 +499,7 @@ class Executor<TMutation: MutationParameters> {
|
|
|
465
499
|
* response has been handled
|
|
466
500
|
*/
|
|
467
501
|
_handleOptimisticResponses(
|
|
468
|
-
responses:
|
|
502
|
+
responses: ReadonlyArray<GraphQLResponseWithData>,
|
|
469
503
|
): boolean {
|
|
470
504
|
if (responses.length > 1) {
|
|
471
505
|
if (
|
|
@@ -500,6 +534,39 @@ class Executor<TMutation: MutationParameters> {
|
|
|
500
534
|
return false;
|
|
501
535
|
}
|
|
502
536
|
|
|
537
|
+
_handlePreNormalizedPayload(payload: RelayResponsePayload): void {
|
|
538
|
+
// NOTE: This path intentionally skips _maybeCompleteSubscriptionOperationTracking
|
|
539
|
+
// and the execute.next.start/end log events. Pre-normalized payloads come from
|
|
540
|
+
// the network-normalization path (NormalizationEngine via executeWithNetwork),
|
|
541
|
+
// which is used only for live exec-time-resolver queries. Those queries never
|
|
542
|
+
// complete from the consumer's perspective — exec-time resolvers re-emit on
|
|
543
|
+
// updates indefinitely — so completion tracking would never fire and is not
|
|
544
|
+
// needed.
|
|
545
|
+
if (this._state === 'completed') {
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
this._seenActors.clear();
|
|
549
|
+
if (this._optimisticUpdates !== null) {
|
|
550
|
+
this._optimisticUpdates.forEach(update =>
|
|
551
|
+
this._getPublishQueueAndSaveActor().revertUpdate(update),
|
|
552
|
+
);
|
|
553
|
+
this._optimisticUpdates = null;
|
|
554
|
+
}
|
|
555
|
+
this._getPublishQueueAndSaveActor().commitPayload(
|
|
556
|
+
this._operation,
|
|
557
|
+
payload,
|
|
558
|
+
payload.storeUpdater ?? this._updater,
|
|
559
|
+
);
|
|
560
|
+
if (payload.isFinal) {
|
|
561
|
+
this._state = 'loading_final';
|
|
562
|
+
} else if (this._state === 'started') {
|
|
563
|
+
this._state = 'loading_incremental';
|
|
564
|
+
}
|
|
565
|
+
const updatedOwners = this._runPublishQueue(this._operation);
|
|
566
|
+
this._updateActiveState();
|
|
567
|
+
this._updateOperationTracker(updatedOwners);
|
|
568
|
+
}
|
|
569
|
+
|
|
503
570
|
_handleNext(response: GraphQLResponse): void {
|
|
504
571
|
if (this._state === 'completed') {
|
|
505
572
|
return;
|
|
@@ -511,12 +578,38 @@ class Executor<TMutation: MutationParameters> {
|
|
|
511
578
|
|
|
512
579
|
if (responsesWithData.length === 0) {
|
|
513
580
|
// no results with data, nothing to process
|
|
514
|
-
// this can occur with extensions-only payloads
|
|
581
|
+
// this can occur with extensions-only payloads, or exec time resolver
|
|
582
|
+
// responses
|
|
515
583
|
const isFinal = responses.some(x => x.extensions?.is_final === true);
|
|
516
584
|
if (isFinal) {
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
585
|
+
if (
|
|
586
|
+
this._useExecTimeResolvers &&
|
|
587
|
+
this._state !== 'loading_final' &&
|
|
588
|
+
responses.some(x => x.extensions?.is_normalized === true)
|
|
589
|
+
) {
|
|
590
|
+
// An exec time resolver query can flush an empty response, if the
|
|
591
|
+
// same response has been included in other queries. Check if we need
|
|
592
|
+
// to mark the request as final
|
|
593
|
+
this._execTimeResolverResponseComplete = true;
|
|
594
|
+
if (
|
|
595
|
+
!this._isClientQuery &&
|
|
596
|
+
responses.some(x => x.extensions?.is_client_only === true)
|
|
597
|
+
) {
|
|
598
|
+
this._isClientQuery = true;
|
|
599
|
+
}
|
|
600
|
+
// Need to update the active state to mark the query as inactive,
|
|
601
|
+
// incase server payloads have completed
|
|
602
|
+
if (this._isClientQuery) {
|
|
603
|
+
// If it is a client query, there is no server response to set the
|
|
604
|
+
// final state, so we need to set it here
|
|
605
|
+
this._state = 'loading_final';
|
|
606
|
+
}
|
|
607
|
+
this._updateActiveState();
|
|
608
|
+
} else {
|
|
609
|
+
this._state = 'loading_final';
|
|
610
|
+
this._updateActiveState();
|
|
611
|
+
this._incrementalPayloadsPending = false;
|
|
612
|
+
}
|
|
520
613
|
}
|
|
521
614
|
this._sink.next(response);
|
|
522
615
|
return;
|
|
@@ -547,13 +640,13 @@ class Executor<TMutation: MutationParameters> {
|
|
|
547
640
|
if (this._isSubscriptionOperation) {
|
|
548
641
|
const nextID = generateUniqueClientID();
|
|
549
642
|
this._operation = {
|
|
550
|
-
request: this._operation.request,
|
|
551
643
|
fragment: createReaderSelector(
|
|
552
644
|
this._operation.fragment.node,
|
|
553
645
|
nextID,
|
|
554
646
|
this._operation.fragment.variables,
|
|
555
647
|
this._operation.fragment.owner,
|
|
556
648
|
),
|
|
649
|
+
request: this._operation.request,
|
|
557
650
|
root: createNormalizationSelector(
|
|
558
651
|
this._operation.root.node,
|
|
559
652
|
nextID,
|
|
@@ -570,10 +663,13 @@ class Executor<TMutation: MutationParameters> {
|
|
|
570
663
|
const payloadFollowups = [];
|
|
571
664
|
for (let i = 0; i < normalizedResponses.length; i++) {
|
|
572
665
|
const response = normalizedResponses[i];
|
|
573
|
-
const source = new RelayRecordSource(
|
|
574
|
-
response.data as $FlowExpectedError,
|
|
575
|
-
);
|
|
666
|
+
const source = new RelayRecordSource(response.data as $FlowFixMe);
|
|
576
667
|
const isFinal = response.extensions?.is_final === true;
|
|
668
|
+
if (response.extensions?.is_client_only === true) {
|
|
669
|
+
// For a mixed server and client query, if the network request is
|
|
670
|
+
// skipped, need to treat it as a client query
|
|
671
|
+
this._isClientQuery = true;
|
|
672
|
+
}
|
|
577
673
|
const payload: RelayResponsePayload = {
|
|
578
674
|
errors: [],
|
|
579
675
|
fieldPayloads: [],
|
|
@@ -592,6 +688,11 @@ class Executor<TMutation: MutationParameters> {
|
|
|
592
688
|
if (isFinal) {
|
|
593
689
|
// Need to update the active state to mark the query as inactive,
|
|
594
690
|
// incase server payloads have completed
|
|
691
|
+
if (this._isClientQuery) {
|
|
692
|
+
// If it is a client query, there is no server response to set the
|
|
693
|
+
// final state, so we need to set it here
|
|
694
|
+
this._state = 'loading_final';
|
|
695
|
+
}
|
|
595
696
|
this._updateActiveState();
|
|
596
697
|
}
|
|
597
698
|
}
|
|
@@ -657,6 +758,7 @@ class Executor<TMutation: MutationParameters> {
|
|
|
657
758
|
ROOT_TYPE,
|
|
658
759
|
{
|
|
659
760
|
actorIdentifier: this._actorIdentifier,
|
|
761
|
+
deferDeduplicatedFields: false,
|
|
660
762
|
getDataID: this._getDataID,
|
|
661
763
|
log: this._log,
|
|
662
764
|
path: [],
|
|
@@ -678,12 +780,12 @@ class Executor<TMutation: MutationParameters> {
|
|
|
678
780
|
payload: {
|
|
679
781
|
errors: null,
|
|
680
782
|
fieldPayloads: null,
|
|
681
|
-
incrementalPlaceholders: null,
|
|
682
783
|
followupPayloads: null,
|
|
683
|
-
|
|
784
|
+
incrementalPlaceholders: null,
|
|
684
785
|
isFinal: false,
|
|
786
|
+
source: RelayRecordSource.create(),
|
|
685
787
|
},
|
|
686
|
-
updater
|
|
788
|
+
updater,
|
|
687
789
|
});
|
|
688
790
|
}
|
|
689
791
|
this._optimisticUpdates = optimisticUpdates;
|
|
@@ -726,7 +828,7 @@ class Executor<TMutation: MutationParameters> {
|
|
|
726
828
|
);
|
|
727
829
|
break;
|
|
728
830
|
default:
|
|
729
|
-
|
|
831
|
+
followupPayload as empty;
|
|
730
832
|
invariant(
|
|
731
833
|
false,
|
|
732
834
|
'OperationExecutor: Unexpected followup kind `%s`. when processing optimistic updates.',
|
|
@@ -775,11 +877,12 @@ class Executor<TMutation: MutationParameters> {
|
|
|
775
877
|
followupPayload.typeName,
|
|
776
878
|
{
|
|
777
879
|
actorIdentifier: this._actorIdentifier,
|
|
880
|
+
deferDeduplicatedFields: false,
|
|
778
881
|
getDataID: this._getDataID,
|
|
779
882
|
log: this._log,
|
|
780
883
|
path: followupPayload.path,
|
|
781
|
-
treatMissingFieldsAsNull: this._treatMissingFieldsAsNull,
|
|
782
884
|
shouldProcessClientComponents: this._shouldProcessClientComponents,
|
|
885
|
+
treatMissingFieldsAsNull: this._treatMissingFieldsAsNull,
|
|
783
886
|
},
|
|
784
887
|
this._useExecTimeResolvers,
|
|
785
888
|
);
|
|
@@ -788,7 +891,7 @@ class Executor<TMutation: MutationParameters> {
|
|
|
788
891
|
_processOptimisticModuleImport(
|
|
789
892
|
normalizationRootNode: NormalizationRootNode,
|
|
790
893
|
moduleImportPayload: ModuleImportPayload,
|
|
791
|
-
):
|
|
894
|
+
): ReadonlyArray<OptimisticUpdate<TMutation>> {
|
|
792
895
|
const operation = getOperation(normalizationRootNode);
|
|
793
896
|
const optimisticUpdates: Array<OptimisticUpdate<TMutation>> = [];
|
|
794
897
|
const modulePayload = this._normalizeFollowupPayload(
|
|
@@ -836,8 +939,8 @@ class Executor<TMutation: MutationParameters> {
|
|
|
836
939
|
}
|
|
837
940
|
|
|
838
941
|
_processResponses(
|
|
839
|
-
responses:
|
|
840
|
-
):
|
|
942
|
+
responses: ReadonlyArray<GraphQLResponseWithData>,
|
|
943
|
+
): ReadonlyArray<RelayResponsePayload> {
|
|
841
944
|
this._log({
|
|
842
945
|
name: 'execute.normalize.start',
|
|
843
946
|
operation: this._operation,
|
|
@@ -859,11 +962,12 @@ class Executor<TMutation: MutationParameters> {
|
|
|
859
962
|
ROOT_TYPE,
|
|
860
963
|
{
|
|
861
964
|
actorIdentifier: this._actorIdentifier,
|
|
965
|
+
deferDeduplicatedFields: false,
|
|
862
966
|
getDataID: this._getDataID,
|
|
863
967
|
log: this._log,
|
|
864
968
|
path: [],
|
|
865
|
-
treatMissingFieldsAsNull: this._treatMissingFieldsAsNull,
|
|
866
969
|
shouldProcessClientComponents: this._shouldProcessClientComponents,
|
|
970
|
+
treatMissingFieldsAsNull: this._treatMissingFieldsAsNull,
|
|
867
971
|
},
|
|
868
972
|
this._useExecTimeResolvers,
|
|
869
973
|
);
|
|
@@ -885,7 +989,7 @@ class Executor<TMutation: MutationParameters> {
|
|
|
885
989
|
* and @stream directives.
|
|
886
990
|
*/
|
|
887
991
|
_processPayloadFollowups(
|
|
888
|
-
payloads:
|
|
992
|
+
payloads: ReadonlyArray<RelayResponsePayload>,
|
|
889
993
|
): void {
|
|
890
994
|
if (this._state === 'completed') {
|
|
891
995
|
return;
|
|
@@ -1017,6 +1121,7 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1017
1121
|
RelayObservable.create<empty>(sink => {
|
|
1018
1122
|
let cancellationToken;
|
|
1019
1123
|
const subscription = networkObservable.subscribe({
|
|
1124
|
+
error: sink.error,
|
|
1020
1125
|
next: (loadedNode: ?NormalizationRootNode) => {
|
|
1021
1126
|
if (loadedNode != null) {
|
|
1022
1127
|
const publishModuleImportPayload = () => {
|
|
@@ -1032,7 +1137,7 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1032
1137
|
// OK: always have to run after an async module import resolves
|
|
1033
1138
|
if (shouldScheduleAsyncStoreUpdate) {
|
|
1034
1139
|
this._scheduleAsyncStoreUpdate(
|
|
1035
|
-
// $FlowFixMe[incompatible-
|
|
1140
|
+
// $FlowFixMe[incompatible-type] `shouldScheduleAsyncStoreUpdate` check should cover `null` case
|
|
1036
1141
|
batchAsyncModuleUpdatesFN,
|
|
1037
1142
|
sink.complete,
|
|
1038
1143
|
);
|
|
@@ -1042,10 +1147,10 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1042
1147
|
}
|
|
1043
1148
|
});
|
|
1044
1149
|
this._log({
|
|
1045
|
-
|
|
1150
|
+
duration,
|
|
1046
1151
|
executeId: this._executeId,
|
|
1152
|
+
name: 'execute.async.module',
|
|
1047
1153
|
operationName: operation.name,
|
|
1048
|
-
duration,
|
|
1049
1154
|
});
|
|
1050
1155
|
if (!shouldScheduleAsyncStoreUpdate) {
|
|
1051
1156
|
sink.complete();
|
|
@@ -1066,7 +1171,6 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1066
1171
|
sink.complete();
|
|
1067
1172
|
}
|
|
1068
1173
|
},
|
|
1069
|
-
error: sink.error,
|
|
1070
1174
|
});
|
|
1071
1175
|
return () => {
|
|
1072
1176
|
subscription.unsubscribe();
|
|
@@ -1094,7 +1198,7 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1094
1198
|
);
|
|
1095
1199
|
break;
|
|
1096
1200
|
default:
|
|
1097
|
-
|
|
1201
|
+
followupPayload as empty;
|
|
1098
1202
|
invariant(
|
|
1099
1203
|
false,
|
|
1100
1204
|
'OperationExecutor: Unexpected followup kind `%s`.',
|
|
@@ -1171,7 +1275,7 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1171
1275
|
} else if (placeholder.kind === 'defer') {
|
|
1172
1276
|
parentID = placeholder.selector.dataID;
|
|
1173
1277
|
} else {
|
|
1174
|
-
|
|
1278
|
+
placeholder as empty;
|
|
1175
1279
|
invariant(
|
|
1176
1280
|
false,
|
|
1177
1281
|
'OperationExecutor: Unsupported incremental placeholder kind `%s`.',
|
|
@@ -1224,8 +1328,8 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1224
1328
|
nextParentPayloads = parentPayloads;
|
|
1225
1329
|
}
|
|
1226
1330
|
this._source.set(parentID, {
|
|
1227
|
-
record: nextParentRecord,
|
|
1228
1331
|
fieldPayloads: nextParentPayloads,
|
|
1332
|
+
record: nextParentRecord,
|
|
1229
1333
|
});
|
|
1230
1334
|
|
|
1231
1335
|
// If there were any queued responses, process them now that placeholders
|
|
@@ -1243,8 +1347,8 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1243
1347
|
* metadata.
|
|
1244
1348
|
*/
|
|
1245
1349
|
_processIncrementalResponses(
|
|
1246
|
-
incrementalResponses:
|
|
1247
|
-
):
|
|
1350
|
+
incrementalResponses: ReadonlyArray<IncrementalGraphQLResponse>,
|
|
1351
|
+
): ReadonlyArray<RelayResponsePayload> {
|
|
1248
1352
|
const relayPayloads = [];
|
|
1249
1353
|
incrementalResponses.forEach(incrementalResponse => {
|
|
1250
1354
|
const {label, path, response} = incrementalResponse;
|
|
@@ -1311,7 +1415,7 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1311
1415
|
|
|
1312
1416
|
_processDeferResponse(
|
|
1313
1417
|
label: string,
|
|
1314
|
-
path:
|
|
1418
|
+
path: ReadonlyArray<unknown>,
|
|
1315
1419
|
placeholder: DeferPlaceholder,
|
|
1316
1420
|
response: GraphQLResponseWithData,
|
|
1317
1421
|
): RelayResponsePayload {
|
|
@@ -1325,11 +1429,12 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1325
1429
|
placeholder.typeName,
|
|
1326
1430
|
{
|
|
1327
1431
|
actorIdentifier: this._actorIdentifier,
|
|
1432
|
+
deferDeduplicatedFields: this._deferDeduplicatedFields,
|
|
1328
1433
|
getDataID: this._getDataID,
|
|
1329
1434
|
log: this._log,
|
|
1330
1435
|
path: placeholder.path,
|
|
1331
|
-
treatMissingFieldsAsNull: this._treatMissingFieldsAsNull,
|
|
1332
1436
|
shouldProcessClientComponents: this._shouldProcessClientComponents,
|
|
1437
|
+
treatMissingFieldsAsNull: this._treatMissingFieldsAsNull,
|
|
1333
1438
|
},
|
|
1334
1439
|
this._useExecTimeResolvers,
|
|
1335
1440
|
);
|
|
@@ -1352,10 +1457,10 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1352
1457
|
const handleFieldsRelayPayload = {
|
|
1353
1458
|
errors: null,
|
|
1354
1459
|
fieldPayloads,
|
|
1355
|
-
incrementalPlaceholders: null,
|
|
1356
1460
|
followupPayloads: null,
|
|
1357
|
-
|
|
1461
|
+
incrementalPlaceholders: null,
|
|
1358
1462
|
isFinal: response.extensions?.is_final === true,
|
|
1463
|
+
source: RelayRecordSource.create(),
|
|
1359
1464
|
};
|
|
1360
1465
|
this._getPublishQueueAndSaveActor().commitPayload(
|
|
1361
1466
|
this._operation,
|
|
@@ -1372,7 +1477,7 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1372
1477
|
*/
|
|
1373
1478
|
_processStreamResponse(
|
|
1374
1479
|
label: string,
|
|
1375
|
-
path:
|
|
1480
|
+
path: ReadonlyArray<unknown>,
|
|
1376
1481
|
placeholder: StreamPlaceholder,
|
|
1377
1482
|
response: GraphQLResponseWithData,
|
|
1378
1483
|
): RelayResponsePayload {
|
|
@@ -1442,10 +1547,10 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1442
1547
|
const handleFieldsRelayPayload = {
|
|
1443
1548
|
errors: null,
|
|
1444
1549
|
fieldPayloads,
|
|
1445
|
-
incrementalPlaceholders: null,
|
|
1446
1550
|
followupPayloads: null,
|
|
1447
|
-
|
|
1551
|
+
incrementalPlaceholders: null,
|
|
1448
1552
|
isFinal: false,
|
|
1553
|
+
source: RelayRecordSource.create(),
|
|
1449
1554
|
};
|
|
1450
1555
|
this._getPublishQueueAndSaveActor().commitPayload(
|
|
1451
1556
|
this._operation,
|
|
@@ -1462,8 +1567,8 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1462
1567
|
parentID: DataID,
|
|
1463
1568
|
field: NormalizationLinkedField,
|
|
1464
1569
|
variables: Variables,
|
|
1465
|
-
path:
|
|
1466
|
-
normalizationPath:
|
|
1570
|
+
path: ReadonlyArray<unknown>,
|
|
1571
|
+
normalizationPath: ReadonlyArray<string>,
|
|
1467
1572
|
): {
|
|
1468
1573
|
fieldPayloads: Array<HandleFieldPayload>,
|
|
1469
1574
|
itemID: DataID,
|
|
@@ -1549,8 +1654,8 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1549
1654
|
nextIDs[itemIndex] = itemID;
|
|
1550
1655
|
RelayModernRecord.setLinkedRecordIDs(nextParentRecord, storageKey, nextIDs);
|
|
1551
1656
|
this._source.set(parentID, {
|
|
1552
|
-
record: nextParentRecord,
|
|
1553
1657
|
fieldPayloads,
|
|
1658
|
+
record: nextParentRecord,
|
|
1554
1659
|
});
|
|
1555
1660
|
const relayPayload = this._normalizeResponse(
|
|
1556
1661
|
response,
|
|
@@ -1558,11 +1663,12 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1558
1663
|
typeName,
|
|
1559
1664
|
{
|
|
1560
1665
|
actorIdentifier: this._actorIdentifier,
|
|
1666
|
+
deferDeduplicatedFields: false,
|
|
1561
1667
|
getDataID: this._getDataID,
|
|
1562
1668
|
log: this._log,
|
|
1563
1669
|
path: [...normalizationPath, responseKey, String(itemIndex)],
|
|
1564
|
-
treatMissingFieldsAsNull: this._treatMissingFieldsAsNull,
|
|
1565
1670
|
shouldProcessClientComponents: this._shouldProcessClientComponents,
|
|
1671
|
+
treatMissingFieldsAsNull: this._treatMissingFieldsAsNull,
|
|
1566
1672
|
},
|
|
1567
1673
|
this._useExecTimeResolvers,
|
|
1568
1674
|
);
|
|
@@ -1596,7 +1702,7 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1596
1702
|
}
|
|
1597
1703
|
|
|
1598
1704
|
_updateOperationTracker(
|
|
1599
|
-
updatedOwners:
|
|
1705
|
+
updatedOwners: ?ReadonlyArray<RequestDescriptor>,
|
|
1600
1706
|
): void {
|
|
1601
1707
|
if (updatedOwners != null && updatedOwners.length > 0) {
|
|
1602
1708
|
this._operationTracker.update(
|
|
@@ -1615,7 +1721,7 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1615
1721
|
return this._getPublishQueue(this._actorIdentifier);
|
|
1616
1722
|
}
|
|
1617
1723
|
|
|
1618
|
-
_getActorsToVisit():
|
|
1724
|
+
_getActorsToVisit(): ReadonlySet<ActorIdentifier> {
|
|
1619
1725
|
if (this._seenActors.size === 0) {
|
|
1620
1726
|
return new Set([this._actorIdentifier]);
|
|
1621
1727
|
} else {
|
|
@@ -1625,7 +1731,7 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1625
1731
|
|
|
1626
1732
|
_runPublishQueue(
|
|
1627
1733
|
operation?: OperationDescriptor,
|
|
1628
|
-
):
|
|
1734
|
+
): ReadonlyArray<RequestDescriptor> {
|
|
1629
1735
|
const updatedOwners = new Set<RequestDescriptor>();
|
|
1630
1736
|
for (const actorIdentifier of this._getActorsToVisit()) {
|
|
1631
1737
|
const owners = this._getPublishQueue(actorIdentifier).run(operation);
|
|
@@ -1664,11 +1770,11 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1664
1770
|
}
|
|
1665
1771
|
|
|
1666
1772
|
function partitionGraphQLResponses(
|
|
1667
|
-
responses:
|
|
1773
|
+
responses: ReadonlyArray<GraphQLResponseWithData>,
|
|
1668
1774
|
): [
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1775
|
+
ReadonlyArray<GraphQLResponseWithData>,
|
|
1776
|
+
ReadonlyArray<IncrementalGraphQLResponse>,
|
|
1777
|
+
ReadonlyArray<GraphQLResponseWithData>,
|
|
1672
1778
|
] {
|
|
1673
1779
|
const nonIncrementalResponses: Array<GraphQLResponseWithData> = [];
|
|
1674
1780
|
const incrementalResponses: Array<IncrementalGraphQLResponse> = [];
|
|
@@ -1699,7 +1805,7 @@ function partitionGraphQLResponses(
|
|
|
1699
1805
|
return [nonIncrementalResponses, incrementalResponses, normalizedResponses];
|
|
1700
1806
|
}
|
|
1701
1807
|
|
|
1702
|
-
function stableStringify(value:
|
|
1808
|
+
function stableStringify(value: unknown): string {
|
|
1703
1809
|
return JSON.stringify(stableCopy(value)) ?? ''; // null-check for flow
|
|
1704
1810
|
}
|
|
1705
1811
|
|