relay-runtime 21.0.0 → 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.
Files changed (107) hide show
  1. package/experimental.d.ts +34 -0
  2. package/experimental.js +1 -1
  3. package/experimental.js.flow +4 -4
  4. package/handlers/RelayDefaultHandlerProvider.d.ts +12 -0
  5. package/handlers/connection/ConnectionHandler.d.ts +51 -0
  6. package/handlers/connection/ConnectionInterface.d.ts +40 -0
  7. package/handlers/connection/MutationHandlers.d.ts +17 -0
  8. package/index.d.ts +274 -0
  9. package/index.js +1 -1
  10. package/llm-docs/api-reference/relay-runtime/fetch-query.mdx +5 -0
  11. package/llm-docs/getting-started/compiler.mdx +19 -3
  12. package/llm-docs/getting-started/quick-start.mdx +15 -12
  13. package/llm-docs/guides/codemods.mdx +14 -1
  14. package/multi-actor-environment/ActorIdentifier.d.ts +17 -0
  15. package/multi-actor-environment/ActorSpecificEnvironment.js.flow +9 -9
  16. package/multi-actor-environment/MultiActorEnvironment.d.ts +123 -0
  17. package/multi-actor-environment/MultiActorEnvironment.js.flow +22 -18
  18. package/multi-actor-environment/MultiActorEnvironmentTypes.d.ts +225 -0
  19. package/multi-actor-environment/MultiActorEnvironmentTypes.js.flow +3 -3
  20. package/multi-actor-environment/index.d.ts +14 -0
  21. package/multi-actor-environment.d.ts +8 -0
  22. package/mutations/RelayDeclarativeMutationConfig.d.ts +70 -0
  23. package/mutations/applyOptimisticMutation.d.ts +25 -0
  24. package/mutations/commitLocalUpdate.d.ts +10 -0
  25. package/mutations/commitMutation.d.ts +48 -0
  26. package/mutations/commitMutation.js.flow +1 -1
  27. package/network/RelayNetwork.d.ts +12 -0
  28. package/network/RelayNetworkTypes.d.ts +145 -0
  29. package/network/RelayNetworkTypes.js.flow +15 -15
  30. package/network/RelayObservable.d.ts +197 -0
  31. package/network/RelayObservable.js.flow +21 -21
  32. package/network/RelayQueryResponseCache.d.ts +16 -0
  33. package/package.json +1 -1
  34. package/query/GraphQLTag.d.ts +45 -0
  35. package/query/fetchQuery.d.ts +21 -0
  36. package/query/fetchQueryInternal.d.ts +26 -0
  37. package/query/fetchQueryInternal.js.flow +4 -4
  38. package/query/fetchQuery_DEPRECATED.d.ts +17 -0
  39. package/store/ClientID.d.ts +14 -0
  40. package/store/DataChecker.js.flow +8 -6
  41. package/store/NormalizationEngine.js.flow +4 -1
  42. package/store/OperationExecutor.d.ts +51 -0
  43. package/store/OperationExecutor.js.flow +33 -30
  44. package/store/RelayModernEnvironment.d.ts +97 -0
  45. package/store/RelayModernEnvironment.js.flow +21 -21
  46. package/store/RelayModernOperationDescriptor.d.ts +28 -0
  47. package/store/RelayModernRecord.d.ts +92 -0
  48. package/store/RelayModernSelector.d.ts +123 -0
  49. package/store/RelayModernStore.d.ts +57 -0
  50. package/store/RelayOperationTracker.d.ts +29 -0
  51. package/store/RelayPublishQueue.js.flow +8 -8
  52. package/store/RelayRecordSource.d.ts +26 -0
  53. package/store/RelayRecordState.d.ts +28 -0
  54. package/store/RelayResponseNormalizer.d.ts +28 -0
  55. package/store/RelayResponseNormalizer.js.flow +8 -8
  56. package/store/RelayStoreTypes.d.ts +1327 -0
  57. package/store/RelayStoreTypes.js.flow +284 -280
  58. package/store/RelayStoreUtils.d.ts +86 -0
  59. package/store/RelayStoreUtils.js.flow +2 -2
  60. package/store/ResolverFragments.d.ts +43 -0
  61. package/store/ResolverFragments.js.flow +14 -6
  62. package/store/StoreInspector.js.flow +2 -2
  63. package/store/ViewerPattern.d.ts +11 -0
  64. package/store/createFragmentSpecResolver.d.ts +16 -0
  65. package/store/defaultGetDataID.js.flow +1 -1
  66. package/store/isRelayModernEnvironment.d.ts +8 -0
  67. package/store/live-resolvers/LiveResolverCache.js.flow +1 -1
  68. package/store/live-resolvers/resolverDataInjector.d.ts +27 -0
  69. package/store/observeFragmentExperimental.d.ts +46 -0
  70. package/store/observeFragmentExperimental.js.flow +1 -1
  71. package/store/observeQueryExperimental.d.ts +30 -0
  72. package/store/readInlineData.d.ts +19 -0
  73. package/store/readInlineData.js.flow +1 -1
  74. package/store/waitForFragmentExperimental.d.ts +49 -0
  75. package/subscription/requestSubscription.d.ts +27 -0
  76. package/subscription/requestSubscription.js.flow +3 -3
  77. package/util/JSResourceTypes.flow.js.flow +4 -4
  78. package/util/NormalizationNode.d.ts +235 -0
  79. package/util/NormalizationNode.js.flow +124 -122
  80. package/util/ReaderNode.d.ts +264 -0
  81. package/util/ReaderNode.js.flow +152 -149
  82. package/util/RelayConcreteNode.d.ts +120 -0
  83. package/util/RelayConcreteNode.js.flow +31 -31
  84. package/util/RelayError.d.ts +13 -0
  85. package/util/RelayFeatureFlags.d.ts +40 -0
  86. package/util/RelayProfiler.d.ts +121 -0
  87. package/util/RelayReplaySubject.d.ts +25 -0
  88. package/util/RelayRuntimeTypes.d.ts +59 -0
  89. package/util/RelayRuntimeTypes.js.flow +33 -30
  90. package/util/createPayloadFor3DField.d.ts +17 -0
  91. package/util/createPayloadFor3DField.js.flow +4 -4
  92. package/util/deepFreeze.d.ts +8 -0
  93. package/util/getFragmentIdentifier.d.ts +10 -0
  94. package/util/getPaginationMetadata.d.ts +20 -0
  95. package/util/getPaginationVariables.d.ts +20 -0
  96. package/util/getPendingOperationsForFragment.d.ts +18 -0
  97. package/util/getRefetchMetadata.d.ts +19 -0
  98. package/util/getRelayHandleKey.d.ts +8 -0
  99. package/util/getRequestIdentifier.d.ts +17 -0
  100. package/util/getValueAtPath.d.ts +8 -0
  101. package/util/handlePotentialSnapshotErrors.d.ts +14 -0
  102. package/util/isEmptyObject.js.flow +1 -1
  103. package/util/isPromise.d.ts +8 -0
  104. package/util/isScalarAndEqual.d.ts +8 -0
  105. package/util/recycleNodesInto.d.ts +8 -0
  106. package/util/stableCopy.d.ts +8 -0
  107. package/util/withProvidedVariables.d.ts +19 -0
@@ -0,0 +1,34 @@
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 { DataID } from './util/RelayRuntimeTypes';
9
+
10
+ export { resolverDataInjector } from './store/live-resolvers/resolverDataInjector';
11
+ export { observeFragment } from './store/observeFragmentExperimental';
12
+ export { observeQuery } from './store/observeQueryExperimental';
13
+ export { waitForFragmentData } from './store/waitForFragmentExperimental';
14
+
15
+ export type IdOf<_A extends string, Typename extends undefined | string = undefined> = Typename extends undefined
16
+ ? { id: DataID }
17
+ : { id: DataID; __typename: Typename };
18
+
19
+ interface ErrorResult<E> {
20
+ ok: false;
21
+ errors: readonly E[];
22
+ }
23
+
24
+ interface OkayResult<T> {
25
+ ok: true;
26
+ value: T;
27
+ }
28
+
29
+ // The type returned by fields annotated with `@catch`
30
+ export type Result<T, E> = OkayResult<T> | ErrorResult<E>;
31
+
32
+ export function isValueResult<T = unknown>(input: Result<T, unknown>): input is OkayResult<T>;
33
+
34
+ export function isErrorResult<E = unknown>(input: Result<unknown, E>): input is ErrorResult<E>;
package/experimental.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v21.0.0
2
+ * Relay v21.0.1
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
@@ -44,13 +44,13 @@ export type IdOf<A extends string, Typename extends void | string = void> = [
44
44
  export type RelayResolverValue<A> = NonNullable<A>;
45
45
 
46
46
  type ErrorResult<Error> = {
47
- +ok: false,
48
- +errors: ReadonlyArray<Error>,
47
+ readonly ok: false,
48
+ readonly errors: ReadonlyArray<Error>,
49
49
  };
50
50
 
51
51
  type OkayResult<T> = {
52
- +ok: true,
53
- +value: T,
52
+ readonly ok: true,
53
+ readonly value: T,
54
54
  };
55
55
 
56
56
  export type Result<T, Error> = OkayResult<T> | ErrorResult<Error>;
@@ -0,0 +1,12 @@
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 { Handler } from '../store/RelayStoreTypes';
9
+
10
+ export type HandlerProvider = (handle: string) => Handler | undefined;
11
+
12
+ export default function RelayDefaultHandlerProvider(handle: string): Handler;
@@ -0,0 +1,51 @@
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 {
9
+ HandleFieldPayload,
10
+ ReadOnlyRecordProxy,
11
+ RecordProxy,
12
+ RecordSourceProxy,
13
+ } from '../../store/RelayStoreTypes';
14
+ import {DataID, Variables} from '../../util/RelayRuntimeTypes';
15
+
16
+ export interface ConnectionMetadata {
17
+ path: readonly string[] | null | undefined;
18
+ direction: string | null | undefined; // 'forward' | 'backward' | 'bidirectional' | null | undefined;
19
+ cursor: string | null | undefined;
20
+ count: string | null | undefined;
21
+ stream?: boolean | undefined;
22
+ }
23
+
24
+ export function buildConnectionEdge(
25
+ store: RecordSourceProxy,
26
+ connection: RecordProxy,
27
+ edge: RecordProxy | null | undefined,
28
+ ): RecordProxy | null | undefined;
29
+
30
+ export function createEdge(
31
+ store: RecordSourceProxy,
32
+ record: RecordProxy,
33
+ node: RecordProxy,
34
+ edgeType: string,
35
+ ): RecordProxy;
36
+
37
+ export function deleteNode(record: RecordProxy, nodeID: DataID): void;
38
+
39
+ export function getConnection(
40
+ record: ReadOnlyRecordProxy,
41
+ key: string,
42
+ filters?: Variables | null,
43
+ ): RecordProxy | null | undefined;
44
+
45
+ export function getConnectionID(recordID: DataID, key: string, filters?: Variables | null): DataID;
46
+
47
+ export function insertEdgeAfter(record: RecordProxy, newEdge: RecordProxy, cursor?: string | null): void;
48
+
49
+ export function insertEdgeBefore(record: RecordProxy, newEdge: RecordProxy, cursor?: string | null): void;
50
+
51
+ export function update(store: RecordSourceProxy, payload: HandleFieldPayload): void;
@@ -0,0 +1,40 @@
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 { DataID } from '../../util/RelayRuntimeTypes';
9
+
10
+ export interface EdgeRecord extends Record<string, unknown> {
11
+ cursor: unknown;
12
+ node: Record<DataID, unknown>;
13
+ }
14
+
15
+ export interface PageInfo {
16
+ endCursor: string | null | undefined;
17
+ hasNextPage: boolean;
18
+ hasPreviousPage: boolean;
19
+ startCursor: string | null | undefined;
20
+ }
21
+
22
+ interface ConnectionConfig {
23
+ CURSOR: string;
24
+ EDGES: string;
25
+ END_CURSOR: string;
26
+ HAS_NEXT_PAGE: string;
27
+ HAS_PREV_PAGE: string;
28
+ NODE: string;
29
+ PAGE_INFO: string;
30
+ PAGE_INFO_TYPE: string;
31
+ START_CURSOR: string;
32
+ }
33
+
34
+ declare const ConnectionInterface: {
35
+ get(): ConnectionConfig;
36
+
37
+ inject(newConfig: ConnectionConfig): void;
38
+ };
39
+
40
+ export default ConnectionInterface;
@@ -0,0 +1,17 @@
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 { Handler } from '../../store/RelayStoreTypes';
9
+
10
+ export const MutationHandlers: {
11
+ DeleteRecordHandler: Handler;
12
+ DeleteEdgeHandler: Handler;
13
+ AppendEdgeHandler: Handler;
14
+ PrependEdgeHandler: Handler;
15
+ AppendNodeHandler: Handler;
16
+ PrependNodeHandler: Handler;
17
+ };
package/index.d.ts ADDED
@@ -0,0 +1,274 @@
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 * as ConnectionHandler from './handlers/connection/ConnectionHandler';
9
+ import ConnectionInterface from './handlers/connection/ConnectionInterface';
10
+ // Extensions
11
+ import RelayDefaultHandlerProvider from './handlers/RelayDefaultHandlerProvider';
12
+ import QueryResponseCache from './network/RelayQueryResponseCache';
13
+ import * as fetchQueryInternal from './query/fetchQueryInternal';
14
+ import * as RelayResolverFragments from './store/ResolverFragments';
15
+ import withProvidedVariables from './util/withProvidedVariables';
16
+
17
+ export { ConnectionInterface };
18
+ export { ConnectionMetadata } from './handlers/connection/ConnectionHandler';
19
+ export { EdgeRecord, PageInfo } from './handlers/connection/ConnectionInterface';
20
+ export { OptimisticMutationConfig } from './mutations/applyOptimisticMutation';
21
+ export { MutationConfig, MutationParameters } from './mutations/commitMutation';
22
+ export {
23
+ DeclarativeMutationConfig,
24
+ MutationTypes,
25
+ RangeBehaviors,
26
+ RangeOperations,
27
+ } from './mutations/RelayDeclarativeMutationConfig';
28
+ export {
29
+ MutationTypes as MutationType,
30
+ RangeOperations as RangeOperation,
31
+ } from './mutations/RelayDeclarativeMutationConfig';
32
+ export {
33
+ ExecuteFunction,
34
+ FetchFunction,
35
+ GraphQLResponse,
36
+ GraphQLResponseWithData,
37
+ GraphQLResponseWithoutData,
38
+ GraphQLSingularResponse,
39
+ LogRequestInfoFunction,
40
+ Network as INetwork,
41
+ PayloadData,
42
+ PayloadError,
43
+ ReactFlightPayloadData,
44
+ ReactFlightPayloadQuery,
45
+ ReactFlightServerTree,
46
+ SubscribeFunction,
47
+ Uploadable,
48
+ UploadableMap,
49
+ } from './network/RelayNetworkTypes';
50
+ export { ObservableFromValue, Observer, Subscribable, Subscription } from './network/RelayObservable';
51
+ export {
52
+ getFragment,
53
+ getInlineDataFragment,
54
+ getNode,
55
+ getPaginationFragment,
56
+ getRefetchableFragment,
57
+ getRequest,
58
+ graphql,
59
+ GraphQLTaggedNode,
60
+ isFragment,
61
+ isInlineDataFragment,
62
+ isRequest,
63
+ } from './query/GraphQLTag';
64
+ export { generateClientID, generateUniqueClientID, isClientID } from './store/ClientID';
65
+ export { TaskScheduler } from './store/OperationExecutor';
66
+ export { RecordState } from './store/RelayRecordState';
67
+ export {
68
+ Environment as IEnvironment,
69
+ FragmentMap,
70
+ FragmentPointer,
71
+ FragmentSpecResolver,
72
+ FragmentType,
73
+ /** @deprecated use FragmentType instead of FragmentReference */
74
+ FragmentType as FragmentReference,
75
+ HandleFieldPayload,
76
+ HasUpdatableSpread,
77
+ InvalidationState,
78
+ LiveState,
79
+ LogEvent,
80
+ LogFunction,
81
+ MissingFieldHandler,
82
+ ModuleImportPointer,
83
+ MutableRecordSource,
84
+ NormalizationSelector,
85
+ OperationAvailability,
86
+ OperationDescriptor,
87
+ OperationLoader,
88
+ OperationTracker,
89
+ OptimisticResponseConfig,
90
+ OptimisticUpdate,
91
+ OptimisticUpdateFunction,
92
+ PluralReaderSelector,
93
+ Props,
94
+ PublishQueue,
95
+ ReactFlightClientResponse,
96
+ ReactFlightPayloadDeserializer,
97
+ ReaderSelector,
98
+ ReadOnlyRecordProxy,
99
+ RecordProxy,
100
+ RecordSourceProxy,
101
+ RecordSourceSelectorProxy,
102
+ RelayContext,
103
+ RelayFieldLogger,
104
+ RequestDescriptor,
105
+ SelectorData,
106
+ SelectorStoreUpdater,
107
+ SingularReaderSelector,
108
+ Snapshot,
109
+ StoreUpdater,
110
+ suspenseSentinel,
111
+ UpdatableFragmentData,
112
+ UpdatableQueryData,
113
+ } from './store/RelayStoreTypes';
114
+ export { GraphQLSubscriptionConfig } from './subscription/requestSubscription';
115
+ export {
116
+ NormalizationArgument,
117
+ NormalizationDefer,
118
+ NormalizationField,
119
+ NormalizationFlightField,
120
+ NormalizationLinkedField,
121
+ NormalizationLinkedHandle,
122
+ NormalizationLocalArgumentDefinition,
123
+ NormalizationModuleImport,
124
+ NormalizationOperation,
125
+ NormalizationRootNode,
126
+ NormalizationScalarField,
127
+ NormalizationSelection,
128
+ NormalizationSplitOperation,
129
+ NormalizationStream,
130
+ NormalizationTypeDiscriminator,
131
+ } from './util/NormalizationNode';
132
+ export {
133
+ ReaderArgument,
134
+ ReaderArgumentDefinition,
135
+ ReaderCondition,
136
+ ReaderField,
137
+ ReaderFlightField,
138
+ ReaderFragment,
139
+ ReaderInlineDataFragment,
140
+ ReaderInlineDataFragmentSpread,
141
+ ReaderInlineFragment,
142
+ ReaderLinkedField,
143
+ ReaderModuleImport,
144
+ ReaderPaginationMetadata,
145
+ ReaderRefetchableFragment,
146
+ ReaderRefetchMetadata,
147
+ ReaderRequiredField,
148
+ ReaderScalarField,
149
+ ReaderSelection,
150
+ RequiredFieldAction,
151
+ } from './util/ReaderNode';
152
+ export {
153
+ ConcreteRequest,
154
+ ConcreteUpdatableQuery,
155
+ GeneratedNode,
156
+ PreloadableConcreteRequest,
157
+ RequestParameters,
158
+ } from './util/RelayConcreteNode';
159
+ export { RelayReplaySubject as ReplaySubject } from './util/RelayReplaySubject';
160
+ export * from './util/RelayRuntimeTypes';
161
+ // Core API
162
+ export { RelayNetwork as Network } from './network/RelayNetwork';
163
+ export { RelayObservable as Observable } from './network/RelayObservable';
164
+ export { default as Environment, EnvironmentConfig } from './store/RelayModernEnvironment';
165
+ export { QueryResponseCache };
166
+ export { RelayModernRecord as Record } from './store/RelayModernRecord';
167
+ export { default as Store } from './store/RelayModernStore';
168
+ export { RelayRecordSource as RecordSource } from './store/RelayRecordSource';
169
+ export { type IdOf, isErrorResult, isValueResult, type Result } from './experimental';
170
+ export { createFragmentSpecResolver } from './store/createFragmentSpecResolver';
171
+ export { readInlineData } from './store/readInlineData';
172
+ export { createOperationDescriptor, createRequestDescriptor } from './store/RelayModernOperationDescriptor';
173
+ export {
174
+ areEqualSelectors,
175
+ createNormalizationSelector,
176
+ createReaderSelector,
177
+ getDataIDsFromFragment,
178
+ getDataIDsFromObject,
179
+ getPluralSelector,
180
+ getSelector,
181
+ getSelectorsFromObject,
182
+ getSingularSelector,
183
+ getVariablesFromFragment,
184
+ getVariablesFromObject,
185
+ getVariablesFromPluralFragment,
186
+ getVariablesFromSingularFragment,
187
+ } from './store/RelayModernSelector';
188
+ export {
189
+ FRAGMENT_OWNER_KEY,
190
+ FRAGMENTS_KEY,
191
+ getModuleComponentKey,
192
+ getModuleOperationKey,
193
+ getStorageKey,
194
+ ID_KEY,
195
+ REF_KEY,
196
+ REFS_KEY,
197
+ ROOT_ID,
198
+ ROOT_TYPE,
199
+ TYPENAME_KEY,
200
+ } from './store/RelayStoreUtils';
201
+ export { readFragment } from './store/ResolverFragments';
202
+ export { RelayDefaultHandlerProvider as DefaultHandlerProvider };
203
+ export declare function getDefaultMissingFieldHandlers(): import('./store/RelayStoreTypes').MissingFieldHandler[];
204
+ export { ConnectionHandler };
205
+ export { MutationHandlers } from './handlers/connection/MutationHandlers';
206
+ export { VIEWER_ID, VIEWER_TYPE } from './store/ViewerPattern';
207
+ // Helpers (can be implemented via the above API)
208
+ export { applyOptimisticMutation } from './mutations/applyOptimisticMutation';
209
+ export { commitLocalUpdate } from './mutations/commitLocalUpdate';
210
+ export { commitMutation } from './mutations/commitMutation';
211
+ export { fetchQuery } from './query/fetchQuery';
212
+ export { fetchQuery_DEPRECATED } from './query/fetchQuery_DEPRECATED';
213
+ export { isRelayModernEnvironment } from './store/isRelayModernEnvironment';
214
+ export { requestSubscription } from './subscription/requestSubscription';
215
+ // Utilities
216
+ export { default as createPayloadFor3DField } from './util/createPayloadFor3DField';
217
+ export { default as getFragmentIdentifier } from './util/getFragmentIdentifier';
218
+ export { default as getPaginationMetadata } from './util/getPaginationMetadata';
219
+ export { default as getPaginationVariables } from './util/getPaginationVariables';
220
+ export { Direction } from './util/getPaginationVariables';
221
+ export { default as getRefetchMetadata } from './util/getRefetchMetadata';
222
+ export { default as getRelayHandleKey } from './util/getRelayHandleKey';
223
+ export { default as getRequestIdentifier } from './util/getRequestIdentifier';
224
+ export { default as getValueAtPath } from './util/getValueAtPath';
225
+ export { default as handlePotentialSnapshotErrors } from './util/handlePotentialSnapshotErrors';
226
+ export declare const PreloadableQueryRegistry: {
227
+ set(key: string, value: import('./util/RelayConcreteNode').ConcreteRequest): void;
228
+ get(key: string): import('./util/RelayConcreteNode').ConcreteRequest | null | undefined;
229
+ onLoad(key: string, callback: (concreteRequest: import('./util/RelayConcreteNode').ConcreteRequest) => void): import('./util/RelayRuntimeTypes').Disposable;
230
+ clear(): void;
231
+ };
232
+ export { RelayProfiler } from './util/RelayProfiler';
233
+ // INTERNAL-ONLY
234
+ export { RelayConcreteNode } from './util/RelayConcreteNode';
235
+ export { default as RelayError } from './util/RelayError';
236
+ export { RelayFeatureFlags } from './util/RelayFeatureFlags';
237
+ export const DEFAULT_HANDLE_KEY = '';
238
+ export { default as deepFreeze } from './util/deepFreeze';
239
+ export { default as getPendingOperationsForFragment } from './util/getPendingOperationsForFragment';
240
+ export { default as isPromise } from './util/isPromise';
241
+ export { default as isScalarAndEqual } from './util/isScalarAndEqual';
242
+ export { default as recycleNodesInto } from './util/recycleNodesInto';
243
+ export { default as stableCopy } from './util/stableCopy';
244
+
245
+ interface Internal {
246
+ fetchQuery: typeof fetchQueryInternal.fetchQuery;
247
+ fetchQueryDeduped: typeof fetchQueryInternal.fetchQueryDeduped;
248
+ getPromiseForActiveRequest: typeof fetchQueryInternal.getPromiseForActiveRequest;
249
+ getObservableForActiveRequest: typeof fetchQueryInternal.getObservableForActiveRequest;
250
+ ResolverFragments: typeof RelayResolverFragments;
251
+ withProvidedVariables: typeof withProvidedVariables;
252
+ }
253
+
254
+ export const __internal: Internal;
255
+
256
+ /**
257
+ * relay-compiler-language-typescript support for fragment references
258
+ */
259
+
260
+ export interface _RefType<Ref extends string> {
261
+ ' $fragmentType': Ref;
262
+ }
263
+
264
+ export interface _FragmentRefs<Refs extends string> {
265
+ ' $fragmentSpreads': FragmentRefs<Refs>;
266
+ }
267
+
268
+ // This is used in the actual artifacts to define the various fragment references a container holds.
269
+ export type FragmentRefs<Refs extends string> = {
270
+ [ref in Refs]: true;
271
+ };
272
+
273
+ // This is a utility type for converting from a data type to a fragment reference that will resolve to that data type.
274
+ export type FragmentRef<Fragment> = Fragment extends _RefType<infer U> ? _FragmentRefs<U> : never;
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v21.0.0
2
+ * Relay v21.0.1
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
@@ -48,6 +48,11 @@ fetchQuery(
48
48
  * `options`: *_[Optional]_* options object
49
49
  * `networkCacheConfig`: *_[Optional]_ *Object containing cache config options
50
50
  * `force`: Boolean value. If true, will bypass the network response cache. Defaults to true.
51
+ * `fetchPolicy`: *_[Optional]_* Determines whether `fetchQuery` should reuse data that is already available in the local Relay store. Must be one of the following values:
52
+ * `"network-only"`: *(default)* Always issue a network request, regardless of what is in the store.
53
+ * `"store-or-network"`: Reuse data from the store if the full query is available locally; otherwise, issue a network request.
54
+
55
+ The `"store-and-network"` and `"store-only"` fetch policies are **not supported** by `fetchQuery`, because it is designed around issuing a single network request and returning the response.
51
56
 
52
57
  ### Flow Type Parameters
53
58
 
@@ -62,7 +62,22 @@ npm run relay
62
62
  If you have [watchman](https://facebook.github.io/watchman) installed you can pass `--watch` to the Relay compiler to have it continue running and automatically update generated files as you edit your product code:
63
63
 
64
64
  ```sh
65
- npm run relay --watch
65
+ relay-compiler --watch
66
+ ```
67
+
68
+ ### Validate mode
69
+
70
+ Pass `--validate` to check whether any generated artifacts are out of date without writing anything to disk. The compiler exits with a non-zero code if any artifacts need to be updated. This is useful in CI to assert that generated files are committed and current:
71
+
72
+ ```sh
73
+ relay-compiler --validate
74
+ ```
75
+ ### Disabling watchman
76
+
77
+ By default, Relay uses [watchman](https://facebook.github.io/watchman), if installed, for fast file discovery. To fall back to directory traversal instead, pass `--no-watchman`:
78
+
79
+ ```sh
80
+ relay-compiler --no-watchman
66
81
  ```
67
82
 
68
83
  ### Codemods
@@ -75,8 +90,9 @@ The Relay compiler can compare two GraphQL documents to determine if one is a su
75
90
 
76
91
  ### Help
77
92
 
78
- To learn about the other capabilities of the Relay compiler see its extensive `--help` output:
93
+ To see the full command-line reference run:
79
94
 
80
95
  ```sh
81
- npm run relay --help
96
+ relay-compiler --help
97
+ relay-compiler <subcommand> --help
82
98
  ```
@@ -32,7 +32,7 @@ cd relay-example
32
32
  # Runtime dependencies
33
33
  npm install relay-runtime react-relay
34
34
  # Dev dependencies
35
- npm install --save-dev babel-plugin-relay graphql relay-compiler
35
+ npm install --save-dev babel-plugin-relay graphql relay-compiler @rolldown/plugin-babel
36
36
  ```
37
37
 
38
38
  :::tip
@@ -45,19 +45,19 @@ npx skills install facebook/relay
45
45
 
46
46
  ## Configure Vite to use Relay
47
47
 
48
- Relay uses a [Babel plugin](./babel-plugin.mdx) to insert code generated by the Relay compiler into your bundle. We can enable the Relay Babel plugin we installed earlier by configuring the React Vite plugin.
48
+ Relay uses a [Babel plugin](./babel-plugin.mdx) to insert code generated by the Relay compiler into your bundle. We can enable the Relay Babel plugin we installed earlier by configuring the Babel Vite plugin.
49
49
 
50
50
  ```tsx title="vite.config.ts"
51
- import { defineConfig } from 'vite'
52
- import react from '@vitejs/plugin-react'
51
+ import { defineConfig } from "vite";
52
+ import react from "@vitejs/plugin-react";
53
+ // change-line
54
+ import babel from "@rolldown/plugin-babel";
53
55
 
54
56
  // https://vite.dev/config/
55
57
  export default defineConfig({
56
- plugins: [
57
- // change-line
58
- react({ babel: { plugins: ["relay"] } })
59
- ],
60
- })
58
+ // change-line
59
+ plugins: [react(), babel({ plugins: ["relay"] })],
60
+ });
61
61
  ```
62
62
 
63
63
  See [Babel Plugin](./babel-plugin.mdx) for information about how to configure the Babel plugin for other build systems.
@@ -87,12 +87,14 @@ See [Relay Compiler](./compiler.mdx) for more information about configuring and
87
87
  To allow components within our application to fetch GraphQL we configure a Relay Environment to fetch from our test endpoint and add it to React context.
88
88
 
89
89
  ```tsx title="src/main.tsx"
90
+ import type { FetchFunction } from "relay-runtime";
91
+
90
92
  import { StrictMode, Suspense } from "react";
91
93
  import { createRoot } from "react-dom/client";
92
94
  import "./index.css";
93
95
  import App from "./App.tsx";
94
96
  import { RelayEnvironmentProvider } from "react-relay";
95
- import { Environment, Network, FetchFunction } from "relay-runtime";
97
+ import { Environment, Network } from "relay-runtime";
96
98
 
97
99
  const HTTP_ENDPOINT = "https://graphql.org/graphql/";
98
100
 
@@ -134,9 +136,10 @@ See [Relay Environment](../api-reference/relay-runtime/relay-environment.mdx) fo
134
136
  Finally we can start defining the data we want to fetch and build our UI. Our app will fetch a list of films and render each one using a `<Film>` component.
135
137
 
136
138
  ```tsx title="src/App.tsx"
137
- import { AppQuery } from "./__generated__/AppQuery.graphql";
139
+ import type { AppQuery } from "./__generated__/AppQuery.graphql";
140
+
138
141
  import { graphql, useLazyLoadQuery } from "react-relay";
139
- import Film from "./Film";
142
+ import Film from "./Film.tsx";
140
143
 
141
144
  export default function App() {
142
145
  const data = useLazyLoadQuery<AppQuery>(
@@ -24,6 +24,8 @@ Usage: relay codemod [OPTIONS] [CONFIG] <COMMAND>
24
24
 
25
25
  Commands:
26
26
  mark-dangerous-conditional-fragment-spreads Marks unaliased conditional fragment spreads as @dangerously_unaliased_fixme
27
+ remove-unnecessary-required-directives Removes @required directives from non-null fields within @throwOnFieldError fragments and operations.
28
+ fix-all Runs all Relay compiler transforms and fixes all fixable diagnostics
27
29
  help Print this message or the help of the given subcommand(s)
28
30
 
29
31
  Arguments:
@@ -52,7 +54,7 @@ can be enabled, which will ensure any future ambiguous fragment spreads must be
52
54
  aliased.
53
55
 
54
56
  Since this codemod can potentially modify many files, there is an optional
55
- `--rollout` parameter which, if used alongside the
57
+ `--rollout-percentage` parameter (shorthand: `-r`) which, if used alongside the
56
58
  `enforce_fragment_alias_where_ambiguous` feature flag in rollout mode, allows
57
59
  progressive codemod and enforcement of this validation.
58
60
 
@@ -64,3 +66,14 @@ directives from non-null fields within
64
66
  fragments and operations, or linked fields with
65
67
  [`@catch`](../guides/catch-directive.mdx), where the compiler is certain that the
66
68
  directive does not change the generated types for the data being fetched.
69
+
70
+ ### fix-all
71
+
72
+ Runs all Relay compiler transforms and automatically applies fixes for every
73
+ fixable diagnostic. This is a convenient catch-all codemod to apply when
74
+ upgrading Relay versions — run it after updating the package to repair any
75
+ issues the compiler now flags:
76
+
77
+ ```sh
78
+ relay codemod fix-all
79
+ ```
@@ -0,0 +1,17 @@
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
+ /**
9
+ * A unique identifier of the current actor.
10
+ */
11
+ export type ActorIdentifier = string;
12
+
13
+ export function assertInternalActorIdentifier(actorIdentifier: ActorIdentifier): void;
14
+
15
+ export function getActorIdentifier(actorID: string): ActorIdentifier;
16
+
17
+ export function getDefaultActorIdentifier(): ActorIdentifier;
@@ -61,15 +61,15 @@ export type ActorSpecificEnvironmentConfig = Readonly<{
61
61
 
62
62
  class ActorSpecificEnvironment implements IActorEnvironment {
63
63
  __log: LogFunction;
64
- +_defaultRenderPolicy: RenderPolicy;
65
- +_network: INetwork;
66
- +_operationTracker: OperationTracker;
67
- +_publishQueue: RelayPublishQueue;
68
- +_store: Store;
69
- +actorIdentifier: ActorIdentifier;
70
- +configName: ?string;
71
- +multiActorEnvironment: IMultiActorEnvironment;
72
- +options: unknown;
64
+ readonly _defaultRenderPolicy: RenderPolicy;
65
+ readonly _network: INetwork;
66
+ readonly _operationTracker: OperationTracker;
67
+ readonly _publishQueue: RelayPublishQueue;
68
+ readonly _store: Store;
69
+ readonly actorIdentifier: ActorIdentifier;
70
+ readonly configName: ?string;
71
+ readonly multiActorEnvironment: IMultiActorEnvironment;
72
+ readonly options: unknown;
73
73
  relayFieldLogger: RelayFieldLogger;
74
74
 
75
75
  constructor(config: ActorSpecificEnvironmentConfig) {