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,86 @@
|
|
|
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 {NormalizationArgument, NormalizationField, NormalizationHandle} from '../util/NormalizationNode';
|
|
9
|
+
import {ReaderArgument, ReaderField} from '../util/ReaderNode';
|
|
10
|
+
import { Variables } from '../util/RelayRuntimeTypes';
|
|
11
|
+
|
|
12
|
+
export interface Arguments {
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Returns the values of field/fragment arguments as an object keyed by argument
|
|
18
|
+
* names. Guaranteed to return a result with stable ordered nested values.
|
|
19
|
+
*/
|
|
20
|
+
export function getArgumentValues(
|
|
21
|
+
args: ReadonlyArray<NormalizationArgument | ReaderArgument>,
|
|
22
|
+
variables: Variables,
|
|
23
|
+
): Arguments;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Given a handle field and variable values, returns a key that can be used to
|
|
27
|
+
* uniquely identify the combination of the handle name and argument values.
|
|
28
|
+
*
|
|
29
|
+
* Note: the word "storage" here refers to the fact this key is primarily used
|
|
30
|
+
* when writing the results of a key in a normalized graph or "store". This
|
|
31
|
+
* name was used in previous implementations of Relay internals and is also
|
|
32
|
+
* used here for consistency.
|
|
33
|
+
*/
|
|
34
|
+
export function getHandleStorageKey(handleField: NormalizationHandle, variables: Variables): string;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Given a field and variable values, returns a key that can be used to
|
|
38
|
+
* uniquely identify the combination of the field name and argument values.
|
|
39
|
+
*
|
|
40
|
+
* Note: the word "storage" here refers to the fact this key is primarily used
|
|
41
|
+
* when writing the results of a key in a normalized graph or "store". This
|
|
42
|
+
* name was used in previous implementations of Relay internals and is also
|
|
43
|
+
* used here for consistency.
|
|
44
|
+
*/
|
|
45
|
+
export function getStorageKey(
|
|
46
|
+
field: NormalizationField | NormalizationHandle | ReaderField,
|
|
47
|
+
variables: Variables,
|
|
48
|
+
): string;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Given a `name` (eg. "foo") and an object representing argument values
|
|
52
|
+
* (eg. `{orberBy: "name", first: 10}`) returns a unique storage key
|
|
53
|
+
* (ie. `foo{"first":10,"orderBy":"name"}`).
|
|
54
|
+
*
|
|
55
|
+
* This differs from getStorageKey which requires a ConcreteNode where arguments
|
|
56
|
+
* are assumed to already be sorted into a stable order.
|
|
57
|
+
*/
|
|
58
|
+
export function getStableStorageKey(name: string, args: Arguments): string;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Given a name and argument values, format a storage key.
|
|
62
|
+
*
|
|
63
|
+
* Arguments and the values within them are expected to be ordered in a stable
|
|
64
|
+
* alphabetical ordering.
|
|
65
|
+
*/
|
|
66
|
+
export function formatStorageKey(name: string, argValues: Arguments): string;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Given Variables and a variable name, return a variable value with
|
|
70
|
+
* all values in a stable order.
|
|
71
|
+
*/
|
|
72
|
+
export function getStableVariableValue(name: string, variables: Variables): unknown;
|
|
73
|
+
|
|
74
|
+
export function getModuleComponentKey(documentName: string): string;
|
|
75
|
+
export function getModuleOperationKey(documentName: string): string;
|
|
76
|
+
|
|
77
|
+
export const FRAGMENTS_KEY: string;
|
|
78
|
+
export const FRAGMENT_OWNER_KEY: string;
|
|
79
|
+
export const FRAGMENT_PROP_NAME_KEY: string;
|
|
80
|
+
export const MODULE_COMPONENT_KEY: string; // alias returned by Reader
|
|
81
|
+
export const ID_KEY: string;
|
|
82
|
+
export const REF_KEY: string;
|
|
83
|
+
export const REFS_KEY: string;
|
|
84
|
+
export const ROOT_ID: string;
|
|
85
|
+
export const ROOT_TYPE: string;
|
|
86
|
+
export const TYPENAME_KEY: string;
|
|
@@ -35,13 +35,14 @@ const {stableCopy} = require('../util/stableCopy');
|
|
|
35
35
|
const invariant = require('invariant');
|
|
36
36
|
|
|
37
37
|
export type Arguments = {
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
readonly FRAGMENT_POINTER_IS_WITHIN_UNMATCHED_TYPE_REFINEMENT?: boolean,
|
|
39
|
+
readonly [string]: unknown,
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
const {VARIABLE, LITERAL, OBJECT_VALUE, LIST_VALUE} = RelayConcreteNode;
|
|
43
43
|
|
|
44
44
|
const ERRORS_KEY: '__errors' = '__errors';
|
|
45
|
+
const FIELD_GRANULAR_NOTIFICATIONS_KEY = '__fieldGranularNotifications';
|
|
45
46
|
const MODULE_COMPONENT_KEY_PREFIX = '__module_component_';
|
|
46
47
|
const MODULE_OPERATION_KEY_PREFIX = '__module_operation_';
|
|
47
48
|
|
|
@@ -50,7 +51,7 @@ const RELAY_READ_TIME_RESOLVER_KEY_PREFIX = '$r:';
|
|
|
50
51
|
function getArgumentValue(
|
|
51
52
|
arg: NormalizationArgument | ReaderArgument,
|
|
52
53
|
variables: Variables,
|
|
53
|
-
):
|
|
54
|
+
): unknown {
|
|
54
55
|
if (arg.kind === VARIABLE) {
|
|
55
56
|
// Variables are provided at runtime and are not guaranteed to be stable.
|
|
56
57
|
return getStableVariableValue(arg.variableName, variables);
|
|
@@ -58,7 +59,7 @@ function getArgumentValue(
|
|
|
58
59
|
// The Relay compiler generates stable ConcreteArgument values.
|
|
59
60
|
return arg.value;
|
|
60
61
|
} else if (arg.kind === OBJECT_VALUE) {
|
|
61
|
-
const value: {[string]:
|
|
62
|
+
const value: {[string]: unknown} = {};
|
|
62
63
|
arg.fields.forEach(field => {
|
|
63
64
|
value[field.name] = getArgumentValue(field, variables);
|
|
64
65
|
});
|
|
@@ -77,13 +78,13 @@ function getArgumentValue(
|
|
|
77
78
|
* names. Guaranteed to return a result with stable ordered nested values.
|
|
78
79
|
*/
|
|
79
80
|
function getArgumentValues(
|
|
80
|
-
args?:
|
|
81
|
+
args?: ?ReadonlyArray<NormalizationArgument | ReaderArgument>,
|
|
81
82
|
variables: Variables,
|
|
82
83
|
isWithinUnmatchedTypeRefinement?: boolean,
|
|
83
84
|
): Arguments {
|
|
84
85
|
const values: {
|
|
85
86
|
FRAGMENT_POINTER_IS_WITHIN_UNMATCHED_TYPE_REFINEMENT?: boolean,
|
|
86
|
-
[string]:
|
|
87
|
+
[string]: unknown,
|
|
87
88
|
} = {};
|
|
88
89
|
if (isWithinUnmatchedTypeRefinement) {
|
|
89
90
|
values[
|
|
@@ -204,7 +205,7 @@ function getArguments(
|
|
|
204
205
|
| NormalizationHandle
|
|
205
206
|
| ReaderField
|
|
206
207
|
| ReaderActorChange,
|
|
207
|
-
):
|
|
208
|
+
): ?ReadonlyArray<NormalizationArgument | ReaderArgument> {
|
|
208
209
|
if (field.kind === 'RelayResolver' || field.kind === 'RelayLiveResolver') {
|
|
209
210
|
if (field.args == null) {
|
|
210
211
|
return field.fragment?.args;
|
|
@@ -256,7 +257,7 @@ function formatStorageKey(name: string, argValues: ?Arguments): string {
|
|
|
256
257
|
* Given Variables and a variable name, return a variable value with
|
|
257
258
|
* all values in a stable order.
|
|
258
259
|
*/
|
|
259
|
-
function getStableVariableValue(name: string, variables: Variables):
|
|
260
|
+
function getStableVariableValue(name: string, variables: Variables): unknown {
|
|
260
261
|
invariant(
|
|
261
262
|
variables.hasOwnProperty(name),
|
|
262
263
|
'getVariableValue(): Undefined variable `%s`.',
|
|
@@ -273,6 +274,10 @@ function getModuleOperationKey(documentName: string): string {
|
|
|
273
274
|
return `${MODULE_OPERATION_KEY_PREFIX}${documentName}`;
|
|
274
275
|
}
|
|
275
276
|
|
|
277
|
+
function getFieldNotificationKey(dataID: string, storageKey: string): string {
|
|
278
|
+
return `__fn:${dataID}:${storageKey}`;
|
|
279
|
+
}
|
|
280
|
+
|
|
276
281
|
/**
|
|
277
282
|
* Constants shared by all implementations of RecordSource/MutableRecordSource/etc.
|
|
278
283
|
*/
|
|
@@ -286,6 +291,7 @@ const RelayStoreUtils = {
|
|
|
286
291
|
FRAGMENT_PROP_NAME_KEY: '__fragmentPropName',
|
|
287
292
|
MODULE_COMPONENT_KEY: '__module_component', // alias returned by Reader
|
|
288
293
|
ERRORS_KEY,
|
|
294
|
+
FIELD_GRANULAR_NOTIFICATIONS_KEY,
|
|
289
295
|
ID_KEY: '__id',
|
|
290
296
|
REF_KEY: '__ref',
|
|
291
297
|
REFS_KEY: '__refs',
|
|
@@ -298,6 +304,7 @@ const RelayStoreUtils = {
|
|
|
298
304
|
RELAY_RESOLVER_SNAPSHOT_KEY: '__resolverSnapshot',
|
|
299
305
|
RELAY_RESOLVER_ERROR_KEY: '__resolverError',
|
|
300
306
|
RELAY_RESOLVER_OUTPUT_TYPE_RECORD_IDS: '__resolverOutputTypeRecordIDs',
|
|
307
|
+
RELAY_RESOLVER_RECORD_TYPENAME: '__RELAY_RESOLVER__',
|
|
301
308
|
RELAY_READ_TIME_RESOLVER_KEY_PREFIX,
|
|
302
309
|
|
|
303
310
|
formatStorageKey,
|
|
@@ -309,6 +316,7 @@ const RelayStoreUtils = {
|
|
|
309
316
|
getStableStorageKey,
|
|
310
317
|
getModuleComponentKey,
|
|
311
318
|
getModuleOperationKey,
|
|
319
|
+
getFieldNotificationKey,
|
|
312
320
|
} as const;
|
|
313
321
|
|
|
314
322
|
module.exports = RelayStoreUtils;
|
|
@@ -32,8 +32,8 @@ export type EvaluationResult<T> = {
|
|
|
32
32
|
error: ?Error,
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
export type ResolverFragmentResult =
|
|
36
|
-
data:
|
|
35
|
+
export type ResolverFragmentResult = Readonly<{
|
|
36
|
+
data: unknown,
|
|
37
37
|
isMissingData: boolean,
|
|
38
38
|
fieldErrors: ?FieldErrors,
|
|
39
39
|
}>;
|
|
@@ -0,0 +1,43 @@
|
|
|
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, FragmentType, KeyType, KeyTypeData, SingularReaderSelector} from './RelayStoreTypes';
|
|
10
|
+
|
|
11
|
+
export interface ResolverContext {
|
|
12
|
+
getDataForResolverFragment: (
|
|
13
|
+
arg0: SingularReaderSelector,
|
|
14
|
+
arg1: FragmentType,
|
|
15
|
+
) => {
|
|
16
|
+
data: unknown;
|
|
17
|
+
isMissingData: boolean;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const RESOLVER_FRAGMENT_MISSING_DATA_SENTINEL: unknown;
|
|
22
|
+
|
|
23
|
+
export function withResolverContext<T>(context: ResolverContext, cb: () => T): T;
|
|
24
|
+
|
|
25
|
+
export function readFragment<TKey extends KeyType>(
|
|
26
|
+
fragmentInput: GraphQLTaggedNode,
|
|
27
|
+
fragmentRef: TKey,
|
|
28
|
+
): KeyTypeData<TKey>;
|
|
29
|
+
|
|
30
|
+
export function readFragment<TKey extends KeyType>(
|
|
31
|
+
fragmentInput: GraphQLTaggedNode,
|
|
32
|
+
fragmentRef: TKey | null,
|
|
33
|
+
): KeyTypeData<TKey> | null;
|
|
34
|
+
|
|
35
|
+
export function readFragment<TKey extends ArrayKeyType>(
|
|
36
|
+
fragmentInput: GraphQLTaggedNode,
|
|
37
|
+
fragmentRef: TKey,
|
|
38
|
+
): ArrayKeyTypeData<TKey>;
|
|
39
|
+
|
|
40
|
+
export function readFragment<TKey extends ArrayKeyType>(
|
|
41
|
+
fragmentInput: GraphQLTaggedNode,
|
|
42
|
+
fragmentRef: TKey | null,
|
|
43
|
+
): ArrayKeyTypeData<TKey> | null;
|
|
@@ -52,34 +52,42 @@ function withResolverContext<T>(context: ResolverContext, cb: () => T): T {
|
|
|
52
52
|
// - array of nullable if the provided ref type is an array of nullable refs
|
|
53
53
|
|
|
54
54
|
declare function readFragment<
|
|
55
|
-
TKey
|
|
55
|
+
TKey extends {
|
|
56
|
+
readonly $data?: unknown,
|
|
57
|
+
readonly $fragmentSpreads: FragmentType,
|
|
58
|
+
...
|
|
59
|
+
},
|
|
56
60
|
>(
|
|
57
61
|
fragmentInput: GraphQLTaggedNode,
|
|
58
62
|
fragmentKey: TKey,
|
|
59
|
-
):
|
|
63
|
+
): NonNullable<TKey['$data']>;
|
|
60
64
|
|
|
61
65
|
declare function readFragment<
|
|
62
|
-
TKey
|
|
66
|
+
TKey extends ?{
|
|
67
|
+
readonly $data?: unknown,
|
|
68
|
+
readonly $fragmentSpreads: FragmentType,
|
|
69
|
+
...
|
|
70
|
+
},
|
|
63
71
|
>(
|
|
64
72
|
fragmentInput: GraphQLTaggedNode,
|
|
65
73
|
fragmentKey: TKey,
|
|
66
74
|
): ?TKey?.['$data'];
|
|
67
75
|
|
|
68
76
|
declare function readFragment<
|
|
69
|
-
TKey
|
|
70
|
-
|
|
71
|
-
|
|
77
|
+
TKey extends ReadonlyArray<{
|
|
78
|
+
readonly $data?: unknown,
|
|
79
|
+
readonly $fragmentSpreads: FragmentType,
|
|
72
80
|
...
|
|
73
81
|
}>,
|
|
74
82
|
>(
|
|
75
83
|
fragmentInput: GraphQLTaggedNode,
|
|
76
84
|
fragmentKey: TKey,
|
|
77
|
-
):
|
|
85
|
+
): NonNullable<TKey[number]['$data']>;
|
|
78
86
|
|
|
79
87
|
declare function readFragment<
|
|
80
|
-
TKey
|
|
81
|
-
|
|
82
|
-
|
|
88
|
+
TKey extends ?ReadonlyArray<{
|
|
89
|
+
readonly $data?: unknown,
|
|
90
|
+
readonly $fragmentSpreads: FragmentType,
|
|
83
91
|
...
|
|
84
92
|
}>,
|
|
85
93
|
>(
|
|
@@ -87,7 +95,7 @@ declare function readFragment<
|
|
|
87
95
|
fragmentKey: TKey,
|
|
88
96
|
): ?TKey?.[number]['$data'];
|
|
89
97
|
|
|
90
|
-
declare function readFragment<TKey
|
|
98
|
+
declare function readFragment<TKey extends FragmentType, TData>(
|
|
91
99
|
fragmentInput: Fragment<TKey, TData>,
|
|
92
100
|
fragmentKey: TKey,
|
|
93
101
|
): TData;
|
|
@@ -95,7 +103,7 @@ declare function readFragment<TKey: FragmentType, TData>(
|
|
|
95
103
|
function readFragment(
|
|
96
104
|
fragmentInput: GraphQLTaggedNode,
|
|
97
105
|
fragmentKey: FragmentType,
|
|
98
|
-
):
|
|
106
|
+
): unknown {
|
|
99
107
|
if (!contextStack.length) {
|
|
100
108
|
throw new Error(
|
|
101
109
|
'readFragment should be called only from within a Relay Resolver function.',
|
|
@@ -127,10 +135,10 @@ function readFragment(
|
|
|
127
135
|
return data;
|
|
128
136
|
}
|
|
129
137
|
|
|
130
|
-
const RESOLVER_FRAGMENT_ERRORED_SENTINEL:
|
|
138
|
+
const RESOLVER_FRAGMENT_ERRORED_SENTINEL: unknown = {};
|
|
131
139
|
|
|
132
140
|
module.exports = {
|
|
141
|
+
RESOLVER_FRAGMENT_ERRORED_SENTINEL,
|
|
133
142
|
readFragment,
|
|
134
143
|
withResolverContext,
|
|
135
|
-
RESOLVER_FRAGMENT_ERRORED_SENTINEL,
|
|
136
144
|
};
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
import type {IEnvironment, RecordSource} from '../store/RelayStoreTypes';
|
|
15
15
|
|
|
16
|
-
type InspectFn = (environment: IEnvironment, dataID?: ?string) =>
|
|
16
|
+
type InspectFn = (environment: IEnvironment, dataID?: ?string) => unknown;
|
|
17
17
|
|
|
18
18
|
let inspect: InspectFn = () => {};
|
|
19
19
|
|
|
@@ -80,9 +80,9 @@ if (__DEV__) {
|
|
|
80
80
|
const isRecord = (o: $FlowFixMe) => o != null && typeof o.__id === 'string';
|
|
81
81
|
|
|
82
82
|
class RecordEntry {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
constructor(key: string, value:
|
|
83
|
+
readonly key: string;
|
|
84
|
+
readonly value: unknown;
|
|
85
|
+
constructor(key: string, value: unknown) {
|
|
86
86
|
this.key = key;
|
|
87
87
|
this.value = value;
|
|
88
88
|
}
|
|
@@ -138,14 +138,13 @@ if (__DEV__) {
|
|
|
138
138
|
const getWrappedRecord = (
|
|
139
139
|
source: RecordSource,
|
|
140
140
|
dataID: string,
|
|
141
|
-
): ?{[string]:
|
|
141
|
+
): ?{[string]: unknown} => {
|
|
142
142
|
const record = source.get(dataID);
|
|
143
143
|
if (record == null) {
|
|
144
|
-
// $FlowFixMe[incompatible-
|
|
144
|
+
// $FlowFixMe[incompatible-type]
|
|
145
145
|
return record;
|
|
146
146
|
}
|
|
147
147
|
return new Proxy(
|
|
148
|
-
// $FlowFixMe: Do not assume that record is an object
|
|
149
148
|
{...record},
|
|
150
149
|
{
|
|
151
150
|
get(target, prop) {
|
|
@@ -159,7 +158,7 @@ if (__DEV__) {
|
|
|
159
158
|
return getWrappedRecord(source, value.__ref);
|
|
160
159
|
}
|
|
161
160
|
if (Array.isArray(value.__refs)) {
|
|
162
|
-
// $FlowFixMe[incompatible-
|
|
161
|
+
// $FlowFixMe[incompatible-type]
|
|
163
162
|
return value.__refs.map((ref: string) =>
|
|
164
163
|
getWrappedRecord(source, ref),
|
|
165
164
|
);
|
|
@@ -0,0 +1,11 @@
|
|
|
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 { DataID } from '../util/RelayRuntimeTypes';
|
|
9
|
+
|
|
10
|
+
export const VIEWER_ID: DataID;
|
|
11
|
+
export const VIEWER_TYPE = 'Viewer';
|
|
@@ -32,7 +32,7 @@ const invariant = require('invariant');
|
|
|
32
32
|
*/
|
|
33
33
|
function cloneRelayHandleSourceField(
|
|
34
34
|
handleField: NormalizationLinkedHandle,
|
|
35
|
-
selections:
|
|
35
|
+
selections: ReadonlyArray<NormalizationSelection>,
|
|
36
36
|
variables: Variables,
|
|
37
37
|
): NormalizationLinkedField {
|
|
38
38
|
const sourceField = selections.find(
|
|
@@ -31,7 +31,7 @@ const invariant = require('invariant');
|
|
|
31
31
|
*/
|
|
32
32
|
function cloneRelayScalarHandleSourceField(
|
|
33
33
|
handleField: NormalizationScalarHandle,
|
|
34
|
-
selections:
|
|
34
|
+
selections: ReadonlyArray<NormalizationSelection>,
|
|
35
35
|
variables: Variables,
|
|
36
36
|
): NormalizationScalarField {
|
|
37
37
|
const sourceField = selections.find(
|
|
@@ -0,0 +1,16 @@
|
|
|
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 {FragmentMap, FragmentSpecResolver, Props, RelayContext} from './RelayStoreTypes';
|
|
9
|
+
|
|
10
|
+
export function createFragmentSpecResolver(
|
|
11
|
+
context: RelayContext,
|
|
12
|
+
containerName: string,
|
|
13
|
+
fragments: FragmentMap,
|
|
14
|
+
props: Props,
|
|
15
|
+
callback?: () => void,
|
|
16
|
+
): FragmentSpecResolver;
|
|
@@ -19,7 +19,7 @@ const invariant = require('invariant');
|
|
|
19
19
|
|
|
20
20
|
// Ideally, we'd just import the type of the react module, but this causes Flow
|
|
21
21
|
// problems.
|
|
22
|
-
type React =
|
|
22
|
+
type React = Readonly<{
|
|
23
23
|
createContext: createContext<RelayContext | null>,
|
|
24
24
|
version: string,
|
|
25
25
|
...
|
|
@@ -18,16 +18,16 @@ const invariant = require('invariant');
|
|
|
18
18
|
|
|
19
19
|
// Ideally, we'd just import the type of the react module, but this causes Flow
|
|
20
20
|
// problems.
|
|
21
|
-
type React =
|
|
22
|
-
createContext: createContext<
|
|
21
|
+
type React = Readonly<{
|
|
22
|
+
createContext: createContext<unknown | null>,
|
|
23
23
|
version: string,
|
|
24
24
|
...
|
|
25
25
|
}>;
|
|
26
26
|
|
|
27
|
-
let relayLoggingContext: ?Context<
|
|
27
|
+
let relayLoggingContext: ?Context<unknown | null>;
|
|
28
28
|
let firstReact: ?React;
|
|
29
29
|
|
|
30
|
-
function createRelayLoggingContext(react: React): Context<
|
|
30
|
+
function createRelayLoggingContext(react: React): Context<unknown | null> {
|
|
31
31
|
if (!relayLoggingContext) {
|
|
32
32
|
relayLoggingContext = react.createContext(null);
|
|
33
33
|
if (__DEV__) {
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
const {VIEWER_ID, VIEWER_TYPE} = require('./ViewerPattern');
|
|
15
15
|
|
|
16
16
|
function defaultGetDataID(
|
|
17
|
-
fieldValue: {
|
|
17
|
+
fieldValue: {readonly [string]: unknown},
|
|
18
18
|
typeName: string,
|
|
19
|
-
):
|
|
19
|
+
): unknown {
|
|
20
20
|
if (typeName === VIEWER_TYPE) {
|
|
21
21
|
return fieldValue.id == null ? VIEWER_ID : fieldValue.id;
|
|
22
22
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
export function isRelayModernEnvironment(environment: any): boolean;
|
|
@@ -19,8 +19,10 @@
|
|
|
19
19
|
* aid in module tree-shaking to avoid requiring all of RelayRuntime just to
|
|
20
20
|
* detect its environment.
|
|
21
21
|
*/
|
|
22
|
-
function isRelayModernEnvironment(environment:
|
|
23
|
-
return Boolean(
|
|
22
|
+
function isRelayModernEnvironment(environment: unknown): boolean {
|
|
23
|
+
return Boolean(
|
|
24
|
+
environment && (environment as any)['@@RelayModernEnvironment'],
|
|
25
|
+
);
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
module.exports = isRelayModernEnvironment;
|