relay-runtime 20.1.0 → 21.0.0
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.js +1 -1
- package/experimental.js.flow +8 -8
- package/handlers/connection/ConnectionHandler.js.flow +5 -5
- package/handlers/connection/ConnectionInterface.js.flow +1 -1
- 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 +113 -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 +82 -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 +213 -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 +66 -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.js.flow +2 -2
- package/multi-actor-environment/ActorSpecificEnvironment.js.flow +7 -7
- package/multi-actor-environment/ActorUtils.js.flow +1 -1
- package/multi-actor-environment/MultiActorEnvironment.js.flow +12 -8
- package/multi-actor-environment/MultiActorEnvironmentTypes.js.flow +3 -3
- 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.js.flow +2 -2
- package/mutations/commitMutation.js.flow +20 -16
- 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/RelayNetworkTypes.js.flow +4 -4
- package/network/RelayObservable.js.flow +16 -14
- package/network/RelayQueryResponseCache.js.flow +3 -3
- package/network/wrapNetworkWithLogObserver.js.flow +1 -1
- package/package.json +2 -1
- package/query/GraphQLTag.js.flow +22 -10
- package/query/fetchQuery.js.flow +23 -10
- package/query/fetchQuery_DEPRECATED.js.flow +1 -1
- package/store/DataChecker.js.flow +43 -9
- package/store/NormalizationEngine.js.flow +779 -0
- package/store/OperationExecutor.js.flow +173 -70
- 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.js.flow +41 -26
- package/store/RelayModernFragmentSpecResolver.js.flow +1 -1
- package/store/RelayModernOperationDescriptor.js.flow +1 -1
- package/store/RelayModernRecord.js.flow +46 -22
- package/store/RelayModernSelector.js.flow +21 -21
- package/store/RelayModernStore.js.flow +219 -58
- package/store/RelayOperationTracker.js.flow +2 -2
- package/store/RelayOptimisticRecordSource.js.flow +2 -2
- package/store/RelayPublishQueue.js.flow +21 -12
- package/store/RelayReader.js.flow +130 -58
- package/store/RelayRecordSource.js.flow +10 -0
- package/store/RelayRecordState.js.flow +1 -1
- package/store/RelayReferenceMarker.js.flow +5 -4
- package/store/RelayResponseNormalizer.js.flow +130 -54
- package/store/RelayStoreSubscriptions.js.flow +52 -8
- package/store/RelayStoreTypes.js.flow +153 -64
- package/store/RelayStoreUtils.js.flow +15 -7
- package/store/ResolverCache.js.flow +2 -2
- package/store/ResolverFragments.js.flow +12 -12
- package/store/StoreInspector.js.flow +6 -7
- package/store/cloneRelayHandleSourceField.js.flow +1 -1
- package/store/cloneRelayScalarHandleSourceField.js.flow +1 -1
- package/store/createRelayContext.js.flow +1 -1
- package/store/createRelayLoggingContext.js.flow +4 -4
- package/store/defaultGetDataID.js.flow +2 -2
- 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.js.flow +8 -5
- package/store/observeFragmentExperimental.js.flow +49 -20
- package/store/observeQueryExperimental.js.flow +5 -5
- package/store/readInlineData.js.flow +4 -4
- package/store/waitForFragmentExperimental.js.flow +3 -3
- package/subscription/requestSubscription.js.flow +7 -7
- package/util/NormalizationNode.js.flow +34 -32
- package/util/ReaderNode.js.flow +32 -30
- package/util/RelayConcreteNode.js.flow +5 -5
- package/util/RelayError.js.flow +4 -1
- package/util/RelayFeatureFlags.js.flow +21 -1
- package/util/RelayProfiler.js.flow +1 -1
- package/util/RelayReplaySubject.js.flow +3 -3
- package/util/RelayRuntimeTypes.js.flow +11 -11
- package/util/createPayloadFor3DField.js.flow +9 -5
- package/util/deepFreeze.js.flow +2 -2
- package/util/getFragmentIdentifier.js.flow +1 -1
- package/util/getPaginationMetadata.js.flow +1 -1
- package/util/getPaginationVariables.js.flow +1 -1
- package/util/getPendingOperationsForFragment.js.flow +2 -2
- package/util/getRefetchMetadata.js.flow +6 -5
- package/util/getValueAtPath.js.flow +3 -3
- package/util/handlePotentialSnapshotErrors.js.flow +5 -5
- package/util/isEmptyObject.js.flow +1 -1
- package/util/isPromise.js.flow +2 -2
- package/util/isScalarAndEqual.js.flow +1 -1
- package/util/recycleNodesInto.js.flow +2 -2
- package/util/registerEnvironmentWithDevTools.js.flow +1 -1
- package/util/shallowFreeze.js.flow +1 -1
- package/util/stableCopy.js.flow +5 -5
- package/util/withProvidedVariables.js.flow +14 -10
|
@@ -71,7 +71,12 @@ const {ROOT_TYPE, TYPENAME_KEY, getStorageKey} = require('./RelayStoreUtils');
|
|
|
71
71
|
const invariant = require('invariant');
|
|
72
72
|
const warning = require('warning');
|
|
73
73
|
|
|
74
|
-
|
|
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> = {
|
|
75
80
|
+actorIdentifier: ActorIdentifier,
|
|
76
81
|
+getDataID: GetDataID,
|
|
77
82
|
+getPublishQueue: (actorIdentifier: ActorIdentifier) => PublishQueue,
|
|
@@ -86,8 +91,9 @@ export type ExecuteConfig<TMutation: MutationParameters> = {
|
|
|
86
91
|
+scheduler?: ?TaskScheduler,
|
|
87
92
|
+shouldProcessClientComponents?: ?boolean,
|
|
88
93
|
+sink: Sink<GraphQLResponse>,
|
|
89
|
-
+source: RelayObservable<
|
|
94
|
+
+source: RelayObservable<NetworkResponse>,
|
|
90
95
|
+treatMissingFieldsAsNull: boolean,
|
|
96
|
+
+deferDeduplicatedFields: boolean,
|
|
91
97
|
+updater?: ?SelectorStoreUpdater<TMutation['response']>,
|
|
92
98
|
+log: LogFunction,
|
|
93
99
|
};
|
|
@@ -108,11 +114,11 @@ type IncrementalResults =
|
|
|
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;
|
|
@@ -160,6 +167,7 @@ class Executor<TMutation: MutationParameters> {
|
|
|
160
167
|
+_seenActors: Set<ActorIdentifier>;
|
|
161
168
|
_normalizeResponse: NormalizeResponseFunction;
|
|
162
169
|
_execTimeResolverResponseComplete: boolean;
|
|
170
|
+
_isClientQuery: boolean;
|
|
163
171
|
|
|
164
172
|
constructor({
|
|
165
173
|
actorIdentifier,
|
|
@@ -177,6 +185,7 @@ class Executor<TMutation: MutationParameters> {
|
|
|
177
185
|
sink,
|
|
178
186
|
source,
|
|
179
187
|
treatMissingFieldsAsNull,
|
|
188
|
+
deferDeduplicatedFields,
|
|
180
189
|
updater,
|
|
181
190
|
log,
|
|
182
191
|
normalizeResponse,
|
|
@@ -184,6 +193,7 @@ class Executor<TMutation: MutationParameters> {
|
|
|
184
193
|
this._actorIdentifier = actorIdentifier;
|
|
185
194
|
this._getDataID = getDataID;
|
|
186
195
|
this._treatMissingFieldsAsNull = treatMissingFieldsAsNull;
|
|
196
|
+
this._deferDeduplicatedFields = deferDeduplicatedFields;
|
|
187
197
|
this._incrementalPayloadsPending = false;
|
|
188
198
|
this._incrementalResults = new Map();
|
|
189
199
|
this._log = log;
|
|
@@ -218,6 +228,9 @@ class Executor<TMutation: MutationParameters> {
|
|
|
218
228
|
this._seenActors = new Set();
|
|
219
229
|
this._completeFns = [];
|
|
220
230
|
this._normalizeResponse = normalizeResponse;
|
|
231
|
+
this._isClientQuery =
|
|
232
|
+
this._operation.request.node.params.id == null &&
|
|
233
|
+
this._operation.request.node.params.text == null;
|
|
221
234
|
|
|
222
235
|
const id = this._nextSubscriptionId++;
|
|
223
236
|
|
|
@@ -246,17 +259,17 @@ class Executor<TMutation: MutationParameters> {
|
|
|
246
259
|
start: subscription => {
|
|
247
260
|
this._start(id, subscription);
|
|
248
261
|
this._log({
|
|
249
|
-
|
|
262
|
+
cacheConfig: this._operation.request.cacheConfig ?? {},
|
|
250
263
|
executeId: this._executeId,
|
|
264
|
+
name: 'execute.start',
|
|
251
265
|
params: this._operation.request.node.params,
|
|
252
266
|
variables: this._operation.request.variables,
|
|
253
|
-
cacheConfig: this._operation.request.cacheConfig ?? {},
|
|
254
267
|
});
|
|
255
268
|
},
|
|
256
269
|
unsubscribe: () => {
|
|
257
270
|
this._log({
|
|
258
|
-
name: 'execute.unsubscribe',
|
|
259
271
|
executeId: this._executeId,
|
|
272
|
+
name: 'execute.unsubscribe',
|
|
260
273
|
});
|
|
261
274
|
},
|
|
262
275
|
});
|
|
@@ -331,7 +344,7 @@ class Executor<TMutation: MutationParameters> {
|
|
|
331
344
|
break;
|
|
332
345
|
}
|
|
333
346
|
default:
|
|
334
|
-
|
|
347
|
+
this._state as empty;
|
|
335
348
|
invariant(false, 'OperationExecutor: invalid executor state.');
|
|
336
349
|
}
|
|
337
350
|
this._operationExecutions.set(
|
|
@@ -370,8 +383,8 @@ class Executor<TMutation: MutationParameters> {
|
|
|
370
383
|
this.cancel();
|
|
371
384
|
this._sink.complete();
|
|
372
385
|
this._log({
|
|
373
|
-
name: 'execute.complete',
|
|
374
386
|
executeId: this._executeId,
|
|
387
|
+
name: 'execute.complete',
|
|
375
388
|
});
|
|
376
389
|
}
|
|
377
390
|
}
|
|
@@ -380,9 +393,9 @@ class Executor<TMutation: MutationParameters> {
|
|
|
380
393
|
this.cancel();
|
|
381
394
|
this._sink.error(error);
|
|
382
395
|
this._log({
|
|
383
|
-
name: 'execute.error',
|
|
384
|
-
executeId: this._executeId,
|
|
385
396
|
error,
|
|
397
|
+
executeId: this._executeId,
|
|
398
|
+
name: 'execute.error',
|
|
386
399
|
});
|
|
387
400
|
}
|
|
388
401
|
|
|
@@ -391,30 +404,48 @@ class Executor<TMutation: MutationParameters> {
|
|
|
391
404
|
this._updateActiveState();
|
|
392
405
|
}
|
|
393
406
|
|
|
394
|
-
// Handle a raw GraphQL response
|
|
395
|
-
|
|
407
|
+
// Handle a raw GraphQL response or a pre-normalized payload from the
|
|
408
|
+
// network layer. Pre-normalized payloads bypass the normal GraphQL pipeline.
|
|
409
|
+
_next(_id: number, response: NetworkResponse): void {
|
|
396
410
|
const priority = this._state === 'loading_incremental' ? 'low' : 'default';
|
|
397
411
|
this._schedule(() => {
|
|
412
|
+
// Pre-normalized payloads from the network layer have isPreNormalized
|
|
413
|
+
// set by NormalizationEngine. Route them to a dedicated handler that
|
|
414
|
+
// commits directly to the store, bypassing normalizeResponse().
|
|
415
|
+
if (
|
|
416
|
+
!Array.isArray(response) &&
|
|
417
|
+
// $FlowFixMe[prop-missing] isPreNormalized exists on RelayResponsePayload branch
|
|
418
|
+
response.isPreNormalized === true
|
|
419
|
+
) {
|
|
420
|
+
// $FlowFixMe[incompatible-type] narrowed by isPreNormalized check
|
|
421
|
+
this._handlePreNormalizedPayload(response);
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
// After the pre-normalized early return, response is a standard
|
|
425
|
+
// GraphQLResponse (Flow cannot narrow this automatically because
|
|
426
|
+
// isPreNormalized is optional, so we cast once here at the boundary).
|
|
427
|
+
// $FlowFixMe[incompatible-type] narrowed by isPreNormalized check above
|
|
428
|
+
const graphQLResponse: GraphQLResponse = response;
|
|
398
429
|
this._log({
|
|
399
|
-
name: 'execute.next.start',
|
|
400
430
|
executeId: this._executeId,
|
|
401
|
-
|
|
431
|
+
name: 'execute.next.start',
|
|
402
432
|
operation: this._operation,
|
|
433
|
+
response: graphQLResponse,
|
|
403
434
|
});
|
|
404
|
-
this._handleNext(
|
|
435
|
+
this._handleNext(graphQLResponse);
|
|
405
436
|
this._maybeCompleteSubscriptionOperationTracking();
|
|
406
437
|
this._log({
|
|
407
|
-
name: 'execute.next.end',
|
|
408
438
|
executeId: this._executeId,
|
|
409
|
-
|
|
439
|
+
name: 'execute.next.end',
|
|
410
440
|
operation: this._operation,
|
|
441
|
+
response: graphQLResponse,
|
|
411
442
|
});
|
|
412
443
|
}, priority);
|
|
413
444
|
}
|
|
414
445
|
|
|
415
446
|
_handleErrorResponse(
|
|
416
|
-
responses:
|
|
417
|
-
):
|
|
447
|
+
responses: ReadonlyArray<GraphQLSingularResponse>,
|
|
448
|
+
): ReadonlyArray<GraphQLResponseWithData> {
|
|
418
449
|
const results = [];
|
|
419
450
|
responses.forEach(response => {
|
|
420
451
|
if (
|
|
@@ -442,7 +473,7 @@ class Executor<TMutation: MutationParameters> {
|
|
|
442
473
|
messages +
|
|
443
474
|
'\n\nSee the error `source` property for more information.',
|
|
444
475
|
);
|
|
445
|
-
(error
|
|
476
|
+
(error as $FlowFixMe).source = {
|
|
446
477
|
errors,
|
|
447
478
|
operation: this._operation.request.node,
|
|
448
479
|
variables: this._operation.request.variables,
|
|
@@ -453,7 +484,7 @@ class Executor<TMutation: MutationParameters> {
|
|
|
453
484
|
throw error;
|
|
454
485
|
} else {
|
|
455
486
|
const responseWithData: GraphQLResponseWithData =
|
|
456
|
-
|
|
487
|
+
response as $FlowFixMe;
|
|
457
488
|
results.push(responseWithData);
|
|
458
489
|
}
|
|
459
490
|
});
|
|
@@ -465,7 +496,7 @@ class Executor<TMutation: MutationParameters> {
|
|
|
465
496
|
* response has been handled
|
|
466
497
|
*/
|
|
467
498
|
_handleOptimisticResponses(
|
|
468
|
-
responses:
|
|
499
|
+
responses: ReadonlyArray<GraphQLResponseWithData>,
|
|
469
500
|
): boolean {
|
|
470
501
|
if (responses.length > 1) {
|
|
471
502
|
if (
|
|
@@ -500,6 +531,39 @@ class Executor<TMutation: MutationParameters> {
|
|
|
500
531
|
return false;
|
|
501
532
|
}
|
|
502
533
|
|
|
534
|
+
_handlePreNormalizedPayload(payload: RelayResponsePayload): void {
|
|
535
|
+
// NOTE: This path intentionally skips _maybeCompleteSubscriptionOperationTracking
|
|
536
|
+
// and the execute.next.start/end log events. Pre-normalized payloads come from
|
|
537
|
+
// the network-normalization path (NormalizationEngine via executeWithNetwork),
|
|
538
|
+
// which is used only for live exec-time-resolver queries. Those queries never
|
|
539
|
+
// complete from the consumer's perspective — exec-time resolvers re-emit on
|
|
540
|
+
// updates indefinitely — so completion tracking would never fire and is not
|
|
541
|
+
// needed.
|
|
542
|
+
if (this._state === 'completed') {
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
this._seenActors.clear();
|
|
546
|
+
if (this._optimisticUpdates !== null) {
|
|
547
|
+
this._optimisticUpdates.forEach(update =>
|
|
548
|
+
this._getPublishQueueAndSaveActor().revertUpdate(update),
|
|
549
|
+
);
|
|
550
|
+
this._optimisticUpdates = null;
|
|
551
|
+
}
|
|
552
|
+
this._getPublishQueueAndSaveActor().commitPayload(
|
|
553
|
+
this._operation,
|
|
554
|
+
payload,
|
|
555
|
+
payload.storeUpdater ?? this._updater,
|
|
556
|
+
);
|
|
557
|
+
if (payload.isFinal) {
|
|
558
|
+
this._state = 'loading_final';
|
|
559
|
+
} else if (this._state === 'started') {
|
|
560
|
+
this._state = 'loading_incremental';
|
|
561
|
+
}
|
|
562
|
+
const updatedOwners = this._runPublishQueue(this._operation);
|
|
563
|
+
this._updateActiveState();
|
|
564
|
+
this._updateOperationTracker(updatedOwners);
|
|
565
|
+
}
|
|
566
|
+
|
|
503
567
|
_handleNext(response: GraphQLResponse): void {
|
|
504
568
|
if (this._state === 'completed') {
|
|
505
569
|
return;
|
|
@@ -511,12 +575,38 @@ class Executor<TMutation: MutationParameters> {
|
|
|
511
575
|
|
|
512
576
|
if (responsesWithData.length === 0) {
|
|
513
577
|
// no results with data, nothing to process
|
|
514
|
-
// this can occur with extensions-only payloads
|
|
578
|
+
// this can occur with extensions-only payloads, or exec time resolver
|
|
579
|
+
// responses
|
|
515
580
|
const isFinal = responses.some(x => x.extensions?.is_final === true);
|
|
516
581
|
if (isFinal) {
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
582
|
+
if (
|
|
583
|
+
this._useExecTimeResolvers &&
|
|
584
|
+
this._state !== 'loading_final' &&
|
|
585
|
+
responses.some(x => x.extensions?.is_normalized === true)
|
|
586
|
+
) {
|
|
587
|
+
// An exec time resolver query can flush an empty response, if the
|
|
588
|
+
// same response has been included in other queries. Check if we need
|
|
589
|
+
// to mark the request as final
|
|
590
|
+
this._execTimeResolverResponseComplete = true;
|
|
591
|
+
if (
|
|
592
|
+
!this._isClientQuery &&
|
|
593
|
+
responses.some(x => x.extensions?.is_client_only === true)
|
|
594
|
+
) {
|
|
595
|
+
this._isClientQuery = true;
|
|
596
|
+
}
|
|
597
|
+
// Need to update the active state to mark the query as inactive,
|
|
598
|
+
// incase server payloads have completed
|
|
599
|
+
if (this._isClientQuery) {
|
|
600
|
+
// If it is a client query, there is no server response to set the
|
|
601
|
+
// final state, so we need to set it here
|
|
602
|
+
this._state = 'loading_final';
|
|
603
|
+
}
|
|
604
|
+
this._updateActiveState();
|
|
605
|
+
} else {
|
|
606
|
+
this._state = 'loading_final';
|
|
607
|
+
this._updateActiveState();
|
|
608
|
+
this._incrementalPayloadsPending = false;
|
|
609
|
+
}
|
|
520
610
|
}
|
|
521
611
|
this._sink.next(response);
|
|
522
612
|
return;
|
|
@@ -547,13 +637,13 @@ class Executor<TMutation: MutationParameters> {
|
|
|
547
637
|
if (this._isSubscriptionOperation) {
|
|
548
638
|
const nextID = generateUniqueClientID();
|
|
549
639
|
this._operation = {
|
|
550
|
-
request: this._operation.request,
|
|
551
640
|
fragment: createReaderSelector(
|
|
552
641
|
this._operation.fragment.node,
|
|
553
642
|
nextID,
|
|
554
643
|
this._operation.fragment.variables,
|
|
555
644
|
this._operation.fragment.owner,
|
|
556
645
|
),
|
|
646
|
+
request: this._operation.request,
|
|
557
647
|
root: createNormalizationSelector(
|
|
558
648
|
this._operation.root.node,
|
|
559
649
|
nextID,
|
|
@@ -570,10 +660,13 @@ class Executor<TMutation: MutationParameters> {
|
|
|
570
660
|
const payloadFollowups = [];
|
|
571
661
|
for (let i = 0; i < normalizedResponses.length; i++) {
|
|
572
662
|
const response = normalizedResponses[i];
|
|
573
|
-
const source = new RelayRecordSource(
|
|
574
|
-
response.data as $FlowExpectedError,
|
|
575
|
-
);
|
|
663
|
+
const source = new RelayRecordSource(response.data as $FlowFixMe);
|
|
576
664
|
const isFinal = response.extensions?.is_final === true;
|
|
665
|
+
if (response.extensions?.is_client_only === true) {
|
|
666
|
+
// For a mixed server and client query, if the network request is
|
|
667
|
+
// skipped, need to treat it as a client query
|
|
668
|
+
this._isClientQuery = true;
|
|
669
|
+
}
|
|
577
670
|
const payload: RelayResponsePayload = {
|
|
578
671
|
errors: [],
|
|
579
672
|
fieldPayloads: [],
|
|
@@ -592,6 +685,11 @@ class Executor<TMutation: MutationParameters> {
|
|
|
592
685
|
if (isFinal) {
|
|
593
686
|
// Need to update the active state to mark the query as inactive,
|
|
594
687
|
// incase server payloads have completed
|
|
688
|
+
if (this._isClientQuery) {
|
|
689
|
+
// If it is a client query, there is no server response to set the
|
|
690
|
+
// final state, so we need to set it here
|
|
691
|
+
this._state = 'loading_final';
|
|
692
|
+
}
|
|
595
693
|
this._updateActiveState();
|
|
596
694
|
}
|
|
597
695
|
}
|
|
@@ -657,6 +755,7 @@ class Executor<TMutation: MutationParameters> {
|
|
|
657
755
|
ROOT_TYPE,
|
|
658
756
|
{
|
|
659
757
|
actorIdentifier: this._actorIdentifier,
|
|
758
|
+
deferDeduplicatedFields: false,
|
|
660
759
|
getDataID: this._getDataID,
|
|
661
760
|
log: this._log,
|
|
662
761
|
path: [],
|
|
@@ -678,12 +777,12 @@ class Executor<TMutation: MutationParameters> {
|
|
|
678
777
|
payload: {
|
|
679
778
|
errors: null,
|
|
680
779
|
fieldPayloads: null,
|
|
681
|
-
incrementalPlaceholders: null,
|
|
682
780
|
followupPayloads: null,
|
|
683
|
-
|
|
781
|
+
incrementalPlaceholders: null,
|
|
684
782
|
isFinal: false,
|
|
783
|
+
source: RelayRecordSource.create(),
|
|
685
784
|
},
|
|
686
|
-
updater
|
|
785
|
+
updater,
|
|
687
786
|
});
|
|
688
787
|
}
|
|
689
788
|
this._optimisticUpdates = optimisticUpdates;
|
|
@@ -726,7 +825,7 @@ class Executor<TMutation: MutationParameters> {
|
|
|
726
825
|
);
|
|
727
826
|
break;
|
|
728
827
|
default:
|
|
729
|
-
|
|
828
|
+
followupPayload as empty;
|
|
730
829
|
invariant(
|
|
731
830
|
false,
|
|
732
831
|
'OperationExecutor: Unexpected followup kind `%s`. when processing optimistic updates.',
|
|
@@ -775,11 +874,12 @@ class Executor<TMutation: MutationParameters> {
|
|
|
775
874
|
followupPayload.typeName,
|
|
776
875
|
{
|
|
777
876
|
actorIdentifier: this._actorIdentifier,
|
|
877
|
+
deferDeduplicatedFields: false,
|
|
778
878
|
getDataID: this._getDataID,
|
|
779
879
|
log: this._log,
|
|
780
880
|
path: followupPayload.path,
|
|
781
|
-
treatMissingFieldsAsNull: this._treatMissingFieldsAsNull,
|
|
782
881
|
shouldProcessClientComponents: this._shouldProcessClientComponents,
|
|
882
|
+
treatMissingFieldsAsNull: this._treatMissingFieldsAsNull,
|
|
783
883
|
},
|
|
784
884
|
this._useExecTimeResolvers,
|
|
785
885
|
);
|
|
@@ -788,7 +888,7 @@ class Executor<TMutation: MutationParameters> {
|
|
|
788
888
|
_processOptimisticModuleImport(
|
|
789
889
|
normalizationRootNode: NormalizationRootNode,
|
|
790
890
|
moduleImportPayload: ModuleImportPayload,
|
|
791
|
-
):
|
|
891
|
+
): ReadonlyArray<OptimisticUpdate<TMutation>> {
|
|
792
892
|
const operation = getOperation(normalizationRootNode);
|
|
793
893
|
const optimisticUpdates: Array<OptimisticUpdate<TMutation>> = [];
|
|
794
894
|
const modulePayload = this._normalizeFollowupPayload(
|
|
@@ -836,8 +936,8 @@ class Executor<TMutation: MutationParameters> {
|
|
|
836
936
|
}
|
|
837
937
|
|
|
838
938
|
_processResponses(
|
|
839
|
-
responses:
|
|
840
|
-
):
|
|
939
|
+
responses: ReadonlyArray<GraphQLResponseWithData>,
|
|
940
|
+
): ReadonlyArray<RelayResponsePayload> {
|
|
841
941
|
this._log({
|
|
842
942
|
name: 'execute.normalize.start',
|
|
843
943
|
operation: this._operation,
|
|
@@ -859,11 +959,12 @@ class Executor<TMutation: MutationParameters> {
|
|
|
859
959
|
ROOT_TYPE,
|
|
860
960
|
{
|
|
861
961
|
actorIdentifier: this._actorIdentifier,
|
|
962
|
+
deferDeduplicatedFields: false,
|
|
862
963
|
getDataID: this._getDataID,
|
|
863
964
|
log: this._log,
|
|
864
965
|
path: [],
|
|
865
|
-
treatMissingFieldsAsNull: this._treatMissingFieldsAsNull,
|
|
866
966
|
shouldProcessClientComponents: this._shouldProcessClientComponents,
|
|
967
|
+
treatMissingFieldsAsNull: this._treatMissingFieldsAsNull,
|
|
867
968
|
},
|
|
868
969
|
this._useExecTimeResolvers,
|
|
869
970
|
);
|
|
@@ -885,7 +986,7 @@ class Executor<TMutation: MutationParameters> {
|
|
|
885
986
|
* and @stream directives.
|
|
886
987
|
*/
|
|
887
988
|
_processPayloadFollowups(
|
|
888
|
-
payloads:
|
|
989
|
+
payloads: ReadonlyArray<RelayResponsePayload>,
|
|
889
990
|
): void {
|
|
890
991
|
if (this._state === 'completed') {
|
|
891
992
|
return;
|
|
@@ -1017,6 +1118,7 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1017
1118
|
RelayObservable.create<empty>(sink => {
|
|
1018
1119
|
let cancellationToken;
|
|
1019
1120
|
const subscription = networkObservable.subscribe({
|
|
1121
|
+
error: sink.error,
|
|
1020
1122
|
next: (loadedNode: ?NormalizationRootNode) => {
|
|
1021
1123
|
if (loadedNode != null) {
|
|
1022
1124
|
const publishModuleImportPayload = () => {
|
|
@@ -1032,7 +1134,7 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1032
1134
|
// OK: always have to run after an async module import resolves
|
|
1033
1135
|
if (shouldScheduleAsyncStoreUpdate) {
|
|
1034
1136
|
this._scheduleAsyncStoreUpdate(
|
|
1035
|
-
// $FlowFixMe[incompatible-
|
|
1137
|
+
// $FlowFixMe[incompatible-type] `shouldScheduleAsyncStoreUpdate` check should cover `null` case
|
|
1036
1138
|
batchAsyncModuleUpdatesFN,
|
|
1037
1139
|
sink.complete,
|
|
1038
1140
|
);
|
|
@@ -1042,10 +1144,10 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1042
1144
|
}
|
|
1043
1145
|
});
|
|
1044
1146
|
this._log({
|
|
1045
|
-
|
|
1147
|
+
duration,
|
|
1046
1148
|
executeId: this._executeId,
|
|
1149
|
+
name: 'execute.async.module',
|
|
1047
1150
|
operationName: operation.name,
|
|
1048
|
-
duration,
|
|
1049
1151
|
});
|
|
1050
1152
|
if (!shouldScheduleAsyncStoreUpdate) {
|
|
1051
1153
|
sink.complete();
|
|
@@ -1066,7 +1168,6 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1066
1168
|
sink.complete();
|
|
1067
1169
|
}
|
|
1068
1170
|
},
|
|
1069
|
-
error: sink.error,
|
|
1070
1171
|
});
|
|
1071
1172
|
return () => {
|
|
1072
1173
|
subscription.unsubscribe();
|
|
@@ -1094,7 +1195,7 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1094
1195
|
);
|
|
1095
1196
|
break;
|
|
1096
1197
|
default:
|
|
1097
|
-
|
|
1198
|
+
followupPayload as empty;
|
|
1098
1199
|
invariant(
|
|
1099
1200
|
false,
|
|
1100
1201
|
'OperationExecutor: Unexpected followup kind `%s`.',
|
|
@@ -1171,7 +1272,7 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1171
1272
|
} else if (placeholder.kind === 'defer') {
|
|
1172
1273
|
parentID = placeholder.selector.dataID;
|
|
1173
1274
|
} else {
|
|
1174
|
-
|
|
1275
|
+
placeholder as empty;
|
|
1175
1276
|
invariant(
|
|
1176
1277
|
false,
|
|
1177
1278
|
'OperationExecutor: Unsupported incremental placeholder kind `%s`.',
|
|
@@ -1224,8 +1325,8 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1224
1325
|
nextParentPayloads = parentPayloads;
|
|
1225
1326
|
}
|
|
1226
1327
|
this._source.set(parentID, {
|
|
1227
|
-
record: nextParentRecord,
|
|
1228
1328
|
fieldPayloads: nextParentPayloads,
|
|
1329
|
+
record: nextParentRecord,
|
|
1229
1330
|
});
|
|
1230
1331
|
|
|
1231
1332
|
// If there were any queued responses, process them now that placeholders
|
|
@@ -1243,8 +1344,8 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1243
1344
|
* metadata.
|
|
1244
1345
|
*/
|
|
1245
1346
|
_processIncrementalResponses(
|
|
1246
|
-
incrementalResponses:
|
|
1247
|
-
):
|
|
1347
|
+
incrementalResponses: ReadonlyArray<IncrementalGraphQLResponse>,
|
|
1348
|
+
): ReadonlyArray<RelayResponsePayload> {
|
|
1248
1349
|
const relayPayloads = [];
|
|
1249
1350
|
incrementalResponses.forEach(incrementalResponse => {
|
|
1250
1351
|
const {label, path, response} = incrementalResponse;
|
|
@@ -1311,7 +1412,7 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1311
1412
|
|
|
1312
1413
|
_processDeferResponse(
|
|
1313
1414
|
label: string,
|
|
1314
|
-
path:
|
|
1415
|
+
path: ReadonlyArray<unknown>,
|
|
1315
1416
|
placeholder: DeferPlaceholder,
|
|
1316
1417
|
response: GraphQLResponseWithData,
|
|
1317
1418
|
): RelayResponsePayload {
|
|
@@ -1325,11 +1426,12 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1325
1426
|
placeholder.typeName,
|
|
1326
1427
|
{
|
|
1327
1428
|
actorIdentifier: this._actorIdentifier,
|
|
1429
|
+
deferDeduplicatedFields: this._deferDeduplicatedFields,
|
|
1328
1430
|
getDataID: this._getDataID,
|
|
1329
1431
|
log: this._log,
|
|
1330
1432
|
path: placeholder.path,
|
|
1331
|
-
treatMissingFieldsAsNull: this._treatMissingFieldsAsNull,
|
|
1332
1433
|
shouldProcessClientComponents: this._shouldProcessClientComponents,
|
|
1434
|
+
treatMissingFieldsAsNull: this._treatMissingFieldsAsNull,
|
|
1333
1435
|
},
|
|
1334
1436
|
this._useExecTimeResolvers,
|
|
1335
1437
|
);
|
|
@@ -1352,10 +1454,10 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1352
1454
|
const handleFieldsRelayPayload = {
|
|
1353
1455
|
errors: null,
|
|
1354
1456
|
fieldPayloads,
|
|
1355
|
-
incrementalPlaceholders: null,
|
|
1356
1457
|
followupPayloads: null,
|
|
1357
|
-
|
|
1458
|
+
incrementalPlaceholders: null,
|
|
1358
1459
|
isFinal: response.extensions?.is_final === true,
|
|
1460
|
+
source: RelayRecordSource.create(),
|
|
1359
1461
|
};
|
|
1360
1462
|
this._getPublishQueueAndSaveActor().commitPayload(
|
|
1361
1463
|
this._operation,
|
|
@@ -1372,7 +1474,7 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1372
1474
|
*/
|
|
1373
1475
|
_processStreamResponse(
|
|
1374
1476
|
label: string,
|
|
1375
|
-
path:
|
|
1477
|
+
path: ReadonlyArray<unknown>,
|
|
1376
1478
|
placeholder: StreamPlaceholder,
|
|
1377
1479
|
response: GraphQLResponseWithData,
|
|
1378
1480
|
): RelayResponsePayload {
|
|
@@ -1442,10 +1544,10 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1442
1544
|
const handleFieldsRelayPayload = {
|
|
1443
1545
|
errors: null,
|
|
1444
1546
|
fieldPayloads,
|
|
1445
|
-
incrementalPlaceholders: null,
|
|
1446
1547
|
followupPayloads: null,
|
|
1447
|
-
|
|
1548
|
+
incrementalPlaceholders: null,
|
|
1448
1549
|
isFinal: false,
|
|
1550
|
+
source: RelayRecordSource.create(),
|
|
1449
1551
|
};
|
|
1450
1552
|
this._getPublishQueueAndSaveActor().commitPayload(
|
|
1451
1553
|
this._operation,
|
|
@@ -1462,8 +1564,8 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1462
1564
|
parentID: DataID,
|
|
1463
1565
|
field: NormalizationLinkedField,
|
|
1464
1566
|
variables: Variables,
|
|
1465
|
-
path:
|
|
1466
|
-
normalizationPath:
|
|
1567
|
+
path: ReadonlyArray<unknown>,
|
|
1568
|
+
normalizationPath: ReadonlyArray<string>,
|
|
1467
1569
|
): {
|
|
1468
1570
|
fieldPayloads: Array<HandleFieldPayload>,
|
|
1469
1571
|
itemID: DataID,
|
|
@@ -1549,8 +1651,8 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1549
1651
|
nextIDs[itemIndex] = itemID;
|
|
1550
1652
|
RelayModernRecord.setLinkedRecordIDs(nextParentRecord, storageKey, nextIDs);
|
|
1551
1653
|
this._source.set(parentID, {
|
|
1552
|
-
record: nextParentRecord,
|
|
1553
1654
|
fieldPayloads,
|
|
1655
|
+
record: nextParentRecord,
|
|
1554
1656
|
});
|
|
1555
1657
|
const relayPayload = this._normalizeResponse(
|
|
1556
1658
|
response,
|
|
@@ -1558,11 +1660,12 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1558
1660
|
typeName,
|
|
1559
1661
|
{
|
|
1560
1662
|
actorIdentifier: this._actorIdentifier,
|
|
1663
|
+
deferDeduplicatedFields: false,
|
|
1561
1664
|
getDataID: this._getDataID,
|
|
1562
1665
|
log: this._log,
|
|
1563
1666
|
path: [...normalizationPath, responseKey, String(itemIndex)],
|
|
1564
|
-
treatMissingFieldsAsNull: this._treatMissingFieldsAsNull,
|
|
1565
1667
|
shouldProcessClientComponents: this._shouldProcessClientComponents,
|
|
1668
|
+
treatMissingFieldsAsNull: this._treatMissingFieldsAsNull,
|
|
1566
1669
|
},
|
|
1567
1670
|
this._useExecTimeResolvers,
|
|
1568
1671
|
);
|
|
@@ -1596,7 +1699,7 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1596
1699
|
}
|
|
1597
1700
|
|
|
1598
1701
|
_updateOperationTracker(
|
|
1599
|
-
updatedOwners:
|
|
1702
|
+
updatedOwners: ?ReadonlyArray<RequestDescriptor>,
|
|
1600
1703
|
): void {
|
|
1601
1704
|
if (updatedOwners != null && updatedOwners.length > 0) {
|
|
1602
1705
|
this._operationTracker.update(
|
|
@@ -1615,7 +1718,7 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1615
1718
|
return this._getPublishQueue(this._actorIdentifier);
|
|
1616
1719
|
}
|
|
1617
1720
|
|
|
1618
|
-
_getActorsToVisit():
|
|
1721
|
+
_getActorsToVisit(): ReadonlySet<ActorIdentifier> {
|
|
1619
1722
|
if (this._seenActors.size === 0) {
|
|
1620
1723
|
return new Set([this._actorIdentifier]);
|
|
1621
1724
|
} else {
|
|
@@ -1625,7 +1728,7 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1625
1728
|
|
|
1626
1729
|
_runPublishQueue(
|
|
1627
1730
|
operation?: OperationDescriptor,
|
|
1628
|
-
):
|
|
1731
|
+
): ReadonlyArray<RequestDescriptor> {
|
|
1629
1732
|
const updatedOwners = new Set<RequestDescriptor>();
|
|
1630
1733
|
for (const actorIdentifier of this._getActorsToVisit()) {
|
|
1631
1734
|
const owners = this._getPublishQueue(actorIdentifier).run(operation);
|
|
@@ -1664,11 +1767,11 @@ class Executor<TMutation: MutationParameters> {
|
|
|
1664
1767
|
}
|
|
1665
1768
|
|
|
1666
1769
|
function partitionGraphQLResponses(
|
|
1667
|
-
responses:
|
|
1770
|
+
responses: ReadonlyArray<GraphQLResponseWithData>,
|
|
1668
1771
|
): [
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1772
|
+
ReadonlyArray<GraphQLResponseWithData>,
|
|
1773
|
+
ReadonlyArray<IncrementalGraphQLResponse>,
|
|
1774
|
+
ReadonlyArray<GraphQLResponseWithData>,
|
|
1672
1775
|
] {
|
|
1673
1776
|
const nonIncrementalResponses: Array<GraphQLResponseWithData> = [];
|
|
1674
1777
|
const incrementalResponses: Array<IncrementalGraphQLResponse> = [];
|
|
@@ -1699,7 +1802,7 @@ function partitionGraphQLResponses(
|
|
|
1699
1802
|
return [nonIncrementalResponses, incrementalResponses, normalizedResponses];
|
|
1700
1803
|
}
|
|
1701
1804
|
|
|
1702
|
-
function stableStringify(value:
|
|
1805
|
+
function stableStringify(value: unknown): string {
|
|
1703
1806
|
return JSON.stringify(stableCopy(value)) ?? ''; // null-check for flow
|
|
1704
1807
|
}
|
|
1705
1808
|
|
|
@@ -71,7 +71,7 @@ function getFragmentVariables(
|
|
|
71
71
|
variables[definition.name] = rootVariables[definition.name];
|
|
72
72
|
break;
|
|
73
73
|
default:
|
|
74
|
-
|
|
74
|
+
definition as empty;
|
|
75
75
|
invariant(
|
|
76
76
|
false,
|
|
77
77
|
'RelayConcreteVariables: Unexpected node kind `%s` in fragment `%s`.',
|
|
@@ -96,7 +96,7 @@ function getOperationVariables(
|
|
|
96
96
|
providedVariables: ?ProvidedVariablesType,
|
|
97
97
|
variables: Variables,
|
|
98
98
|
): Variables {
|
|
99
|
-
const operationVariables: {[string]:
|
|
99
|
+
const operationVariables: {[string]: unknown} = {};
|
|
100
100
|
operation.argumentDefinitions.forEach(def => {
|
|
101
101
|
let value = def.defaultValue;
|
|
102
102
|
if (variables[def.name] != null) {
|
|
@@ -115,8 +115,8 @@ function getOperationVariables(
|
|
|
115
115
|
|
|
116
116
|
function getLocalVariables(
|
|
117
117
|
currentVariables: Variables,
|
|
118
|
-
argumentDefinitions:
|
|
119
|
-
args:
|
|
118
|
+
argumentDefinitions: ?ReadonlyArray<NormalizationLocalArgumentDefinition>,
|
|
119
|
+
args: ?ReadonlyArray<NormalizationArgument>,
|
|
120
120
|
): Variables {
|
|
121
121
|
if (argumentDefinitions == null) {
|
|
122
122
|
return currentVariables;
|
|
@@ -132,7 +132,7 @@ function getLocalVariables(
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
module.exports = {
|
|
135
|
-
getLocalVariables,
|
|
136
135
|
getFragmentVariables,
|
|
136
|
+
getLocalVariables,
|
|
137
137
|
getOperationVariables,
|
|
138
138
|
};
|