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
|
@@ -0,0 +1,49 @@
|
|
|
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 { GraphQLTaggedNode } from '../query/GraphQLTag';
|
|
9
|
+
import type {ArrayKeyType, ArrayKeyTypeData, Environment as IEnvironment, KeyType, KeyTypeData} from './RelayStoreTypes';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* EXPERIMENTAL: This API is experimental and does not yet support all Relay
|
|
13
|
+
* features. Notably, it does not correctly handle some features of Relay Resolvers.
|
|
14
|
+
*
|
|
15
|
+
* Given a fragment and a fragment reference, returns a promise that resolves
|
|
16
|
+
* once the fragment data is available, or rejects if the fragment has an error.
|
|
17
|
+
* Errors include both network errors and field errors due to @required(action:
|
|
18
|
+
* THROW) or @throwOnFieldError.
|
|
19
|
+
|
|
20
|
+
* This API is intended for use when consuming data outside of a UI framework, or
|
|
21
|
+
* when you need to imperatively access data inside an event handler. For example,
|
|
22
|
+
* you might choose to @defer a fragment that you only need to access inside an
|
|
23
|
+
* event handler and then await its value inside the handler if/when it is triggered.
|
|
24
|
+
*/
|
|
25
|
+
export function waitForFragmentData<TKey extends KeyType>(
|
|
26
|
+
environment: IEnvironment,
|
|
27
|
+
fragmentInput: GraphQLTaggedNode,
|
|
28
|
+
fragmentRef: TKey,
|
|
29
|
+
): Promise<KeyTypeData<TKey>>;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* EXPERIMENTAL: This API is experimental and does not yet support all Relay
|
|
33
|
+
* features. Notably, it does not correctly handle some features of Relay Resolvers.
|
|
34
|
+
*
|
|
35
|
+
* Given a fragment and a fragment reference, returns a promise that resolves
|
|
36
|
+
* once the fragment data is available, or rejects if the fragment has an error.
|
|
37
|
+
* Errors include both network errors and field errors due to @required(action:
|
|
38
|
+
* THROW) or @throwOnFieldError.
|
|
39
|
+
|
|
40
|
+
* This API is intended for use when consuming data outside of a UI framework, or
|
|
41
|
+
* when you need to imperatively access data inside an event handler. For example,
|
|
42
|
+
* you might choose to @defer a fragment that you only need to access inside an
|
|
43
|
+
* event handler and then await its value inside the handler if/when it is triggered.
|
|
44
|
+
*/
|
|
45
|
+
export function waitForFragmentData<TKey extends ArrayKeyType>(
|
|
46
|
+
environment: IEnvironment,
|
|
47
|
+
fragmentInput: GraphQLTaggedNode,
|
|
48
|
+
fragmentRef: TKey,
|
|
49
|
+
): Promise<ArrayKeyTypeData<TKey>>;
|
|
@@ -33,12 +33,12 @@ const {observeFragment} = require('./observeFragmentExperimental');
|
|
|
33
33
|
* you might choose to @defer a fragment that you only need to access inside an
|
|
34
34
|
* event handler and then await its value inside the handler if/when it is triggered.
|
|
35
35
|
*/
|
|
36
|
-
async function waitForFragmentData<TFragmentType
|
|
36
|
+
async function waitForFragmentData<TFragmentType extends FragmentType, TData>(
|
|
37
37
|
environment: IEnvironment,
|
|
38
38
|
fragment: Fragment<TFragmentType, TData>,
|
|
39
39
|
fragmentRef:
|
|
40
40
|
| HasSpread<TFragmentType>
|
|
41
|
-
|
|
|
41
|
+
| ReadonlyArray<HasSpread<TFragmentType>>,
|
|
42
42
|
): Promise<TData> {
|
|
43
43
|
let subscription: ?Subscription;
|
|
44
44
|
|
|
@@ -60,7 +60,7 @@ async function waitForFragmentData<TFragmentType: FragmentType, TData>(
|
|
|
60
60
|
});
|
|
61
61
|
subscription?.unsubscribe();
|
|
62
62
|
return data;
|
|
63
|
-
} catch (e:
|
|
63
|
+
} catch (e: unknown) {
|
|
64
64
|
subscription?.unsubscribe();
|
|
65
65
|
throw e;
|
|
66
66
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
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 { DeclarativeMutationConfig } from '../mutations/RelayDeclarativeMutationConfig';
|
|
9
|
+
import { GraphQLTaggedNode } from '../query/GraphQLTag';
|
|
10
|
+
import {Environment, SelectorStoreUpdater} from '../store/RelayStoreTypes';
|
|
11
|
+
import {CacheConfig, Disposable, OperationType} from '../util/RelayRuntimeTypes';
|
|
12
|
+
|
|
13
|
+
export interface GraphQLSubscriptionConfig<TSubscription extends OperationType> {
|
|
14
|
+
cacheConfig?: CacheConfig | undefined;
|
|
15
|
+
configs?: readonly DeclarativeMutationConfig[] | undefined;
|
|
16
|
+
subscription: GraphQLTaggedNode;
|
|
17
|
+
variables: TSubscription['variables'];
|
|
18
|
+
onCompleted?: (() => void) | undefined;
|
|
19
|
+
onError?: ((error: Error) => void) | undefined;
|
|
20
|
+
onNext?: ((response: TSubscription['response'] | null | undefined) => void) | undefined;
|
|
21
|
+
updater?: SelectorStoreUpdater<TSubscription['response']> | undefined;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function requestSubscription<TSubscription extends OperationType = OperationType>(
|
|
25
|
+
environment: Environment,
|
|
26
|
+
config: GraphQLSubscriptionConfig<TSubscription>,
|
|
27
|
+
): Disposable;
|
|
@@ -32,9 +32,9 @@ const {createReaderSelector} = require('../store/RelayModernSelector');
|
|
|
32
32
|
const warning = require('warning');
|
|
33
33
|
|
|
34
34
|
export type SubscriptionParameters = {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
readonly response: {...},
|
|
36
|
+
readonly variables: {...},
|
|
37
|
+
readonly rawResponse?: {...},
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
/**
|
|
@@ -42,18 +42,18 @@ export type SubscriptionParameters = {
|
|
|
42
42
|
* type information.
|
|
43
43
|
*/
|
|
44
44
|
export type GraphQLSubscriptionConfig<TVariables, TData, TRawResponse> =
|
|
45
|
-
|
|
45
|
+
Readonly<{
|
|
46
46
|
configs?: Array<DeclarativeMutationConfig>,
|
|
47
47
|
cacheConfig?: CacheConfig,
|
|
48
48
|
subscription: GraphQLSubscription<TVariables, TData, TRawResponse>,
|
|
49
|
-
variables: TVariables
|
|
49
|
+
variables: NoInfer<TVariables>,
|
|
50
50
|
onCompleted?: ?() => void,
|
|
51
51
|
onError?: ?(error: Error) => void,
|
|
52
52
|
onNext?: ?(response: ?TData) => void,
|
|
53
53
|
updater?: ?SelectorStoreUpdater<TData>,
|
|
54
54
|
}>;
|
|
55
55
|
|
|
56
|
-
function requestSubscription<TVariables
|
|
56
|
+
function requestSubscription<TVariables extends Variables, TData, TRawResponse>(
|
|
57
57
|
environment: IEnvironment,
|
|
58
58
|
config: GraphQLSubscriptionConfig<TVariables, TData, TRawResponse>,
|
|
59
59
|
): Disposable {
|
|
@@ -89,6 +89,8 @@ function requestSubscription<TVariables: Variables, TData, TRawResponse>(
|
|
|
89
89
|
updater,
|
|
90
90
|
})
|
|
91
91
|
.subscribe({
|
|
92
|
+
complete: onCompleted,
|
|
93
|
+
error: onError,
|
|
92
94
|
next: responses => {
|
|
93
95
|
if (onNext != null) {
|
|
94
96
|
let selector = operation.fragment;
|
|
@@ -107,12 +109,10 @@ function requestSubscription<TVariables: Variables, TData, TRawResponse>(
|
|
|
107
109
|
);
|
|
108
110
|
}
|
|
109
111
|
const data = environment.lookup(selector).data;
|
|
110
|
-
// $FlowFixMe[incompatible-
|
|
111
|
-
onNext(
|
|
112
|
+
// $FlowFixMe[incompatible-type]
|
|
113
|
+
onNext(data as TData);
|
|
112
114
|
}
|
|
113
115
|
},
|
|
114
|
-
error: onError,
|
|
115
|
-
complete: onCompleted,
|
|
116
116
|
});
|
|
117
117
|
return {
|
|
118
118
|
dispose: sub.unsubscribe,
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
export interface JSResourceReference
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
export interface JSResourceReference<out T> {
|
|
15
|
+
readonly getModuleId: () => string;
|
|
16
|
+
readonly getModuleIfRequired: () => ?T;
|
|
17
|
+
readonly load: () => Promise<T>;
|
|
18
18
|
}
|
|
@@ -0,0 +1,235 @@
|
|
|
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 {ConcreteRequest, ProvidedVariableType} from './RelayConcreteNode';
|
|
9
|
+
|
|
10
|
+
export interface JSResourceReference<TModule> {
|
|
11
|
+
getModuleId(): string;
|
|
12
|
+
getModuleIfRequired(): TModule | null | undefined;
|
|
13
|
+
load(): Promise<TModule>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Represents a single operation used to processing and normalize runtime
|
|
18
|
+
* request results.
|
|
19
|
+
*/
|
|
20
|
+
export interface NormalizationOperation {
|
|
21
|
+
readonly kind: 'Operation';
|
|
22
|
+
readonly name: string;
|
|
23
|
+
readonly argumentDefinitions: readonly NormalizationLocalArgumentDefinition[];
|
|
24
|
+
readonly selections: readonly NormalizationSelection[];
|
|
25
|
+
readonly clientAbstractTypes?: {
|
|
26
|
+
readonly [key: string]: readonly string[];
|
|
27
|
+
};
|
|
28
|
+
readonly use_exec_time_resolvers?: boolean;
|
|
29
|
+
readonly exec_time_resolvers_enabled_provider?: ProvidedVariableType;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type NormalizationHandle = NormalizationScalarHandle | NormalizationLinkedHandle;
|
|
33
|
+
|
|
34
|
+
export interface NormalizationLinkedHandle {
|
|
35
|
+
readonly kind: 'LinkedHandle';
|
|
36
|
+
readonly alias?: string | null | undefined;
|
|
37
|
+
readonly name: string;
|
|
38
|
+
readonly args?: readonly NormalizationArgument[] | null | undefined;
|
|
39
|
+
readonly handle: string;
|
|
40
|
+
readonly key: string;
|
|
41
|
+
// NOTE: this property is optional because it's expected to be rarely used
|
|
42
|
+
readonly dynamicKey?: NormalizationArgument | null | undefined;
|
|
43
|
+
readonly filters?: readonly string[] | null | undefined;
|
|
44
|
+
readonly handleArgs?: readonly NormalizationArgument[];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface NormalizationScalarHandle {
|
|
48
|
+
readonly kind: 'ScalarHandle';
|
|
49
|
+
readonly alias?: string | null | undefined;
|
|
50
|
+
readonly name: string;
|
|
51
|
+
readonly args?: readonly NormalizationArgument[] | null | undefined;
|
|
52
|
+
readonly handle: string;
|
|
53
|
+
readonly key: string;
|
|
54
|
+
// NOTE: this property is optional because it's expected to be rarely used
|
|
55
|
+
readonly dynamicKey?: NormalizationArgument | null | undefined;
|
|
56
|
+
readonly filters?: readonly string[] | null | undefined;
|
|
57
|
+
readonly handleArgs?: readonly NormalizationArgument[];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export type NormalizationArgument =
|
|
61
|
+
| NormalizationListValueArgument
|
|
62
|
+
| NormalizationLiteralArgument
|
|
63
|
+
| NormalizationObjectValueArgument
|
|
64
|
+
| NormalizationVariableArgument;
|
|
65
|
+
|
|
66
|
+
export interface NormalizationCondition {
|
|
67
|
+
readonly kind: 'Condition';
|
|
68
|
+
readonly passingValue: boolean;
|
|
69
|
+
readonly condition: string;
|
|
70
|
+
readonly selections: readonly NormalizationSelection[];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface NormalizationClientExtension {
|
|
74
|
+
readonly kind: 'ClientExtension';
|
|
75
|
+
readonly selections: readonly NormalizationSelection[];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export type NormalizationField = NormalizationFlightField | NormalizationScalarField | NormalizationLinkedField;
|
|
79
|
+
|
|
80
|
+
export interface NormalizationInlineFragment {
|
|
81
|
+
readonly kind: 'InlineFragment';
|
|
82
|
+
readonly selections: readonly NormalizationSelection[];
|
|
83
|
+
readonly type: string;
|
|
84
|
+
readonly abstractKey?: string | null | undefined;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface NormalizationFragmentSpread {
|
|
88
|
+
readonly kind: 'FragmentSpread';
|
|
89
|
+
readonly fragment: NormalizationSplitOperation;
|
|
90
|
+
readonly args?: readonly NormalizationArgument[] | null | undefined;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface NormalizationLinkedField {
|
|
94
|
+
readonly kind: 'LinkedField';
|
|
95
|
+
readonly alias?: string | null | undefined;
|
|
96
|
+
readonly name: string;
|
|
97
|
+
readonly storageKey?: string | null | undefined;
|
|
98
|
+
readonly args?: readonly NormalizationArgument[] | null | undefined;
|
|
99
|
+
readonly concreteType?: string | null | undefined;
|
|
100
|
+
readonly plural: boolean;
|
|
101
|
+
readonly selections: readonly NormalizationSelection[];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface NormalizationActorChange {
|
|
105
|
+
readonly kind: 'ActorChange';
|
|
106
|
+
readonly linkedField: NormalizationLinkedField;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface NormalizationModuleImport {
|
|
110
|
+
readonly args?: readonly NormalizationArgument[] | null | undefined;
|
|
111
|
+
readonly kind: 'ModuleImport';
|
|
112
|
+
readonly documentName: string;
|
|
113
|
+
readonly fragmentPropName: string;
|
|
114
|
+
readonly fragmentName: string;
|
|
115
|
+
readonly componentModuleProvider?: () => unknown | Promise<unknown> | JSResourceReference<unknown>;
|
|
116
|
+
readonly operationModuleProvider?: () =>
|
|
117
|
+
| NormalizationRootNode
|
|
118
|
+
| Promise<NormalizationRootNode>
|
|
119
|
+
| JSResourceReference<NormalizationRootNode>;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface NormalizationListValueArgument {
|
|
123
|
+
readonly kind: 'ListValue';
|
|
124
|
+
readonly name: string;
|
|
125
|
+
readonly items: ReadonlyArray<NormalizationArgument | null>;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface NormalizationLiteralArgument {
|
|
129
|
+
readonly kind: 'Literal';
|
|
130
|
+
readonly name: string;
|
|
131
|
+
readonly type?: string | null | undefined;
|
|
132
|
+
readonly value: any;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface NormalizationLocalArgumentDefinition {
|
|
136
|
+
readonly kind: 'LocalArgument';
|
|
137
|
+
readonly name: string;
|
|
138
|
+
readonly defaultValue: any;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export type NormalizationNode =
|
|
142
|
+
| NormalizationClientExtension
|
|
143
|
+
| NormalizationCondition
|
|
144
|
+
| NormalizationDefer
|
|
145
|
+
| NormalizationInlineFragment
|
|
146
|
+
| NormalizationLinkedField
|
|
147
|
+
| NormalizationOperation
|
|
148
|
+
| NormalizationSplitOperation
|
|
149
|
+
| NormalizationStream;
|
|
150
|
+
|
|
151
|
+
export interface NormalizationScalarField {
|
|
152
|
+
readonly kind: 'ScalarField';
|
|
153
|
+
readonly alias?: string | null | undefined;
|
|
154
|
+
readonly name: string;
|
|
155
|
+
readonly args?: readonly NormalizationArgument[] | null | undefined;
|
|
156
|
+
readonly storageKey?: string | null | undefined;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export interface NormalizationFlightField {
|
|
160
|
+
readonly kind: 'FlightField';
|
|
161
|
+
readonly alias?: string | null | undefined;
|
|
162
|
+
readonly name: string;
|
|
163
|
+
readonly args?: readonly NormalizationArgument[] | null | undefined;
|
|
164
|
+
readonly storageKey: string | null | undefined;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export interface NormalizationClientComponent {
|
|
168
|
+
readonly args?: readonly NormalizationArgument[] | null | undefined;
|
|
169
|
+
readonly kind: 'ClientComponent';
|
|
170
|
+
readonly fragment: NormalizationNode;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export interface NormalizationTypeDiscriminator {
|
|
174
|
+
readonly kind: 'TypeDiscriminator';
|
|
175
|
+
readonly abstractKey: string;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export type NormalizationSelection =
|
|
179
|
+
| NormalizationCondition
|
|
180
|
+
| NormalizationClientComponent
|
|
181
|
+
| NormalizationClientExtension
|
|
182
|
+
| NormalizationDefer
|
|
183
|
+
| NormalizationField
|
|
184
|
+
| NormalizationFlightField
|
|
185
|
+
| NormalizationFragmentSpread
|
|
186
|
+
| NormalizationHandle
|
|
187
|
+
| NormalizationInlineFragment
|
|
188
|
+
| NormalizationModuleImport
|
|
189
|
+
| NormalizationStream
|
|
190
|
+
| NormalizationActorChange
|
|
191
|
+
| NormalizationTypeDiscriminator;
|
|
192
|
+
|
|
193
|
+
export interface NormalizationSplitOperation {
|
|
194
|
+
readonly argumentDefinitions?: readonly NormalizationLocalArgumentDefinition[];
|
|
195
|
+
readonly kind: 'SplitOperation';
|
|
196
|
+
readonly name: string;
|
|
197
|
+
readonly metadata: { readonly [key: string]: unknown } | null | undefined;
|
|
198
|
+
readonly selections: readonly NormalizationSelection[];
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export interface NormalizationStream {
|
|
202
|
+
readonly if: string | null;
|
|
203
|
+
readonly kind: 'Stream';
|
|
204
|
+
readonly label: string;
|
|
205
|
+
readonly selections: readonly NormalizationSelection[];
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export interface NormalizationDefer {
|
|
209
|
+
readonly if: string | null;
|
|
210
|
+
readonly kind: 'Defer';
|
|
211
|
+
readonly label: string;
|
|
212
|
+
readonly selections: readonly NormalizationSelection[];
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export interface NormalizationVariableArgument {
|
|
216
|
+
readonly kind: 'Variable';
|
|
217
|
+
readonly name: string;
|
|
218
|
+
readonly type?: string | null | undefined;
|
|
219
|
+
readonly variableName: string;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export interface NormalizationObjectValueArgument {
|
|
223
|
+
readonly kind: 'ObjectValue';
|
|
224
|
+
readonly name: string;
|
|
225
|
+
readonly fields: readonly NormalizationArgument[];
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export type NormalizationSelectableNode =
|
|
229
|
+
| NormalizationDefer
|
|
230
|
+
| NormalizationLinkedField
|
|
231
|
+
| NormalizationOperation
|
|
232
|
+
| NormalizationSplitOperation
|
|
233
|
+
| NormalizationStream;
|
|
234
|
+
|
|
235
|
+
export type NormalizationRootNode = ConcreteRequest | NormalizationSplitOperation;
|