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,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
|
};
|
|
@@ -18,13 +18,13 @@ const SELF: Self = Symbol('$SELF');
|
|
|
18
18
|
|
|
19
19
|
export opaque type Self = typeof SELF;
|
|
20
20
|
|
|
21
|
-
export type TRelayFieldErrorForDisplay =
|
|
22
|
-
path?:
|
|
21
|
+
export type TRelayFieldErrorForDisplay = Readonly<{
|
|
22
|
+
path?: ReadonlyArray<string | number>,
|
|
23
23
|
severity?: 'CRITICAL' | 'ERROR' | 'WARNING',
|
|
24
24
|
}>;
|
|
25
25
|
|
|
26
26
|
// We display a subset of the TRelayFieldError to the user. Removing the message by default.
|
|
27
|
-
export type TRelayFieldError =
|
|
27
|
+
export type TRelayFieldError = Readonly<{
|
|
28
28
|
...TRelayFieldErrorForDisplay,
|
|
29
29
|
message: string,
|
|
30
30
|
}>;
|
|
@@ -49,13 +49,13 @@ export opaque type RelayErrorTrie = Map<
|
|
|
49
49
|
>;
|
|
50
50
|
|
|
51
51
|
function buildErrorTrie(
|
|
52
|
-
errors:
|
|
52
|
+
errors: ?ReadonlyArray<PayloadError>,
|
|
53
53
|
): RelayErrorTrie | null {
|
|
54
54
|
if (errors == null) {
|
|
55
55
|
return null;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
const trie:
|
|
58
|
+
const trie: NonNullable<RelayErrorTrie> = new Map();
|
|
59
59
|
// eslint-disable-next-line no-unused-vars
|
|
60
60
|
ERRORS: for (const {path, locations: _, ...error} of errors) {
|
|
61
61
|
if (path == null) {
|
|
@@ -100,7 +100,7 @@ function buildErrorTrie(
|
|
|
100
100
|
function getErrorsByKey(
|
|
101
101
|
trie: RelayErrorTrie,
|
|
102
102
|
key: string | number,
|
|
103
|
-
):
|
|
103
|
+
): ReadonlyArray<TRelayFieldError> | null {
|
|
104
104
|
const value = trie.get(key);
|
|
105
105
|
if (value == null) {
|
|
106
106
|
return null;
|
|
@@ -109,7 +109,7 @@ function getErrorsByKey(
|
|
|
109
109
|
return value;
|
|
110
110
|
}
|
|
111
111
|
const errors: Array<
|
|
112
|
-
|
|
112
|
+
Readonly<{
|
|
113
113
|
message: string,
|
|
114
114
|
path?: Array<string | number>,
|
|
115
115
|
severity?: 'CRITICAL' | 'ERROR' | 'WARNING',
|
|
@@ -122,7 +122,7 @@ function getErrorsByKey(
|
|
|
122
122
|
function recursivelyCopyErrorsIntoArray(
|
|
123
123
|
trieOrSet: RelayErrorTrie,
|
|
124
124
|
errors: Array<
|
|
125
|
-
|
|
125
|
+
Readonly<{
|
|
126
126
|
message: string,
|
|
127
127
|
path?: Array<string | number>,
|
|
128
128
|
severity?: 'CRITICAL' | 'ERROR' | 'WARNING',
|
|
@@ -165,14 +165,14 @@ function getNestedErrorTrieByKey(
|
|
|
165
165
|
return null;
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
module.exports =
|
|
168
|
+
module.exports = {
|
|
169
169
|
SELF,
|
|
170
170
|
buildErrorTrie,
|
|
171
|
-
getNestedErrorTrieByKey,
|
|
172
171
|
getErrorsByKey,
|
|
173
|
-
|
|
172
|
+
getNestedErrorTrieByKey,
|
|
173
|
+
} as {
|
|
174
174
|
SELF: typeof SELF,
|
|
175
175
|
buildErrorTrie: typeof buildErrorTrie,
|
|
176
176
|
getNestedErrorTrieByKey: typeof getNestedErrorTrieByKey,
|
|
177
177
|
getErrorsByKey: typeof getErrorsByKey,
|
|
178
|
-
}
|
|
178
|
+
};
|
|
@@ -58,7 +58,7 @@ class GraphModeHandler {
|
|
|
58
58
|
this._streamIdToCacheKey.clear();
|
|
59
59
|
break;
|
|
60
60
|
default:
|
|
61
|
-
|
|
61
|
+
chunk.$kind as empty;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
return this._recordSource;
|
|
@@ -93,12 +93,12 @@ class GraphModeHandler {
|
|
|
93
93
|
} else {
|
|
94
94
|
if (value.hasOwnProperty('__id')) {
|
|
95
95
|
// Singular
|
|
96
|
-
const streamID: number =
|
|
96
|
+
const streamID: number = value.__id as any;
|
|
97
97
|
const id = this._lookupCacheKey(streamID);
|
|
98
98
|
RelayModernRecord.setLinkedRecordID(parentRecord, key, id);
|
|
99
99
|
} else if (value.hasOwnProperty('__ids')) {
|
|
100
100
|
// Plural
|
|
101
|
-
const streamIDs: Array<number | null> =
|
|
101
|
+
const streamIDs: Array<number | null> = value.__ids as any;
|
|
102
102
|
const ids = streamIDs.map((sID): ?DataID => {
|
|
103
103
|
return sID == null ? null : this._lookupCacheKey(sID);
|
|
104
104
|
});
|
|
@@ -183,7 +183,7 @@ export class GraphModeNormalizer {
|
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
_getObjectType(data: PayloadData): string {
|
|
186
|
-
const typeName = (data
|
|
186
|
+
const typeName = (data as any)[TYPENAME_KEY];
|
|
187
187
|
invariant(
|
|
188
188
|
typeName != null,
|
|
189
189
|
'Expected a typename for record `%s`.',
|
|
@@ -198,7 +198,7 @@ export class GraphModeNormalizer {
|
|
|
198
198
|
return getStorageKey(selection, this._variables);
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
-
_getVariableValue(name: string):
|
|
201
|
+
_getVariableValue(name: string): unknown {
|
|
202
202
|
invariant(
|
|
203
203
|
this._variables.hasOwnProperty(name),
|
|
204
204
|
'Unexpected undefined variable `%s`.',
|
|
@@ -218,10 +218,10 @@ export class GraphModeNormalizer {
|
|
|
218
218
|
const $streamID = this._getStreamID();
|
|
219
219
|
yield {
|
|
220
220
|
...rootFields,
|
|
221
|
-
$kind: 'Record',
|
|
222
|
-
$streamID,
|
|
223
221
|
__id: dataID,
|
|
224
222
|
__typename: ROOT_TYPE,
|
|
223
|
+
$kind: 'Record',
|
|
224
|
+
$streamID,
|
|
225
225
|
} as RecordChunk;
|
|
226
226
|
yield {
|
|
227
227
|
$kind: 'Complete',
|
|
@@ -243,9 +243,9 @@ export class GraphModeNormalizer {
|
|
|
243
243
|
// experimental transform
|
|
244
244
|
yield {
|
|
245
245
|
...fields,
|
|
246
|
-
$kind: 'Record',
|
|
247
|
-
__typename: typename,
|
|
248
246
|
__id: cacheKey,
|
|
247
|
+
__typename: typename,
|
|
248
|
+
$kind: 'Record',
|
|
249
249
|
$streamID,
|
|
250
250
|
} as RecordChunk;
|
|
251
251
|
} else if (Object.keys(fields).length > 0) {
|
|
@@ -267,7 +267,7 @@ export class GraphModeNormalizer {
|
|
|
267
267
|
switch (selection.kind) {
|
|
268
268
|
case LINKED_FIELD: {
|
|
269
269
|
const responseKey = selection.alias ?? selection.name;
|
|
270
|
-
const fieldData: PayloadData =
|
|
270
|
+
const fieldData: PayloadData = data[responseKey] as any;
|
|
271
271
|
|
|
272
272
|
const storageKey = this._getStorageKey(selection);
|
|
273
273
|
|
|
@@ -305,7 +305,7 @@ export class GraphModeNormalizer {
|
|
|
305
305
|
this.duplicateFieldsAvoided++;
|
|
306
306
|
break;
|
|
307
307
|
}
|
|
308
|
-
const fieldData: ChunkField =
|
|
308
|
+
const fieldData: ChunkField = data[responseKey] as any;
|
|
309
309
|
|
|
310
310
|
parentFields[storageKey] = fieldData;
|
|
311
311
|
sentFields.add(storageKey);
|
|
@@ -378,8 +378,9 @@ export class GraphModeNormalizer {
|
|
|
378
378
|
// Otherwise data *for this selection* should not be present: enqueue
|
|
379
379
|
// metadata to process the subsequent response chunk.
|
|
380
380
|
this._incrementalPlaceholders.push({
|
|
381
|
-
|
|
381
|
+
actorIdentifier: this._actorIdentifier,
|
|
382
382
|
data,
|
|
383
|
+
kind: 'defer',
|
|
383
384
|
label: selection.label,
|
|
384
385
|
path: [...this._path],
|
|
385
386
|
selector: createNormalizationSelector(
|
|
@@ -388,7 +389,6 @@ export class GraphModeNormalizer {
|
|
|
388
389
|
this._variables,
|
|
389
390
|
),
|
|
390
391
|
typeName: this._getObjectType(data),
|
|
391
|
-
actorIdentifier: this._actorIdentifier,
|
|
392
392
|
});
|
|
393
393
|
}
|
|
394
394
|
break;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { GetDataID } from './RelayResponseNormalizer';
|
|
9
|
+
|
|
10
|
+
import { HandlerProvider } from '../handlers/RelayDefaultHandlerProvider';
|
|
11
|
+
import {GraphQLResponse, Network, PayloadData, UploadableMap} from '../network/RelayNetworkTypes';
|
|
12
|
+
import { RelayObservable } from '../network/RelayObservable';
|
|
13
|
+
import {Disposable, RenderPolicy} from '../util/RelayRuntimeTypes';
|
|
14
|
+
import { TaskScheduler } from './OperationExecutor';
|
|
15
|
+
import { RelayOperationTracker } from './RelayOperationTracker';
|
|
16
|
+
import {
|
|
17
|
+
Environment,
|
|
18
|
+
LogFunction,
|
|
19
|
+
MissingFieldHandler,
|
|
20
|
+
OperationAvailability,
|
|
21
|
+
OperationDescriptor,
|
|
22
|
+
OperationLoader,
|
|
23
|
+
OperationTracker,
|
|
24
|
+
OptimisticResponseConfig,
|
|
25
|
+
OptimisticUpdateFunction,
|
|
26
|
+
RelayFieldLogger,
|
|
27
|
+
SelectorStoreUpdater,
|
|
28
|
+
SingularReaderSelector,
|
|
29
|
+
Snapshot,
|
|
30
|
+
Store,
|
|
31
|
+
StoreUpdater,
|
|
32
|
+
} from './RelayStoreTypes';
|
|
33
|
+
|
|
34
|
+
export interface EnvironmentConfig {
|
|
35
|
+
readonly configName?: string | undefined;
|
|
36
|
+
readonly handlerProvider?: HandlerProvider | null | undefined;
|
|
37
|
+
readonly treatMissingFieldsAsNull?: boolean | undefined;
|
|
38
|
+
readonly log?: LogFunction | null | undefined;
|
|
39
|
+
readonly operationLoader?: OperationLoader | null | undefined;
|
|
40
|
+
readonly network: Network;
|
|
41
|
+
readonly scheduler?: TaskScheduler | null | undefined;
|
|
42
|
+
readonly store?: Store;
|
|
43
|
+
readonly missingFieldHandlers?: readonly MissingFieldHandler[] | null | undefined;
|
|
44
|
+
readonly operationTracker?: OperationTracker | null | undefined;
|
|
45
|
+
readonly getDataID?: GetDataID | null | undefined;
|
|
46
|
+
readonly UNSTABLE_defaultRenderPolicy?: RenderPolicy | null | undefined;
|
|
47
|
+
readonly options?: unknown | undefined;
|
|
48
|
+
readonly isServer?: boolean | undefined;
|
|
49
|
+
readonly relayFieldLogger?: RelayFieldLogger | null | undefined;
|
|
50
|
+
readonly shouldProcessClientComponents?: boolean | null | undefined;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export default class RelayModernEnvironment implements Environment {
|
|
54
|
+
options: unknown;
|
|
55
|
+
configName: string | null | undefined;
|
|
56
|
+
relayFieldLogger: RelayFieldLogger;
|
|
57
|
+
constructor(config: EnvironmentConfig);
|
|
58
|
+
getStore(): Store;
|
|
59
|
+
getNetwork(): Network;
|
|
60
|
+
getOperationTracker(): RelayOperationTracker;
|
|
61
|
+
isRequestActive(requestIdentifier: string): boolean;
|
|
62
|
+
applyUpdate(optimisticUpdate: OptimisticUpdateFunction): Disposable;
|
|
63
|
+
revertUpdate(update: OptimisticUpdateFunction): void;
|
|
64
|
+
replaceUpdate(update: OptimisticUpdateFunction, newUpdate: OptimisticUpdateFunction): void;
|
|
65
|
+
applyMutation(optimisticConfig: OptimisticResponseConfig): Disposable;
|
|
66
|
+
check(operation: OperationDescriptor): OperationAvailability;
|
|
67
|
+
commitPayload(operationDescriptor: OperationDescriptor, payload: PayloadData): void;
|
|
68
|
+
commitUpdate(updater: StoreUpdater): void;
|
|
69
|
+
lookup(readSelector: SingularReaderSelector): Snapshot;
|
|
70
|
+
subscribe(snapshot: Snapshot, callback: (snapshot: Snapshot) => void): Disposable;
|
|
71
|
+
retain(operation: OperationDescriptor): Disposable;
|
|
72
|
+
isServer(): boolean;
|
|
73
|
+
execute(data: {
|
|
74
|
+
operation: OperationDescriptor;
|
|
75
|
+
updater?: SelectorStoreUpdater | null | undefined;
|
|
76
|
+
}): RelayObservable<GraphQLResponse>;
|
|
77
|
+
executeMutation({
|
|
78
|
+
operation,
|
|
79
|
+
optimisticResponse,
|
|
80
|
+
optimisticUpdater,
|
|
81
|
+
updater,
|
|
82
|
+
uploadables,
|
|
83
|
+
}: {
|
|
84
|
+
operation: OperationDescriptor;
|
|
85
|
+
optimisticUpdater?: SelectorStoreUpdater | null | undefined;
|
|
86
|
+
optimisticResponse?: { [key: string]: any } | null | undefined;
|
|
87
|
+
updater?: SelectorStoreUpdater | null | undefined;
|
|
88
|
+
uploadables?: UploadableMap | null | undefined;
|
|
89
|
+
}): RelayObservable<GraphQLResponse>;
|
|
90
|
+
executeWithSource({
|
|
91
|
+
operation,
|
|
92
|
+
source,
|
|
93
|
+
}: {
|
|
94
|
+
operation: OperationDescriptor;
|
|
95
|
+
source: RelayObservable<GraphQLResponse>;
|
|
96
|
+
}): RelayObservable<GraphQLResponse>;
|
|
97
|
+
}
|
|
@@ -64,28 +64,29 @@ const RelayRecordSource = require('./RelayRecordSource');
|
|
|
64
64
|
const invariant = require('invariant');
|
|
65
65
|
|
|
66
66
|
export type EnvironmentConfig = {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
67
|
+
readonly configName?: string,
|
|
68
|
+
readonly handlerProvider?: ?HandlerProvider,
|
|
69
|
+
readonly treatMissingFieldsAsNull?: boolean,
|
|
70
|
+
readonly deferDeduplicatedFields?: boolean,
|
|
71
|
+
readonly log?: ?LogFunction,
|
|
72
|
+
readonly operationLoader?: ?OperationLoader,
|
|
73
|
+
readonly network: INetwork,
|
|
74
|
+
readonly normalizeResponse?: ?NormalizeResponseFunction,
|
|
75
|
+
readonly scheduler?: ?TaskScheduler,
|
|
76
|
+
readonly store?: Store,
|
|
77
|
+
readonly missingFieldHandlers?: ?ReadonlyArray<MissingFieldHandler>,
|
|
78
|
+
readonly operationTracker?: ?OperationTracker,
|
|
79
|
+
readonly getDataID?: ?GetDataID,
|
|
80
|
+
readonly UNSTABLE_defaultRenderPolicy?: ?RenderPolicy,
|
|
81
|
+
readonly options?: unknown,
|
|
82
|
+
readonly isServer?: boolean,
|
|
83
|
+
readonly relayFieldLogger?: ?RelayFieldLogger,
|
|
84
|
+
readonly shouldProcessClientComponents?: ?boolean,
|
|
84
85
|
};
|
|
85
86
|
|
|
86
87
|
class RelayModernEnvironment implements IEnvironment {
|
|
87
88
|
__log: LogFunction;
|
|
88
|
-
|
|
89
|
+
readonly _defaultRenderPolicy: RenderPolicy;
|
|
89
90
|
_operationLoader: ?OperationLoader;
|
|
90
91
|
_shouldProcessClientComponents: ?boolean;
|
|
91
92
|
_network: INetwork;
|
|
@@ -93,19 +94,21 @@ class RelayModernEnvironment implements IEnvironment {
|
|
|
93
94
|
_scheduler: ?TaskScheduler;
|
|
94
95
|
_store: Store;
|
|
95
96
|
configName: ?string;
|
|
96
|
-
_missingFieldHandlers:
|
|
97
|
+
_missingFieldHandlers: ReadonlyArray<MissingFieldHandler>;
|
|
97
98
|
_operationTracker: OperationTracker;
|
|
98
99
|
_getDataID: GetDataID;
|
|
99
100
|
_treatMissingFieldsAsNull: boolean;
|
|
101
|
+
_deferDeduplicatedFields: boolean;
|
|
100
102
|
_operationExecutions: Map<string, ActiveState>;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
+
readonly options: unknown;
|
|
104
|
+
readonly _isServer: boolean;
|
|
103
105
|
relayFieldLogger: RelayFieldLogger;
|
|
104
106
|
_normalizeResponse: NormalizeResponseFunction;
|
|
105
107
|
|
|
106
108
|
constructor(config: EnvironmentConfig) {
|
|
107
109
|
this.configName = config.configName;
|
|
108
110
|
this._treatMissingFieldsAsNull = config.treatMissingFieldsAsNull === true;
|
|
111
|
+
this._deferDeduplicatedFields = config.deferDeduplicatedFields === true;
|
|
109
112
|
const operationLoader = config.operationLoader;
|
|
110
113
|
if (__DEV__) {
|
|
111
114
|
if (operationLoader != null) {
|
|
@@ -122,9 +125,9 @@ class RelayModernEnvironment implements IEnvironment {
|
|
|
122
125
|
const store =
|
|
123
126
|
config.store ??
|
|
124
127
|
new RelayModernStore(new RelayRecordSource(), {
|
|
128
|
+
getDataID: config.getDataID,
|
|
125
129
|
log: config.log,
|
|
126
130
|
operationLoader: config.operationLoader,
|
|
127
|
-
getDataID: config.getDataID,
|
|
128
131
|
shouldProcessClientComponents: config.shouldProcessClientComponents,
|
|
129
132
|
});
|
|
130
133
|
|
|
@@ -150,12 +153,12 @@ class RelayModernEnvironment implements IEnvironment {
|
|
|
150
153
|
this._isServer = config.isServer ?? false;
|
|
151
154
|
this._normalizeResponse = config.normalizeResponse ?? normalizeResponse;
|
|
152
155
|
|
|
153
|
-
(this
|
|
156
|
+
(this as any).__setNet = newNet =>
|
|
154
157
|
(this._network = wrapNetworkWithLogObserver(this, newNet));
|
|
155
158
|
|
|
156
159
|
if (__DEV__) {
|
|
157
160
|
const {inspect} = require('./StoreInspector');
|
|
158
|
-
(this
|
|
161
|
+
(this as any).DEBUG_inspect = (dataID: ?string) => inspect(this, dataID);
|
|
159
162
|
}
|
|
160
163
|
|
|
161
164
|
this._operationTracker =
|
|
@@ -224,7 +227,7 @@ class RelayModernEnvironment implements IEnvironment {
|
|
|
224
227
|
});
|
|
225
228
|
}
|
|
226
229
|
|
|
227
|
-
applyMutation<TMutation
|
|
230
|
+
applyMutation<TMutation extends MutationParameters>(
|
|
228
231
|
optimisticConfig: OptimisticResponseConfig<TMutation>,
|
|
229
232
|
): Disposable {
|
|
230
233
|
const subscription = this._execute({
|
|
@@ -256,7 +259,7 @@ class RelayModernEnvironment implements IEnvironment {
|
|
|
256
259
|
this._execute({
|
|
257
260
|
createSource: () => RelayObservable.from({data: payload}),
|
|
258
261
|
isClientPayload: true,
|
|
259
|
-
operation
|
|
262
|
+
operation,
|
|
260
263
|
optimisticConfig: null,
|
|
261
264
|
updater: null,
|
|
262
265
|
}).subscribe({});
|
|
@@ -284,18 +287,28 @@ class RelayModernEnvironment implements IEnvironment {
|
|
|
284
287
|
return this._store.retain(operation);
|
|
285
288
|
}
|
|
286
289
|
|
|
290
|
+
experimental_batchUpdates(callback: () => void): void {
|
|
291
|
+
// $FlowFixMe[prop-missing] - experimental method not on Store interface
|
|
292
|
+
const batchFn = this._store.experimental_batchUpdates;
|
|
293
|
+
invariant(
|
|
294
|
+
typeof batchFn === 'function',
|
|
295
|
+
'RelayModernEnvironment: The current store does not support experimental_batchUpdates.',
|
|
296
|
+
);
|
|
297
|
+
// We must use .call to preserve Flow's narrowing from the above typeof check.
|
|
298
|
+
batchFn.call(this._store, callback);
|
|
299
|
+
}
|
|
300
|
+
|
|
287
301
|
isServer(): boolean {
|
|
288
302
|
return this._isServer;
|
|
289
303
|
}
|
|
290
304
|
|
|
291
305
|
_checkSelectorAndHandleMissingFields(
|
|
292
306
|
operation: OperationDescriptor,
|
|
293
|
-
handlers:
|
|
307
|
+
handlers: ReadonlyArray<MissingFieldHandler>,
|
|
294
308
|
): OperationAvailability {
|
|
295
309
|
const target = RelayRecordSource.create();
|
|
296
310
|
const source = this._store.getSource();
|
|
297
311
|
const result = this._store.check(operation, {
|
|
298
|
-
handlers,
|
|
299
312
|
defaultActorIdentifier: INTERNAL_ACTOR_IDENTIFIER_DO_NOT_USE,
|
|
300
313
|
getSourceForActor(actorIdentifier: ActorIdentifier) {
|
|
301
314
|
assertInternalActorIdentifier(actorIdentifier);
|
|
@@ -305,6 +318,7 @@ class RelayModernEnvironment implements IEnvironment {
|
|
|
305
318
|
assertInternalActorIdentifier(actorIdentifier);
|
|
306
319
|
return target;
|
|
307
320
|
},
|
|
321
|
+
handlers,
|
|
308
322
|
});
|
|
309
323
|
if (target.size() > 0) {
|
|
310
324
|
this._scheduleUpdates(() => {
|
|
@@ -365,7 +379,7 @@ class RelayModernEnvironment implements IEnvironment {
|
|
|
365
379
|
* Note: Observables are lazy, so calling this method will do nothing until
|
|
366
380
|
* the result is subscribed to: environment.execute({...}).subscribe({...}).
|
|
367
381
|
*/
|
|
368
|
-
executeSubscription<TMutation
|
|
382
|
+
executeSubscription<TMutation extends MutationParameters>({
|
|
369
383
|
operation,
|
|
370
384
|
updater,
|
|
371
385
|
}: {
|
|
@@ -397,7 +411,7 @@ class RelayModernEnvironment implements IEnvironment {
|
|
|
397
411
|
* the result is subscribed to:
|
|
398
412
|
* environment.executeMutation({...}).subscribe({...}).
|
|
399
413
|
*/
|
|
400
|
-
executeMutation<TMutation
|
|
414
|
+
executeMutation<TMutation extends MutationParameters>({
|
|
401
415
|
operation,
|
|
402
416
|
optimisticResponse,
|
|
403
417
|
optimisticUpdater,
|
|
@@ -407,7 +421,7 @@ class RelayModernEnvironment implements IEnvironment {
|
|
|
407
421
|
let optimisticConfig;
|
|
408
422
|
if (optimisticResponse || optimisticUpdater) {
|
|
409
423
|
optimisticConfig = {
|
|
410
|
-
operation
|
|
424
|
+
operation,
|
|
411
425
|
response: optimisticResponse,
|
|
412
426
|
updater: optimisticUpdater,
|
|
413
427
|
};
|
|
@@ -455,11 +469,11 @@ class RelayModernEnvironment implements IEnvironment {
|
|
|
455
469
|
});
|
|
456
470
|
}
|
|
457
471
|
|
|
458
|
-
toJSON():
|
|
472
|
+
toJSON(): unknown {
|
|
459
473
|
return `RelayModernEnvironment(${this.configName ?? ''})`;
|
|
460
474
|
}
|
|
461
475
|
|
|
462
|
-
_execute<TMutation
|
|
476
|
+
_execute<TMutation extends MutationParameters>({
|
|
463
477
|
createSource,
|
|
464
478
|
isClientPayload,
|
|
465
479
|
operation,
|
|
@@ -478,30 +492,31 @@ class RelayModernEnvironment implements IEnvironment {
|
|
|
478
492
|
const executor = OperationExecutor.execute<$FlowFixMe>({
|
|
479
493
|
actorIdentifier: INTERNAL_ACTOR_IDENTIFIER_DO_NOT_USE,
|
|
480
494
|
getDataID: this._getDataID,
|
|
495
|
+
getPublishQueue(actorIdentifier: ActorIdentifier) {
|
|
496
|
+
assertInternalActorIdentifier(actorIdentifier);
|
|
497
|
+
return publishQueue;
|
|
498
|
+
},
|
|
499
|
+
getStore(actorIdentifier: ActorIdentifier) {
|
|
500
|
+
assertInternalActorIdentifier(actorIdentifier);
|
|
501
|
+
return store;
|
|
502
|
+
},
|
|
481
503
|
isClientPayload,
|
|
482
504
|
log: this.__log,
|
|
505
|
+
normalizeResponse: this._normalizeResponse,
|
|
483
506
|
operation,
|
|
484
507
|
operationExecutions: this._operationExecutions,
|
|
485
508
|
operationLoader: this._operationLoader,
|
|
486
509
|
operationTracker: this._operationTracker,
|
|
487
510
|
optimisticConfig,
|
|
488
|
-
getPublishQueue(actorIdentifier: ActorIdentifier) {
|
|
489
|
-
assertInternalActorIdentifier(actorIdentifier);
|
|
490
|
-
return publishQueue;
|
|
491
|
-
},
|
|
492
511
|
scheduler: this._scheduler,
|
|
493
512
|
shouldProcessClientComponents: this._shouldProcessClientComponents,
|
|
494
513
|
sink,
|
|
495
514
|
// NOTE: Some product tests expect `Network.execute` to be called only
|
|
496
515
|
// when the Observable is executed.
|
|
497
516
|
source: createSource(),
|
|
498
|
-
getStore(actorIdentifier: ActorIdentifier) {
|
|
499
|
-
assertInternalActorIdentifier(actorIdentifier);
|
|
500
|
-
return store;
|
|
501
|
-
},
|
|
502
517
|
treatMissingFieldsAsNull: this._treatMissingFieldsAsNull,
|
|
518
|
+
deferDeduplicatedFields: this._deferDeduplicatedFields,
|
|
503
519
|
updater,
|
|
504
|
-
normalizeResponse: this._normalizeResponse,
|
|
505
520
|
});
|
|
506
521
|
return () => executor.cancel();
|
|
507
522
|
});
|
|
@@ -520,7 +535,7 @@ function operationHasClientAbstractTypes(
|
|
|
520
535
|
// Add a sigil for detection by `isRelayModernEnvironment()` to avoid a
|
|
521
536
|
// realm-specific instanceof check, and to aid in module tree-shaking to
|
|
522
537
|
// avoid requiring all of RelayRuntime just to detect its environment.
|
|
523
|
-
(RelayModernEnvironment
|
|
538
|
+
(RelayModernEnvironment as any).prototype['@@RelayModernEnvironment'] = true;
|
|
524
539
|
|
|
525
540
|
function emptyFunction() {}
|
|
526
541
|
|
|
@@ -43,7 +43,7 @@ const areEqual = require('areEqual');
|
|
|
43
43
|
const invariant = require('invariant');
|
|
44
44
|
const warning = require('warning');
|
|
45
45
|
|
|
46
|
-
type Props = {[key: string]:
|
|
46
|
+
type Props = {[key: string]: unknown, ...};
|
|
47
47
|
type Resolvers = {
|
|
48
48
|
[key: string]: ?(SelectorListResolver | SelectorResolver),
|
|
49
49
|
...
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { ConcreteRequest } from '../util/RelayConcreteNode';
|
|
9
|
+
import {CacheConfig, DataID, Variables} from '../util/RelayRuntimeTypes';
|
|
10
|
+
import {OperationDescriptor, RequestDescriptor} from './RelayStoreTypes';
|
|
11
|
+
/**
|
|
12
|
+
* Creates an instance of the `OperationDescriptor` type defined in
|
|
13
|
+
* `RelayStoreTypes` given an operation and some variables. The input variables
|
|
14
|
+
* are filtered to exclude variables that do not match defined arguments on the
|
|
15
|
+
* operation, and default values are populated for null values.
|
|
16
|
+
*/
|
|
17
|
+
export function createOperationDescriptor(
|
|
18
|
+
request: ConcreteRequest,
|
|
19
|
+
variables: Variables,
|
|
20
|
+
cacheConfig?: CacheConfig | null,
|
|
21
|
+
dataID?: DataID,
|
|
22
|
+
): OperationDescriptor;
|
|
23
|
+
|
|
24
|
+
export function createRequestDescriptor(
|
|
25
|
+
request: ConcreteRequest,
|
|
26
|
+
variables: Variables,
|
|
27
|
+
cacheConfig?: CacheConfig | null,
|
|
28
|
+
): RequestDescriptor;
|
|
@@ -39,7 +39,7 @@ const invariant = require('invariant');
|
|
|
39
39
|
* are filtered to exclude variables that do not match defined arguments on the
|
|
40
40
|
* operation, and default values are populated for null values.
|
|
41
41
|
*/
|
|
42
|
-
function createOperationDescriptor<TQuery
|
|
42
|
+
function createOperationDescriptor<TQuery extends OperationType>(
|
|
43
43
|
request: ConcreteRequest,
|
|
44
44
|
variables: VariablesOf<TQuery>,
|
|
45
45
|
cacheConfig?: ?CacheConfig,
|