relay-runtime 20.1.0 → 21.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/experimental.js +1 -1
- package/experimental.js.flow +8 -8
- package/handlers/connection/ConnectionHandler.js.flow +5 -5
- package/handlers/connection/ConnectionInterface.js.flow +1 -1
- package/index.js +1 -1
- package/index.js.flow +125 -62
- package/lib/experimental.js +3 -3
- package/lib/index.js +105 -57
- package/lib/multi-actor-environment/ActorIdentifier.js +2 -2
- package/lib/multi-actor-environment/MultiActorEnvironment.js +3 -1
- package/lib/mutations/commitMutation.js +8 -8
- package/lib/mutations/validateMutation.js +4 -4
- package/lib/query/GraphQLTag.js +3 -3
- package/lib/query/fetchQuery.js +15 -3
- package/lib/store/DataChecker.js +38 -4
- package/lib/store/NormalizationEngine.js +373 -0
- package/lib/store/OperationExecutor.js +172 -113
- package/lib/store/RelayConcreteVariables.js +1 -1
- package/lib/store/RelayErrorTrie.js +2 -2
- package/lib/store/RelayExperimentalGraphResponseTransform.js +8 -8
- package/lib/store/RelayModernEnvironment.js +26 -19
- package/lib/store/RelayModernRecord.js +18 -8
- package/lib/store/RelayModernSelector.js +9 -9
- package/lib/store/RelayModernStore.js +152 -43
- package/lib/store/RelayPublishQueue.js +1 -1
- package/lib/store/RelayReader.js +76 -38
- package/lib/store/RelayRecordSource.js +6 -0
- package/lib/store/RelayReferenceMarker.js +2 -1
- package/lib/store/RelayResponseNormalizer.js +88 -55
- package/lib/store/RelayStoreSubscriptions.js +34 -10
- package/lib/store/RelayStoreUtils.js +8 -1
- package/lib/store/ResolverFragments.js +2 -2
- package/lib/store/live-resolvers/LiveResolverCache.js +25 -9
- package/lib/store/observeFragmentExperimental.js +17 -1
- package/lib/store/observeQueryExperimental.js +2 -2
- package/lib/subscription/requestSubscription.js +3 -3
- package/lib/util/RelayError.js +3 -0
- package/lib/util/RelayFeatureFlags.js +6 -2
- package/lib/util/RelayReplaySubject.js +4 -4
- package/lib/util/handlePotentialSnapshotErrors.js +2 -2
- package/lib/util/stableCopy.js +2 -2
- package/llm-docs/api-reference/entrypoint-apis/entrypoint-container.mdx +38 -0
- package/llm-docs/api-reference/entrypoint-apis/load-entrypoint.mdx +77 -0
- package/llm-docs/api-reference/entrypoint-apis/use-entrypoint-loader.mdx +99 -0
- package/llm-docs/api-reference/graphql/graphql-directives.mdx +378 -0
- package/llm-docs/api-reference/hooks/_use-lazy-load-query-extra.mdx +16 -0
- package/llm-docs/api-reference/hooks/load-query.mdx +84 -0
- package/llm-docs/api-reference/hooks/relay-environment-provider.mdx +78 -0
- package/llm-docs/api-reference/hooks/use-client-query.mdx +65 -0
- package/llm-docs/api-reference/hooks/use-fragment.mdx +69 -0
- package/llm-docs/api-reference/hooks/use-lazy-load-query.mdx +62 -0
- package/llm-docs/api-reference/hooks/use-mutation.mdx +94 -0
- package/llm-docs/api-reference/hooks/use-pagination-fragment.mdx +166 -0
- package/llm-docs/api-reference/hooks/use-prefetchable-forward-pagination-fragment.mdx +134 -0
- package/llm-docs/api-reference/hooks/use-preloaded-query.mdx +84 -0
- package/llm-docs/api-reference/hooks/use-query-loader.mdx +95 -0
- package/llm-docs/api-reference/hooks/use-refetchable-fragment.mdx +122 -0
- package/llm-docs/api-reference/hooks/use-relay-environment.mdx +37 -0
- package/llm-docs/api-reference/hooks/use-subscription.mdx +66 -0
- package/llm-docs/api-reference/relay-resolvers/docblock-format.mdx +321 -0
- package/llm-docs/api-reference/relay-resolvers/runtime-functions.mdx +94 -0
- package/llm-docs/api-reference/relay-runtime/commit-mutation.mdx +65 -0
- package/llm-docs/api-reference/relay-runtime/fetch-query.mdx +113 -0
- package/llm-docs/api-reference/relay-runtime/field-logger.mdx +170 -0
- package/llm-docs/api-reference/relay-runtime/observe-fragment.mdx +92 -0
- package/llm-docs/api-reference/relay-runtime/relay-environment.mdx +53 -0
- package/llm-docs/api-reference/relay-runtime/request-subscription.mdx +54 -0
- package/llm-docs/api-reference/relay-runtime/runtime-configuration.mdx +52 -0
- package/llm-docs/api-reference/relay-runtime/store.mdx +734 -0
- package/llm-docs/api-reference/relay-runtime/wait-for-fragment-data.mdx +89 -0
- package/llm-docs/api-reference/types/CacheConfig.mdx +8 -0
- package/llm-docs/api-reference/types/Disposable.mdx +4 -0
- package/llm-docs/api-reference/types/GraphQLSubscriptionConfig.mdx +17 -0
- package/llm-docs/api-reference/types/MutationConfig.mdx +31 -0
- package/llm-docs/api-reference/types/SelectorStoreUpdater.mdx +6 -0
- package/llm-docs/api-reference/types/UploadableMap.mdx +3 -0
- package/llm-docs/community/learning-resources.mdx +64 -0
- package/llm-docs/debugging/declarative-mutation-directives.mdx +34 -0
- package/llm-docs/debugging/disallowed-id-types-error.mdx +43 -0
- package/llm-docs/debugging/inconsistent-typename-error.mdx +47 -0
- package/llm-docs/debugging/relay-devtools.mdx +73 -0
- package/llm-docs/debugging/why-null.mdx +116 -0
- package/llm-docs/editor-support.mdx +55 -0
- package/llm-docs/error-reference/unknown-field.mdx +36 -0
- package/llm-docs/getting-started/babel-plugin.mdx +31 -0
- package/llm-docs/getting-started/compiler-config.mdx +25 -0
- package/llm-docs/getting-started/compiler.mdx +82 -0
- package/llm-docs/getting-started/lint-rules.mdx +87 -0
- package/llm-docs/getting-started/production.mdx +30 -0
- package/llm-docs/getting-started/quick-start.mdx +213 -0
- package/llm-docs/glossary/glossary.mdx +1040 -0
- package/llm-docs/guided-tour/list-data/advanced-pagination.mdx +157 -0
- package/llm-docs/guided-tour/list-data/connections.mdx +81 -0
- package/llm-docs/guided-tour/list-data/pagination.mdx +193 -0
- package/llm-docs/guided-tour/list-data/rendering-connections.mdx +112 -0
- package/llm-docs/guided-tour/list-data/streaming-pagination.mdx +87 -0
- package/llm-docs/guided-tour/managing-data-outside-react/retaining-queries.mdx +51 -0
- package/llm-docs/guided-tour/refetching/refetching-queries-with-different-data.mdx +337 -0
- package/llm-docs/guided-tour/refetching/refreshing-queries.mdx +350 -0
- package/llm-docs/guided-tour/rendering/environment.mdx +59 -0
- package/llm-docs/guided-tour/rendering/error-states.mdx +295 -0
- package/llm-docs/guided-tour/rendering/fragments.mdx +354 -0
- package/llm-docs/guided-tour/rendering/loading-states.mdx +245 -0
- package/llm-docs/guided-tour/rendering/queries.mdx +261 -0
- package/llm-docs/guided-tour/rendering/variables.mdx +233 -0
- package/llm-docs/guided-tour/reusing-cached-data/fetch-policies.mdx +56 -0
- package/llm-docs/guided-tour/reusing-cached-data/filling-in-missing-data.mdx +102 -0
- package/llm-docs/guided-tour/reusing-cached-data/introduction.mdx +22 -0
- package/llm-docs/guided-tour/reusing-cached-data/presence-of-data.mdx +93 -0
- package/llm-docs/guided-tour/reusing-cached-data/rendering-partially-cached-data.mdx +175 -0
- package/llm-docs/guided-tour/reusing-cached-data/staleness-of-data.mdx +116 -0
- package/llm-docs/guided-tour/updating-data/client-only-data.mdx +115 -0
- package/llm-docs/guided-tour/updating-data/graphql-mutations.mdx +334 -0
- package/llm-docs/guided-tour/updating-data/graphql-subscriptions.mdx +279 -0
- package/llm-docs/guided-tour/updating-data/imperatively-modifying-linked-fields.mdx +511 -0
- package/llm-docs/guided-tour/updating-data/imperatively-modifying-store-data-legacy.mdx +142 -0
- package/llm-docs/guided-tour/updating-data/imperatively-modifying-store-data.mdx +275 -0
- package/llm-docs/guided-tour/updating-data/introduction.mdx +25 -0
- package/llm-docs/guided-tour/updating-data/local-data-updates.mdx +71 -0
- package/llm-docs/guided-tour/updating-data/typesafe-updaters-faq.mdx +83 -0
- package/llm-docs/guided-tour/updating-data/updating-connections.mdx +592 -0
- package/llm-docs/guides/alias-directive.mdx +160 -0
- package/llm-docs/guides/catch-directive.mdx +167 -0
- package/llm-docs/guides/client-schema-extensions.mdx +208 -0
- package/llm-docs/guides/codemods.mdx +66 -0
- package/llm-docs/guides/data-driven-dependencies/client-3d.mdx +255 -0
- package/llm-docs/guides/data-driven-dependencies/configuration.mdx +127 -0
- package/llm-docs/guides/data-driven-dependencies/introduction.mdx +39 -0
- package/llm-docs/guides/data-driven-dependencies/server-3d.mdx +664 -0
- package/llm-docs/guides/document-comparison.mdx +106 -0
- package/llm-docs/guides/graphql-server-specification.mdx +453 -0
- package/llm-docs/guides/network-layer.mdx +69 -0
- package/llm-docs/guides/persisted-queries.mdx +328 -0
- package/llm-docs/guides/relay-resolvers/context.mdx +99 -0
- package/llm-docs/guides/relay-resolvers/defining-fields.mdx +151 -0
- package/llm-docs/guides/relay-resolvers/defining-types.mdx +164 -0
- package/llm-docs/guides/relay-resolvers/deprecated.mdx +27 -0
- package/llm-docs/guides/relay-resolvers/derived-fields.mdx +127 -0
- package/llm-docs/guides/relay-resolvers/descriptions.mdx +44 -0
- package/llm-docs/guides/relay-resolvers/enabling.mdx +41 -0
- package/llm-docs/guides/relay-resolvers/errors.mdx +64 -0
- package/llm-docs/guides/relay-resolvers/field-arguments.mdx +63 -0
- package/llm-docs/guides/relay-resolvers/introduction.mdx +62 -0
- package/llm-docs/guides/relay-resolvers/limitations.mdx +30 -0
- package/llm-docs/guides/relay-resolvers/live-fields.mdx +164 -0
- package/llm-docs/guides/relay-resolvers/return-types.mdx +161 -0
- package/llm-docs/guides/relay-resolvers/suspense.mdx +41 -0
- package/llm-docs/guides/required-directive.mdx +240 -0
- package/llm-docs/guides/semantic-nullability.mdx +93 -0
- package/llm-docs/guides/testing-relay-components.mdx +642 -0
- package/llm-docs/guides/testing-relay-with-preloaded-queries.mdx +160 -0
- package/llm-docs/guides/throw-on-field-error-directive.mdx +58 -0
- package/llm-docs/guides/type-emission.mdx +414 -0
- package/llm-docs/home.mdx +32 -0
- package/llm-docs/principles-and-architecture/architecture-overview.mdx +24 -0
- package/llm-docs/principles-and-architecture/compiler-architecture.mdx +106 -0
- package/llm-docs/principles-and-architecture/runtime-architecture.mdx +249 -0
- package/llm-docs/principles-and-architecture/thinking-in-graphql.mdx +309 -0
- package/llm-docs/principles-and-architecture/thinking-in-relay.mdx +104 -0
- package/llm-docs/principles-and-architecture/videos.mdx +50 -0
- package/llm-docs/tutorial/arrays-lists.mdx +126 -0
- package/llm-docs/tutorial/fragments-1.mdx +487 -0
- package/llm-docs/tutorial/graphql.mdx +172 -0
- package/llm-docs/tutorial/interfaces-polymorphism.mdx +161 -0
- package/llm-docs/tutorial/intro.mdx +58 -0
- package/llm-docs/tutorial/mutations-updates.mdx +624 -0
- package/llm-docs/tutorial/organizing-mutations-queries-and-subscriptions.mdx +13 -0
- package/llm-docs/tutorial/queries-1.mdx +267 -0
- package/llm-docs/tutorial/queries-2.mdx +389 -0
- package/llm-docs/tutorial/refetchable-fragments.mdx +352 -0
- package/multi-actor-environment/ActorIdentifier.js.flow +2 -2
- package/multi-actor-environment/ActorSpecificEnvironment.js.flow +7 -7
- package/multi-actor-environment/ActorUtils.js.flow +1 -1
- package/multi-actor-environment/MultiActorEnvironment.js.flow +12 -8
- package/multi-actor-environment/MultiActorEnvironmentTypes.js.flow +3 -3
- package/mutations/RelayDeclarativeMutationConfig.js.flow +9 -9
- package/mutations/RelayRecordProxy.js.flow +8 -11
- package/mutations/RelayRecordSourceMutator.js.flow +4 -4
- package/mutations/RelayRecordSourceProxy.js.flow +4 -4
- package/mutations/RelayRecordSourceSelectorProxy.js.flow +6 -6
- package/mutations/applyOptimisticMutation.js.flow +2 -2
- package/mutations/commitMutation.js.flow +20 -16
- package/mutations/createUpdatableProxy.js.flow +19 -19
- package/mutations/readUpdatableFragment.js.flow +3 -3
- package/mutations/readUpdatableQuery.js.flow +3 -3
- package/mutations/validateMutation.js.flow +7 -7
- package/network/RelayNetworkTypes.js.flow +4 -4
- package/network/RelayObservable.js.flow +16 -14
- package/network/RelayQueryResponseCache.js.flow +3 -3
- package/network/wrapNetworkWithLogObserver.js.flow +1 -1
- package/package.json +2 -1
- package/query/GraphQLTag.js.flow +22 -10
- package/query/fetchQuery.js.flow +23 -10
- package/query/fetchQuery_DEPRECATED.js.flow +1 -1
- package/store/DataChecker.js.flow +43 -9
- package/store/NormalizationEngine.js.flow +779 -0
- package/store/OperationExecutor.js.flow +173 -70
- package/store/RelayConcreteVariables.js.flow +5 -5
- package/store/RelayErrorTrie.js.flow +12 -12
- package/store/RelayExperimentalGraphResponseHandler.js.flow +3 -3
- package/store/RelayExperimentalGraphResponseTransform.js.flow +10 -10
- package/store/RelayModernEnvironment.js.flow +41 -26
- package/store/RelayModernFragmentSpecResolver.js.flow +1 -1
- package/store/RelayModernOperationDescriptor.js.flow +1 -1
- package/store/RelayModernRecord.js.flow +46 -22
- package/store/RelayModernSelector.js.flow +21 -21
- package/store/RelayModernStore.js.flow +219 -58
- package/store/RelayOperationTracker.js.flow +2 -2
- package/store/RelayOptimisticRecordSource.js.flow +2 -2
- package/store/RelayPublishQueue.js.flow +21 -12
- package/store/RelayReader.js.flow +130 -58
- package/store/RelayRecordSource.js.flow +10 -0
- package/store/RelayRecordState.js.flow +1 -1
- package/store/RelayReferenceMarker.js.flow +5 -4
- package/store/RelayResponseNormalizer.js.flow +130 -54
- package/store/RelayStoreSubscriptions.js.flow +52 -8
- package/store/RelayStoreTypes.js.flow +153 -64
- package/store/RelayStoreUtils.js.flow +15 -7
- package/store/ResolverCache.js.flow +2 -2
- package/store/ResolverFragments.js.flow +12 -12
- package/store/StoreInspector.js.flow +6 -7
- package/store/cloneRelayHandleSourceField.js.flow +1 -1
- package/store/cloneRelayScalarHandleSourceField.js.flow +1 -1
- package/store/createRelayContext.js.flow +1 -1
- package/store/createRelayLoggingContext.js.flow +4 -4
- package/store/defaultGetDataID.js.flow +2 -2
- package/store/isRelayModernEnvironment.js.flow +4 -2
- package/store/live-resolvers/LiveResolverCache.js.flow +55 -20
- package/store/live-resolvers/LiveResolverSuspenseSentinel.js.flow +3 -3
- package/store/live-resolvers/getOutputTypeRecordIDs.js.flow +1 -1
- package/store/live-resolvers/isLiveStateValue.js.flow +2 -2
- package/store/live-resolvers/resolverDataInjector.js.flow +8 -5
- package/store/observeFragmentExperimental.js.flow +49 -20
- package/store/observeQueryExperimental.js.flow +5 -5
- package/store/readInlineData.js.flow +4 -4
- package/store/waitForFragmentExperimental.js.flow +3 -3
- package/subscription/requestSubscription.js.flow +7 -7
- package/util/NormalizationNode.js.flow +34 -32
- package/util/ReaderNode.js.flow +32 -30
- package/util/RelayConcreteNode.js.flow +5 -5
- package/util/RelayError.js.flow +4 -1
- package/util/RelayFeatureFlags.js.flow +21 -1
- package/util/RelayProfiler.js.flow +1 -1
- package/util/RelayReplaySubject.js.flow +3 -3
- package/util/RelayRuntimeTypes.js.flow +11 -11
- package/util/createPayloadFor3DField.js.flow +9 -5
- package/util/deepFreeze.js.flow +2 -2
- package/util/getFragmentIdentifier.js.flow +1 -1
- package/util/getPaginationMetadata.js.flow +1 -1
- package/util/getPaginationVariables.js.flow +1 -1
- package/util/getPendingOperationsForFragment.js.flow +2 -2
- package/util/getRefetchMetadata.js.flow +6 -5
- package/util/getValueAtPath.js.flow +3 -3
- package/util/handlePotentialSnapshotErrors.js.flow +5 -5
- package/util/isEmptyObject.js.flow +1 -1
- package/util/isPromise.js.flow +2 -2
- package/util/isScalarAndEqual.js.flow +1 -1
- package/util/recycleNodesInto.js.flow +2 -2
- package/util/registerEnvironmentWithDevTools.js.flow +1 -1
- package/util/shallowFreeze.js.flow +1 -1
- package/util/stableCopy.js.flow +5 -5
- package/util/withProvidedVariables.js.flow +14 -10
|
@@ -64,7 +64,7 @@ class RelayReplaySubject<T> {
|
|
|
64
64
|
sink.next(event.data);
|
|
65
65
|
break;
|
|
66
66
|
default:
|
|
67
|
-
|
|
67
|
+
event.kind as empty;
|
|
68
68
|
invariant(
|
|
69
69
|
false,
|
|
70
70
|
'RelayReplaySubject: Unknown event kind `%s`.',
|
|
@@ -96,8 +96,8 @@ class RelayReplaySubject<T> {
|
|
|
96
96
|
}
|
|
97
97
|
this._complete = true;
|
|
98
98
|
this._events.push({
|
|
99
|
-
kind: 'error',
|
|
100
99
|
error,
|
|
100
|
+
kind: 'error',
|
|
101
101
|
});
|
|
102
102
|
this._sinks.forEach(sink => sink.error(error));
|
|
103
103
|
}
|
|
@@ -107,8 +107,8 @@ class RelayReplaySubject<T> {
|
|
|
107
107
|
return;
|
|
108
108
|
}
|
|
109
109
|
this._events.push({
|
|
110
|
-
kind: 'next',
|
|
111
110
|
data,
|
|
111
|
+
kind: 'next',
|
|
112
112
|
});
|
|
113
113
|
this._sinks.forEach(sink => sink.next(data));
|
|
114
114
|
}
|
|
@@ -40,11 +40,11 @@ export type Variables = {+[string]: $FlowFixMe};
|
|
|
40
40
|
export type OperationType = {
|
|
41
41
|
// TODO(T33395812) Make this an open object type
|
|
42
42
|
+variables: Variables,
|
|
43
|
-
+response:
|
|
43
|
+
+response: unknown,
|
|
44
44
|
+rawResponse?: {...},
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
export type VariablesOf<T
|
|
47
|
+
export type VariablesOf<T extends OperationType> = T['variables'];
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* Settings for how a query response may be cached.
|
|
@@ -68,7 +68,7 @@ export type CacheConfig = {
|
|
|
68
68
|
+onSubscribe?: () => void,
|
|
69
69
|
+onResume?: (pauseTimeMs: number) => void,
|
|
70
70
|
+onPause?: (mqttConnectionIsOk: boolean, internetIsOk: boolean) => void,
|
|
71
|
-
+metadata?: {+[key: string]:
|
|
71
|
+
+metadata?: {+[key: string]: unknown, ...},
|
|
72
72
|
+transactionId?: ?string,
|
|
73
73
|
};
|
|
74
74
|
|
|
@@ -86,7 +86,7 @@ export type RenderPolicy = 'full' | 'partial';
|
|
|
86
86
|
* Return type of graphql tag literals for all operations.
|
|
87
87
|
*/
|
|
88
88
|
declare export opaque type Operation<
|
|
89
|
-
-TVariables
|
|
89
|
+
-TVariables extends Variables,
|
|
90
90
|
+TData,
|
|
91
91
|
TRawResponse,
|
|
92
92
|
>: ConcreteRequest;
|
|
@@ -95,7 +95,7 @@ declare export opaque type Operation<
|
|
|
95
95
|
* Return type of graphql tag literals for updatable queries.
|
|
96
96
|
*/
|
|
97
97
|
declare export opaque type UpdatableQuery<
|
|
98
|
-
-TVariables
|
|
98
|
+
-TVariables extends Variables,
|
|
99
99
|
+TData,
|
|
100
100
|
>: ConcreteUpdatableQuery;
|
|
101
101
|
|
|
@@ -111,7 +111,7 @@ declare export opaque type UpdatableFragment<
|
|
|
111
111
|
* Return type of graphql tag literals for queries.
|
|
112
112
|
*/
|
|
113
113
|
declare export opaque type Query<
|
|
114
|
-
-TVariables
|
|
114
|
+
-TVariables extends Variables,
|
|
115
115
|
+TData,
|
|
116
116
|
TRawResponse = void,
|
|
117
117
|
>: Operation<TVariables, TData, TRawResponse>;
|
|
@@ -120,7 +120,7 @@ declare export opaque type Query<
|
|
|
120
120
|
* Return type of graphql tag literals for client-only queries.
|
|
121
121
|
*/
|
|
122
122
|
declare export opaque type ClientQuery<
|
|
123
|
-
-TVariables
|
|
123
|
+
-TVariables extends Variables,
|
|
124
124
|
+TData,
|
|
125
125
|
TRawResponse = void,
|
|
126
126
|
>: ClientRequest;
|
|
@@ -129,7 +129,7 @@ declare export opaque type ClientQuery<
|
|
|
129
129
|
* Return type of graphql tag literals for mutations.
|
|
130
130
|
*/
|
|
131
131
|
declare export opaque type Mutation<
|
|
132
|
-
-TVariables
|
|
132
|
+
-TVariables extends Variables,
|
|
133
133
|
+TData,
|
|
134
134
|
TRawResponse = {...},
|
|
135
135
|
>: Operation<TVariables, TData, TRawResponse>;
|
|
@@ -141,7 +141,7 @@ declare export opaque type Mutation<
|
|
|
141
141
|
* `RelayObservable`'s `Subscription` type.
|
|
142
142
|
*/
|
|
143
143
|
declare export opaque type GraphQLSubscription<
|
|
144
|
-
-TVariables
|
|
144
|
+
-TVariables extends Variables,
|
|
145
145
|
+TData,
|
|
146
146
|
TRawResponse = void,
|
|
147
147
|
>: Operation<TVariables, TData, TRawResponse>;
|
|
@@ -166,7 +166,7 @@ declare export opaque type Fragment<TFragmentType, +TData>: ReaderFragment;
|
|
|
166
166
|
declare export opaque type RefetchableFragment<
|
|
167
167
|
TFragmentType,
|
|
168
168
|
+TData,
|
|
169
|
-
TVariables
|
|
169
|
+
TVariables extends Variables,
|
|
170
170
|
>: Fragment<TFragmentType, TData>;
|
|
171
171
|
|
|
172
172
|
/**
|
|
@@ -177,5 +177,5 @@ declare export opaque type PrefetchableRefetchableFragment<
|
|
|
177
177
|
TFragmentType,
|
|
178
178
|
+TData,
|
|
179
179
|
+TEdgeData,
|
|
180
|
-
TVariables
|
|
180
|
+
TVariables extends Variables,
|
|
181
181
|
>: Fragment<TFragmentType, TData>;
|
|
@@ -21,15 +21,19 @@ const {
|
|
|
21
21
|
|
|
22
22
|
export opaque type Local3DPayload<
|
|
23
23
|
// eslint-disable-next-line no-unused-vars
|
|
24
|
-
+DocumentName
|
|
25
|
-
+Response
|
|
24
|
+
+DocumentName extends string,
|
|
25
|
+
+Response extends {...},
|
|
26
26
|
> = Response;
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
function createPayloadFor3DField<
|
|
29
|
+
// $FlowFixMe[unsupported-variance-annotation]
|
|
30
|
+
+DocumentName extends string,
|
|
31
|
+
// $FlowFixMe[unsupported-variance-annotation]
|
|
32
|
+
+Response extends {...},
|
|
33
|
+
>(
|
|
30
34
|
name: DocumentName,
|
|
31
35
|
operation: JSResourceReference<NormalizationSplitOperation>,
|
|
32
|
-
component: JSResourceReference<
|
|
36
|
+
component: JSResourceReference<unknown>,
|
|
33
37
|
response: Response,
|
|
34
38
|
): Local3DPayload<DocumentName, Response> {
|
|
35
39
|
const data = {
|
package/util/deepFreeze.js.flow
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* For convenience, and for consistency with the behavior of `Object.freeze`,
|
|
18
18
|
* returns the now-frozen original object.
|
|
19
19
|
*/
|
|
20
|
-
function deepFreeze<T
|
|
20
|
+
function deepFreeze<T extends {...}>(object: T): T {
|
|
21
21
|
if (!shouldBeFrozen(object)) {
|
|
22
22
|
return object;
|
|
23
23
|
}
|
|
@@ -35,7 +35,7 @@ function deepFreeze<T: {...}>(object: T): T {
|
|
|
35
35
|
return object;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
function shouldBeFrozen(value:
|
|
38
|
+
function shouldBeFrozen(value: unknown): boolean {
|
|
39
39
|
// Only freeze plain JS arrays and objects
|
|
40
40
|
return (
|
|
41
41
|
value != null &&
|
|
@@ -25,7 +25,7 @@ const {intern} = require('./StringInterner');
|
|
|
25
25
|
|
|
26
26
|
function getFragmentIdentifier(
|
|
27
27
|
fragmentNode: ReaderFragment,
|
|
28
|
-
fragmentRef:
|
|
28
|
+
fragmentRef: unknown,
|
|
29
29
|
): string {
|
|
30
30
|
const selector = getSelector(fragmentNode, fragmentRef);
|
|
31
31
|
const fragmentOwnerIdentifier =
|
|
@@ -21,7 +21,7 @@ function getPaginationMetadata(
|
|
|
21
21
|
fragmentNode: ReaderFragment,
|
|
22
22
|
componentDisplayName: string,
|
|
23
23
|
): {
|
|
24
|
-
connectionPathInFragmentData:
|
|
24
|
+
connectionPathInFragmentData: ReadonlyArray<string | number>,
|
|
25
25
|
identifierField: ?string,
|
|
26
26
|
paginationRequest: ConcreteRequest,
|
|
27
27
|
paginationMetadata: ReaderPaginationMetadata,
|
|
@@ -26,7 +26,7 @@ function getPaginationVariables(
|
|
|
26
26
|
baseVariables: Variables,
|
|
27
27
|
extraVariables: Variables,
|
|
28
28
|
paginationMetadata: ReaderPaginationMetadata,
|
|
29
|
-
): {[string]:
|
|
29
|
+
): {[string]: unknown, ...} {
|
|
30
30
|
const {backward: backwardMetadata, forward: forwardMetadata} =
|
|
31
31
|
paginationMetadata;
|
|
32
32
|
|
|
@@ -22,9 +22,9 @@ function getPendingOperationsForFragment(
|
|
|
22
22
|
fragmentOwner: RequestDescriptor,
|
|
23
23
|
): {
|
|
24
24
|
promise: Promise<void>,
|
|
25
|
-
pendingOperations:
|
|
25
|
+
pendingOperations: ReadonlyArray<RequestDescriptor>,
|
|
26
26
|
} | null {
|
|
27
|
-
let pendingOperations:
|
|
27
|
+
let pendingOperations: ReadonlyArray<RequestDescriptor> = [];
|
|
28
28
|
let promise = getPromiseForActiveRequest(environment, fragmentOwner);
|
|
29
29
|
|
|
30
30
|
if (promise != null) {
|
|
@@ -24,7 +24,7 @@ function getRefetchMetadata(
|
|
|
24
24
|
fragmentNode: ReaderFragment,
|
|
25
25
|
componentDisplayName: string,
|
|
26
26
|
): {
|
|
27
|
-
fragmentRefPathInResponse:
|
|
27
|
+
fragmentRefPathInResponse: ReadonlyArray<string | number>,
|
|
28
28
|
identifierInfo: ?RefetchableIdentifierInfo,
|
|
29
29
|
refetchableRequest: ConcreteRequest,
|
|
30
30
|
refetchMetadata: ReaderRefetchMetadata,
|
|
@@ -50,10 +50,11 @@ function getRefetchMetadata(
|
|
|
50
50
|
);
|
|
51
51
|
|
|
52
52
|
// handle both commonjs and es modules
|
|
53
|
-
const refetchableRequest: ConcreteRequest | string =
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
const refetchableRequest: ConcreteRequest | string = (
|
|
54
|
+
refetchMetadata as $FlowFixMe
|
|
55
|
+
).operation.default
|
|
56
|
+
? (refetchMetadata as $FlowFixMe).operation.default
|
|
57
|
+
: refetchMetadata.operation;
|
|
57
58
|
const fragmentRefPathInResponse = refetchMetadata.fragmentPathInResult;
|
|
58
59
|
invariant(
|
|
59
60
|
typeof refetchableRequest !== 'string',
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
const invariant = require('invariant');
|
|
15
15
|
|
|
16
16
|
function getValueAtPath(
|
|
17
|
-
data:
|
|
18
|
-
path:
|
|
19
|
-
):
|
|
17
|
+
data: unknown,
|
|
18
|
+
path: ReadonlyArray<string | number>,
|
|
19
|
+
): unknown {
|
|
20
20
|
let result = data;
|
|
21
21
|
for (const key of path) {
|
|
22
22
|
if (result == null) {
|
|
@@ -22,7 +22,7 @@ const invariant = require('invariant');
|
|
|
22
22
|
function handleFieldErrors(
|
|
23
23
|
environment: IEnvironment,
|
|
24
24
|
fieldErrors: FieldErrors,
|
|
25
|
-
loggingContext:
|
|
25
|
+
loggingContext: unknown | void,
|
|
26
26
|
) {
|
|
27
27
|
for (const fieldError of fieldErrors) {
|
|
28
28
|
// First we log all events. Note that the logger may opt to throw its own
|
|
@@ -67,7 +67,7 @@ function handleFieldErrors(
|
|
|
67
67
|
// can't assert this via types.
|
|
68
68
|
break;
|
|
69
69
|
default:
|
|
70
|
-
|
|
70
|
+
fieldError.kind as empty;
|
|
71
71
|
invariant(false, 'Relay: Unexpected event kind: %s', fieldError.kind);
|
|
72
72
|
}
|
|
73
73
|
}
|
|
@@ -86,7 +86,7 @@ function eventShouldThrow(event: FieldError): boolean {
|
|
|
86
86
|
case 'missing_expected_data.log':
|
|
87
87
|
return false;
|
|
88
88
|
default:
|
|
89
|
-
|
|
89
|
+
event.kind as empty;
|
|
90
90
|
throw new Error('Relay: Unexpected event kind');
|
|
91
91
|
}
|
|
92
92
|
}
|
|
@@ -94,7 +94,7 @@ function eventShouldThrow(event: FieldError): boolean {
|
|
|
94
94
|
function handlePotentialSnapshotErrors(
|
|
95
95
|
environment: IEnvironment,
|
|
96
96
|
fieldErrors: ?FieldErrors,
|
|
97
|
-
loggingContext:
|
|
97
|
+
loggingContext: unknown | void,
|
|
98
98
|
) {
|
|
99
99
|
/**
|
|
100
100
|
* Inside handleFieldErrors, we check for throwOnFieldError - but this fn logs the error anyway by default
|
|
@@ -106,6 +106,6 @@ function handlePotentialSnapshotErrors(
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
module.exports = {
|
|
109
|
-
handlePotentialSnapshotErrors,
|
|
110
109
|
eventShouldThrow,
|
|
110
|
+
handlePotentialSnapshotErrors,
|
|
111
111
|
};
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
|
15
15
|
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
16
16
|
|
|
17
|
-
function isEmptyObject(obj: {+[key: string]:
|
|
17
|
+
function isEmptyObject(obj: {+[key: string]: unknown}): boolean {
|
|
18
18
|
for (const key in obj) {
|
|
19
19
|
if (hasOwnProperty.call(obj, key)) {
|
|
20
20
|
return false;
|
package/util/isPromise.js.flow
CHANGED
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
declare function isPromise<T>(p:
|
|
14
|
+
declare function isPromise<T>(p: unknown): p is Promise<T>;
|
|
15
15
|
|
|
16
|
-
function isPromise(p:
|
|
16
|
+
function isPromise(p: unknown) {
|
|
17
17
|
return p != null && typeof p === 'object' && typeof p.then === 'function';
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* - returns false for complex values, since these cannot be cheaply tested for
|
|
19
19
|
* equality (use `areEquals` instead)
|
|
20
20
|
*/
|
|
21
|
-
function isScalarAndEqual(valueA:
|
|
21
|
+
function isScalarAndEqual(valueA: unknown, valueB: unknown): boolean {
|
|
22
22
|
return valueA === valueB && (valueA === null || typeof valueA !== 'object');
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -38,8 +38,8 @@ function recycleNodesIntoImpl<T>(
|
|
|
38
38
|
let canRecycle = false;
|
|
39
39
|
|
|
40
40
|
// Assign local variables to preserve Flow type refinement.
|
|
41
|
-
const prevArray: ?Array<
|
|
42
|
-
const nextArray: ?Array<
|
|
41
|
+
const prevArray: ?Array<unknown> = Array.isArray(prevData) ? prevData : null;
|
|
42
|
+
const nextArray: ?Array<unknown> = Array.isArray(nextData) ? nextData : null;
|
|
43
43
|
if (prevArray && nextArray) {
|
|
44
44
|
const canMutateNext = canMutate && !Object.isFrozen(nextArray);
|
|
45
45
|
canRecycle =
|
|
@@ -28,7 +28,7 @@ function registerEnvironmentWithDevTools(environment: IEnvironment): void {
|
|
|
28
28
|
// $FlowFixMe[incompatible-use] D61394600
|
|
29
29
|
const devToolsHook = _global && _global.__RELAY_DEVTOOLS_HOOK__;
|
|
30
30
|
if (devToolsHook) {
|
|
31
|
-
// $FlowFixMe[incompatible-
|
|
31
|
+
// $FlowFixMe[incompatible-type] D61394600
|
|
32
32
|
devToolsHook.registerEnvironment(environment);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
14
|
// Shallow freeze to prevent Relay from mutating the value in recycleNodesInto or deepFreezing the value
|
|
15
|
-
module.exports = function shallowFreeze(value:
|
|
15
|
+
module.exports = function shallowFreeze(value: unknown) {
|
|
16
16
|
if (
|
|
17
17
|
typeof value === 'object' &&
|
|
18
18
|
value != null &&
|
package/util/stableCopy.js.flow
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* keys sorted such that equivalent values would have identical JSON.stringify
|
|
17
17
|
* results.
|
|
18
18
|
*/
|
|
19
|
-
function stableCopy<T
|
|
19
|
+
function stableCopy<T extends unknown>(value: T): T {
|
|
20
20
|
if (!value || typeof value !== 'object') {
|
|
21
21
|
return value;
|
|
22
22
|
}
|
|
@@ -24,17 +24,17 @@ function stableCopy<T: mixed>(value: T): T {
|
|
|
24
24
|
return value.map(stableCopy);
|
|
25
25
|
}
|
|
26
26
|
const keys = Object.keys(value).sort();
|
|
27
|
-
const stable: {[string]:
|
|
27
|
+
const stable: {[string]: unknown} = {};
|
|
28
28
|
for (let i = 0; i < keys.length; i++) {
|
|
29
29
|
stable[keys[i]] = stableCopy(value[keys[i]]);
|
|
30
30
|
}
|
|
31
|
-
return
|
|
31
|
+
return stable as any;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
// Detect if a data structure contains cycles. The logic here mirrors
|
|
35
35
|
// `stableCopy` above and is intended to detect cycles early before they get
|
|
36
36
|
// passed to `stableCopy` which would result in a stack overflow.
|
|
37
|
-
function hasCycle(value:
|
|
37
|
+
function hasCycle(value: unknown, parents: Set<unknown> = new Set()): boolean {
|
|
38
38
|
// $FlowFixMe[sketchy-null-mixed]
|
|
39
39
|
if (!value || typeof value !== 'object') {
|
|
40
40
|
return false;
|
|
@@ -52,6 +52,6 @@ function hasCycle(value: mixed, parents: Set<mixed> = new Set()): boolean {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
module.exports = {
|
|
55
|
-
stableCopy,
|
|
56
55
|
hasCycle,
|
|
56
|
+
stableCopy,
|
|
57
57
|
};
|
|
@@ -19,17 +19,19 @@ const warning = require('warning');
|
|
|
19
19
|
|
|
20
20
|
const WEAKMAP_SUPPORTED = typeof WeakMap === 'function';
|
|
21
21
|
let debugCache:
|
|
22
|
-
| Map<
|
|
23
|
-
| Map<() =>
|
|
24
|
-
| WeakMap<interface {} |
|
|
25
|
-
| WeakMap<() =>
|
|
22
|
+
| Map<unknown, unknown>
|
|
23
|
+
| Map<() => unknown, unknown>
|
|
24
|
+
| WeakMap<interface {} | ReadonlyArray<unknown>, unknown>
|
|
25
|
+
| WeakMap<() => unknown, unknown> = WEAKMAP_SUPPORTED
|
|
26
|
+
? new WeakMap()
|
|
27
|
+
: new Map();
|
|
26
28
|
|
|
27
29
|
function withProvidedVariables(
|
|
28
30
|
userSuppliedVariables: Variables,
|
|
29
31
|
providedVariables: ?ProvidedVariablesType,
|
|
30
32
|
): Variables {
|
|
31
33
|
if (providedVariables != null) {
|
|
32
|
-
const operationVariables: {[string]:
|
|
34
|
+
const operationVariables: {[string]: unknown} = {};
|
|
33
35
|
// $FlowFixMe[unsafe-object-assign]
|
|
34
36
|
Object.assign(operationVariables, userSuppliedVariables);
|
|
35
37
|
Object.keys(providedVariables).forEach((varName: string) => {
|
|
@@ -64,10 +66,12 @@ function withProvidedVariables(
|
|
|
64
66
|
}
|
|
65
67
|
}
|
|
66
68
|
|
|
67
|
-
withProvidedVariables.tests_only_resetDebugCache = (
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
withProvidedVariables.tests_only_resetDebugCache = (
|
|
70
|
+
__DEV__
|
|
71
|
+
? () => {
|
|
72
|
+
debugCache = WEAKMAP_SUPPORTED ? new WeakMap() : new Map();
|
|
73
|
+
}
|
|
74
|
+
: undefined
|
|
75
|
+
) as void | (() => void);
|
|
72
76
|
|
|
73
77
|
module.exports = withProvidedVariables;
|