react-relay 0.0.0-main-ff9b2fed → 0.0.0-main-dc0b087a

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v0.0.0-main-ff9b2fed
2
+ * Relay v0.0.0-main-dc0b087a
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
@@ -0,0 +1,377 @@
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 React from 'react';
9
+ import {
10
+ _FragmentRefs,
11
+ _RefType,
12
+ CacheConfig,
13
+ ConcreteRequest,
14
+ Disposable,
15
+ DisposeFn,
16
+ Environment,
17
+ FetchPolicy,
18
+ FragmentType,
19
+ GraphQLResponse,
20
+ IEnvironment,
21
+ Observable,
22
+ Observer,
23
+ OperationType,
24
+ PreloadableConcreteRequest,
25
+ RenderPolicy,
26
+ Variables,
27
+ VariablesOf,
28
+ } from 'relay-runtime';
29
+
30
+ export { FragmentRef } from 'relay-runtime';
31
+ export { VariablesOf } from 'relay-runtime';
32
+
33
+ // --- Legacy container types ---
34
+
35
+ export interface RelayProp {
36
+ environment: Environment;
37
+ refetch: undefined; // ensures no RelayRefetchProp is used with a fragment container
38
+ hasMore: undefined; // ensures no RelayPaginationProp is used with a fragment container
39
+ }
40
+
41
+ export interface RelayRefetchProp {
42
+ environment: Environment;
43
+ refetch: (
44
+ refetchVariables: Variables | ((fragmentVariables: Variables) => Variables),
45
+ renderVariables?: Variables | null,
46
+ observerOrCallback?: ObserverOrCallback | null,
47
+ options?: RefetchOptions,
48
+ ) => Disposable;
49
+ hasMore: undefined; // ensures no RelayPaginationProp is used with a refetch container
50
+ }
51
+ export interface RefetchOptions {
52
+ force?: boolean | undefined;
53
+ fetchPolicy?: 'store-or-network' | 'network-only' | undefined;
54
+ }
55
+
56
+ type ObserverOrCallback = Observer<void> | ((error: Error | null | undefined) => void);
57
+
58
+ export interface RelayPaginationProp {
59
+ readonly environment: Environment;
60
+ readonly hasMore: () => boolean;
61
+ readonly isLoading: () => boolean;
62
+ readonly loadMore: (
63
+ pageSize: number,
64
+ observerOrCallback?: ObserverOrCallback | null,
65
+ options?: RefetchOptions | null,
66
+ ) => Disposable | null | undefined;
67
+ readonly refetchConnection: (
68
+ totalCount: number,
69
+ observerOrCallback?: ObserverOrCallback | null,
70
+ refetchVariables?: Variables | null,
71
+ ) => Disposable | null | undefined;
72
+ refetch: undefined; // ensures no RelayRefetchProp is used with a pagination container
73
+ }
74
+
75
+ export type FragmentOrRegularProp<T> = T extends _RefType<infer U> ? _FragmentRefs<U>
76
+ : T extends ReadonlyArray<_RefType<infer U>> ? ReadonlyArray<_FragmentRefs<U>>
77
+ : T;
78
+
79
+ export type MappedFragmentProps<T> = {
80
+ [K in keyof T]: FragmentOrRegularProp<T[K]>;
81
+ };
82
+
83
+ // --- Fragment key types (from helpers) ---
84
+
85
+ export type KeyType<TData = unknown> = Readonly<{
86
+ ' $data'?: TData | undefined;
87
+ ' $fragmentSpreads': FragmentType;
88
+ }>;
89
+
90
+ export type KeyTypeData<TKey extends KeyType<TData>, TData = unknown> = Required<TKey>[' $data'];
91
+
92
+ export type ArrayKeyType<TData = unknown> = ReadonlyArray<KeyType<readonly TData[]> | null | undefined>;
93
+ export type ArrayKeyTypeData<TKey extends ArrayKeyType<TData>, TData = unknown> = KeyTypeData<
94
+ NonNullable<TKey[number]>
95
+ >;
96
+
97
+ export type GetEntryPointParamsFromEntryPoint<TEntryPoint> = TEntryPoint extends EntryPoint<
98
+ infer _TEntryPointComponent,
99
+ infer TEntryPointParams
100
+ > ? TEntryPointParams
101
+ : never;
102
+
103
+ export type GetEntryPointComponentFromEntryPoint<TEntryPoint> = TEntryPoint extends EntryPoint<
104
+ infer TEntryPointComponent,
105
+ infer _TEntryPointParams
106
+ > ? TEntryPointComponent
107
+ : never;
108
+
109
+ // --- EntryPoint types ---
110
+
111
+ export interface JSResourceReference<TModule> {
112
+ getModuleId(): string;
113
+
114
+ getModuleIfRequired(): TModule | null;
115
+
116
+ load(): Promise<TModule>;
117
+ }
118
+
119
+ export type PreloadFetchPolicy = 'store-or-network' | 'store-and-network' | 'network-only';
120
+
121
+ export type PreloadOptions = Readonly<{
122
+ fetchKey?: string | number | undefined;
123
+ fetchPolicy?: PreloadFetchPolicy | null | undefined;
124
+ networkCacheConfig?: CacheConfig | null | undefined;
125
+ }>;
126
+
127
+ export type LoadQueryOptions = Readonly<{
128
+ fetchPolicy?: FetchPolicy | null | undefined;
129
+ networkCacheConfig?: CacheConfig | null | undefined;
130
+ onQueryAstLoadTimeout?: (() => void) | null | undefined;
131
+ }>;
132
+
133
+ export type EnvironmentProviderOptions<T extends Record<string, unknown> = Record<string, unknown>> = T;
134
+
135
+ export type PreloadedQuery<
136
+ TQuery extends OperationType,
137
+ TEnvironmentProviderOptions = EnvironmentProviderOptions,
138
+ > = Readonly<{
139
+ kind: 'PreloadedQuery';
140
+ environment: IEnvironment;
141
+ environmentProviderOptions?: TEnvironmentProviderOptions | null | undefined;
142
+ fetchKey: string | number;
143
+ fetchPolicy: PreloadFetchPolicy;
144
+ networkCacheConfig?: CacheConfig | null | undefined;
145
+ id?: string | null | undefined;
146
+ name: string;
147
+ source?: Observable<GraphQLResponse> | null | undefined;
148
+ variables: VariablesOf<TQuery>;
149
+ dispose: DisposeFn;
150
+ isDisposed: boolean;
151
+ }>;
152
+
153
+ export type PreloadQueryStatus = Readonly<{
154
+ cacheConfig?: CacheConfig | null | undefined;
155
+ source: 'cache' | 'network';
156
+ fetchTime?: number | null | undefined;
157
+ }>;
158
+
159
+ /**
160
+ * The Interface of the EntryPoints .entrypoint files
161
+ *
162
+ * Every .entrypoint file it's an object that must have two required fields:
163
+ * - getPreloadProps(...) function that will return the description of preloaded
164
+ * queries and preloaded (nested) entry points for the current entry point
165
+ * - root - JSResource of the module that will render those preloaded queries
166
+ *
167
+ * TEntryPointParams - object that contains all necessary information to execute
168
+ * the preloaders (routeParams, query variables)
169
+ *
170
+ * TPreloadedQueries - queries, defined in the root components
171
+ *
172
+ * TNestedEntryPoints - nested entry points, defined in the root components
173
+ *
174
+ * TRuntimeProps - the type of additional props that you may pass to the
175
+ * component (like `onClick` handler, etc) during runtime. Values for them
176
+ * defined during component runtime
177
+ *
178
+ * TExtraProps - a bag of extra props that you may define in `entrypoint` file
179
+ * and they will be passed to the EntryPointComponent as `extraProps`
180
+ */
181
+ type InternalEntryPointRepresentation<
182
+ TEntryPointParams extends Record<string, unknown>,
183
+ TPreloadedQueries extends Record<string, OperationType>,
184
+ TNestedEntryPoints extends Record<string, unknown>,
185
+ TRuntimeProps extends Record<string, unknown>,
186
+ TExtraProps extends Record<string, unknown> | null,
187
+ > = Readonly<{
188
+ root: JSResourceReference<
189
+ EntryPointComponent<TPreloadedQueries, TNestedEntryPoints, TRuntimeProps, TExtraProps>
190
+ >;
191
+ getPreloadProps: (
192
+ entryPointParams: TEntryPointParams,
193
+ ) => PreloadProps<TEntryPointParams, TPreloadedQueries, TNestedEntryPoints, TExtraProps>;
194
+ }>;
195
+
196
+ type ThinQueryParamsObject<TPreloadedQueries extends Record<string, OperationType> = Record<string, never>> = {
197
+ [K in keyof TPreloadedQueries]: ThinQueryParams<TPreloadedQueries[K]>;
198
+ };
199
+
200
+ type ThinNestedEntryPointParamsObject<
201
+ TEntryPoints extends Record<string, EntryPoint<any, any> | undefined> = Record<string, never>,
202
+ > = {
203
+ [K in keyof TEntryPoints]: ThinNestedEntryPointParams<TEntryPoints[K]>;
204
+ };
205
+
206
+ type PreloadedQueries<TPreloadedQueries> = TPreloadedQueries extends Record<string, OperationType> ? {
207
+ [T in keyof TPreloadedQueries]: PreloadedQuery<TPreloadedQueries[T]>;
208
+ }
209
+ : never;
210
+
211
+ type PreloadedEntryPoints<TEntryPoints> = TEntryPoints extends Record<
212
+ string,
213
+ InternalEntryPointRepresentation<any, any, any, any, any> | undefined
214
+ > ? {
215
+ [T in keyof TEntryPoints]: PreloadedEntryPoint<
216
+ GetEntryPointComponentFromEntryPoint<TEntryPoints[T]>
217
+ >;
218
+ }
219
+ : never;
220
+
221
+ export type PreloadProps<
222
+ _TPreloadParams extends Record<string, unknown>,
223
+ TPreloadedQueries extends Record<string, OperationType>,
224
+ TNestedEntryPoints extends Record<string, EntryPoint<any, any> | undefined>,
225
+ TExtraProps extends Record<string, unknown> | null,
226
+ > = Readonly<{
227
+ entryPoints?: ThinNestedEntryPointParamsObject<TNestedEntryPoints> | undefined;
228
+ extraProps?: TExtraProps | undefined;
229
+ queries?: ThinQueryParamsObject<TPreloadedQueries> | undefined;
230
+ }>;
231
+
232
+ export type EntryPointProps<TPreloadedQueries, TNestedEntryPoints, TRuntimeProps, TExtraProps> = Readonly<{
233
+ entryPoints: PreloadedEntryPoints<TNestedEntryPoints>;
234
+ extraProps: TExtraProps;
235
+ props: TRuntimeProps;
236
+ queries: PreloadedQueries<TPreloadedQueries>;
237
+ }>;
238
+
239
+ export type EntryPointComponent<
240
+ TPreloadedQueries extends Record<string, OperationType>,
241
+ TNestedEntryPoints extends Record<string, EntryPoint<any, any> | undefined>,
242
+ TRuntimeProps extends Record<string, unknown> = Record<string, unknown>,
243
+ TExtraProps extends Record<string, unknown> | null = Record<string, unknown>,
244
+ > = React.ComponentType<EntryPointProps<TPreloadedQueries, TNestedEntryPoints, TRuntimeProps, TExtraProps>>;
245
+
246
+ export type PreloadedEntryPoint<TEntryPointComponent> = TEntryPointComponent extends EntryPointComponent<
247
+ infer TPreloadedQueries,
248
+ infer TNestedEntryPoints,
249
+ infer _TRuntimeProps,
250
+ infer TExtraProps
251
+ > ? Readonly<{
252
+ dispose: DisposeFn;
253
+ entryPoints: PreloadedEntryPoints<TNestedEntryPoints>;
254
+ extraProps: TExtraProps;
255
+ getComponent: () => TEntryPointComponent;
256
+ isDisposed: boolean;
257
+ queries: PreloadedQueries<TPreloadedQueries>;
258
+ rootModuleID: string;
259
+ }>
260
+ : never;
261
+
262
+ export type ThinQueryParams<
263
+ TQuery extends OperationType,
264
+ TEnvironmentProviderOptions extends EnvironmentProviderOptions = EnvironmentProviderOptions,
265
+ > = Readonly<{
266
+ parameters: ConcreteRequest | PreloadableConcreteRequest<TQuery>;
267
+ variables: VariablesOf<TQuery>;
268
+ options?: PreloadOptions | null | undefined;
269
+ environmentProviderOptions?: TEnvironmentProviderOptions | null | undefined;
270
+ }>;
271
+
272
+ export type ThinNestedEntryPointParams<TEntryPoint> = Readonly<{
273
+ entryPoint: TEntryPoint;
274
+ entryPointParams: GetEntryPointParamsFromEntryPoint<TEntryPoint>;
275
+ }>;
276
+
277
+ export type EntryPoint<TEntryPointComponent, TEntryPointParams extends Record<string, unknown> = Record<string, unknown>> = InternalEntryPointRepresentation<
278
+ TEntryPointParams,
279
+ TEntryPointComponent extends EntryPointComponent<infer TPreloadedQueries, any, any, any> ? TPreloadedQueries
280
+ : never,
281
+ TEntryPointComponent extends EntryPointComponent<any, infer TNestedEntryPoints, any, any> ? TNestedEntryPoints
282
+ : never,
283
+ TEntryPointComponent extends EntryPointComponent<any, any, infer TRuntimeProps, any> ? TRuntimeProps : never,
284
+ TEntryPointComponent extends EntryPointComponent<any, any, any, infer TExtraProps> ? TExtraProps : never
285
+ >;
286
+
287
+ export interface IEnvironmentProvider<TOptions> {
288
+ getEnvironment(options: TOptions | null): IEnvironment;
289
+ }
290
+
291
+ // --- Refetchable fragment types (from useRefetchableFragmentNode) ---
292
+
293
+ export type RefetchFn<TQuery extends OperationType, TOptions = RefetchableOptions> = RefetchFnExact<TQuery, TOptions>;
294
+
295
+ export type RefetchFnDynamic<
296
+ TQuery extends OperationType,
297
+ _TKey extends KeyType | null | undefined,
298
+ TOptions = RefetchableOptions,
299
+ > = RefetchInexactDynamicResponse<TQuery, TOptions> & RefetchExactDynamicResponse<TQuery, TOptions>;
300
+
301
+ export type RefetchInexact<TQuery extends OperationType, TOptions> = (
302
+ data?: unknown,
303
+ ) => RefetchFnInexact<TQuery, TOptions>;
304
+ export type RefetchInexactDynamicResponse<TQuery extends OperationType, TOptions> = ReturnType<
305
+ RefetchInexact<TQuery, TOptions>
306
+ >;
307
+
308
+ export type RefetchExact<TQuery extends OperationType, TOptions> = (
309
+ data?: unknown | null,
310
+ ) => RefetchFnExact<TQuery, TOptions>;
311
+ export type RefetchExactDynamicResponse<TQuery extends OperationType, TOptions> = ReturnType<
312
+ RefetchExact<TQuery, TOptions>
313
+ >;
314
+
315
+ export type RefetchFnBase<TVars, TOptions> = (vars: TVars, options?: TOptions) => Disposable;
316
+
317
+ export type RefetchFnExact<TQuery extends OperationType, TOptions = RefetchableOptions> = RefetchFnBase<
318
+ VariablesOf<TQuery>,
319
+ TOptions
320
+ >;
321
+ export type RefetchFnInexact<TQuery extends OperationType, TOptions = RefetchableOptions> = RefetchFnBase<
322
+ Partial<VariablesOf<TQuery>>,
323
+ TOptions
324
+ >;
325
+
326
+ export interface ReturnTypeNode<
327
+ TQuery extends OperationType,
328
+ TKey extends KeyType | null | undefined,
329
+ TOptions = RefetchableOptions,
330
+ > {
331
+ fragmentData: unknown;
332
+ fragmentRef: unknown;
333
+ refetch: RefetchFnDynamic<TQuery, TKey, TOptions>;
334
+ disableStoreUpdates: () => void;
335
+ enableStoreUpdates: () => void;
336
+ }
337
+
338
+ export interface RefetchableOptions {
339
+ fetchPolicy?: FetchPolicy | undefined;
340
+ onComplete?: ((arg: Error | null) => void) | undefined;
341
+ UNSTABLE_renderPolicy?: RenderPolicy | undefined;
342
+ }
343
+
344
+ export interface InternalRefetchableOptions extends RefetchableOptions {
345
+ __environment?: IEnvironment | undefined;
346
+ }
347
+
348
+ export type RefetchableAction =
349
+ | {
350
+ type: 'reset';
351
+ environment: IEnvironment;
352
+ fragmentIdentifier: string;
353
+ }
354
+ | {
355
+ type: 'refetch';
356
+ refetchVariables: Variables;
357
+ fetchPolicy?: FetchPolicy | undefined;
358
+ renderPolicy?: RenderPolicy | undefined;
359
+ onComplete?: ((args: Error | null) => void) | undefined;
360
+ environment?: IEnvironment | null | undefined;
361
+ };
362
+
363
+ export interface RefetchState {
364
+ fetchPolicy?: FetchPolicy | undefined;
365
+ renderPolicy?: RenderPolicy | undefined;
366
+ mirroredEnvironment: IEnvironment;
367
+ mirroredFragmentIdentifier: string;
368
+ onComplete?: ((arg: Error | null) => void) | undefined;
369
+ refetchEnvironment?: IEnvironment | null | undefined;
370
+ refetchVariables?: Variables | null | undefined;
371
+ refetchGeneration: number;
372
+ }
373
+
374
+ export interface DebugIDandTypename {
375
+ id: string;
376
+ typename: string;
377
+ }
package/hooks.d.ts ADDED
@@ -0,0 +1,89 @@
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 {
9
+ EntryPoint,
10
+ EntryPointComponent,
11
+ EntryPointProps,
12
+ EnvironmentProviderOptions,
13
+ IEnvironmentProvider,
14
+ JSResourceReference,
15
+ LoadQueryOptions,
16
+ PreloadedEntryPoint,
17
+ PreloadedQuery,
18
+ PreloadFetchPolicy,
19
+ PreloadOptions,
20
+ PreloadProps,
21
+ PreloadQueryStatus,
22
+ ThinNestedEntryPointParams,
23
+ ThinQueryParams,
24
+ VariablesOf,
25
+ } from './ReactRelayTypes';
26
+
27
+ export {
28
+ DataID,
29
+ DeclarativeMutationConfig,
30
+ Disposable,
31
+ FetchPolicy,
32
+ GraphQLTaggedNode,
33
+ // RelayRuntime has two environment exports: one interface, one concrete.
34
+ IEnvironment as Environment,
35
+ MutationType,
36
+ MutationTypes,
37
+ NormalizationSelector,
38
+ OperationDescriptor,
39
+ RangeOperation,
40
+ RangeOperations,
41
+ ReaderSelector,
42
+ RelayContext,
43
+ Snapshot,
44
+ Variables,
45
+ } from 'relay-runtime';
46
+ export { MatchContainerProps, MatchPointer } from './relay-hooks/MatchContainer';
47
+ export { ProfilerContextType } from './relay-hooks/ProfilerContext';
48
+ export { Direction, LoadMoreFn } from './relay-hooks/useLoadMoreFunction';
49
+ export { UseMutationConfig } from './relay-hooks/useMutation';
50
+ export { UseQueryLoaderLoadQueryOptions } from './relay-hooks/useQueryLoader';
51
+ export { RefetchableOptions as RefetchOptions, RefetchFn, RefetchFnDynamic } from './ReactRelayTypes';
52
+
53
+ // /**
54
+ // * The public interface for Relay Hooks.
55
+ // */
56
+
57
+ export { graphql } from 'relay-runtime';
58
+
59
+ export { ConnectionHandler } from 'relay-runtime';
60
+
61
+ export { applyOptimisticMutation } from 'relay-runtime';
62
+ export { commitLocalUpdate } from 'relay-runtime';
63
+ export { commitMutation } from 'relay-runtime';
64
+
65
+ export { readInlineData } from 'relay-runtime';
66
+ export { requestSubscription } from 'relay-runtime';
67
+
68
+ export { EntryPointContainer } from './relay-hooks/EntryPointContainer.react';
69
+ export { RelayEnvironmentProvider } from './relay-hooks/RelayEnvironmentProvider';
70
+
71
+ export { ProfilerContext } from './relay-hooks/ProfilerContext';
72
+
73
+ export { fetchQuery } from 'relay-runtime';
74
+
75
+ export { loadEntryPoint } from './relay-hooks/loadEntryPoint';
76
+ export { loadQuery } from './relay-hooks/loadQuery';
77
+
78
+ export { useClientQuery } from './relay-hooks/useClientQuery';
79
+ export { useEntryPointLoader } from './relay-hooks/useEntryPointLoader';
80
+ export { useFragment } from './relay-hooks/useFragment';
81
+ export { useLazyLoadQuery } from './relay-hooks/useLazyLoadQuery';
82
+ export { useMutation } from './relay-hooks/useMutation';
83
+ export { usePaginationFragment } from './relay-hooks/usePaginationFragment';
84
+ export { usePreloadedQuery } from './relay-hooks/usePreloadedQuery';
85
+ export { useQueryLoader } from './relay-hooks/useQueryLoader';
86
+ export { useRefetchableFragment } from './relay-hooks/useRefetchableFragment';
87
+ export { useRelayEnvironment } from './relay-hooks/useRelayEnvironment';
88
+ export { useSubscribeToInvalidationState } from './relay-hooks/useSubscribeToInvalidationState';
89
+ export { useSubscription } from './relay-hooks/useSubscription';
package/hooks.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v0.0.0-main-ff9b2fed
2
+ * Relay v0.0.0-main-dc0b087a
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
package/index.d.ts ADDED
@@ -0,0 +1,9 @@
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 * from './hooks';
9
+ export * from './legacy';
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v0.0.0-main-ff9b2fed
2
+ * Relay v0.0.0-main-dc0b087a
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
package/legacy.d.ts ADDED
@@ -0,0 +1,143 @@
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 {MappedFragmentProps, RelayPaginationProp, RelayProp, RelayRefetchProp} from './ReactRelayTypes';
9
+ import * as React from 'react';
10
+ import {
11
+ _FragmentRefs,
12
+ _RefType,
13
+ CacheConfig,
14
+ FetchPolicy,
15
+ GraphQLTaggedNode,
16
+ IEnvironment,
17
+ OperationType,
18
+ PageInfo,
19
+ RelayContext,
20
+ Variables,
21
+ } from 'relay-runtime';
22
+
23
+ export { FragmentRef, RelayPaginationProp, RelayProp, RelayRefetchProp } from './ReactRelayTypes';
24
+
25
+ export {
26
+ DataID,
27
+ DeclarativeMutationConfig,
28
+ Disposable,
29
+ FetchPolicy,
30
+ GraphQLTaggedNode,
31
+ // RelayRuntime has two environment exports: one interface, one concrete.
32
+ IEnvironment as Environment,
33
+ MutationType,
34
+ NormalizationSelector,
35
+ OperationDescriptor,
36
+ RangeOperation,
37
+ ReaderSelector,
38
+ RelayContext,
39
+ Snapshot,
40
+ Variables,
41
+ } from 'relay-runtime';
42
+
43
+ /**
44
+ * Legacy react-relay exports.
45
+ * Should prefer using interface defined in ./hooks.js
46
+ */
47
+ export { ConnectionHandler } from 'relay-runtime';
48
+ export interface QueryRendererProps<TOperation extends OperationType> {
49
+ environment: IEnvironment;
50
+ query: GraphQLTaggedNode | null | undefined;
51
+ render: (renderProps: {
52
+ error: Error | null;
53
+ props: TOperation['response'] | null;
54
+ retry: (() => void) | null;
55
+ }) => React.ReactNode;
56
+ variables: TOperation['variables'];
57
+ }
58
+ declare class ReactRelayQueryRenderer<TOperation extends OperationType> extends React.Component<
59
+ {
60
+ cacheConfig?: CacheConfig | null | undefined;
61
+ fetchPolicy?: FetchPolicy | undefined;
62
+ } & QueryRendererProps<TOperation>
63
+ > {}
64
+ export { ReactRelayQueryRenderer as QueryRenderer };
65
+
66
+ declare class ReactRelayLocalQueryRenderer<TOperation extends OperationType> extends React.Component<
67
+ QueryRendererProps<TOperation>
68
+ > {}
69
+ export { ReactRelayLocalQueryRenderer as LocalQueryRenderer };
70
+
71
+ export { MutationTypes } from 'relay-runtime';
72
+ export { RangeOperations } from 'relay-runtime';
73
+
74
+ export const ReactRelayContext: React.Context<RelayContext | null>;
75
+
76
+ export { applyOptimisticMutation } from 'relay-runtime';
77
+ export { commitLocalUpdate } from 'relay-runtime';
78
+ export { commitMutation } from 'relay-runtime';
79
+
80
+ export type ContainerProps<Props> = MappedFragmentProps<Pick<Props, Exclude<keyof Props, 'relay'>>>;
81
+ export type RelayProps<Props> = ContainerProps<Props>; // TODO: validate this
82
+ export type Container<Props> = React.ComponentType<
83
+ ContainerProps<Props> & { componentRef?: ((ref: any) => void) | undefined }
84
+ >;
85
+
86
+ // TODO: validate the bellow three
87
+ export type RelayFragmentContainer<TComponent extends React.ElementType> = React.ComponentType<
88
+ ContainerProps<React.ComponentPropsWithoutRef<TComponent>>
89
+ >;
90
+
91
+ export type RelayPaginationContainer<TComponent extends React.ElementType> = React.ComponentType<
92
+ ContainerProps<React.ComponentPropsWithoutRef<TComponent>>
93
+ >;
94
+
95
+ export type RelayRefetchContainer<TComponent extends React.ElementType> = React.ComponentType<
96
+ ContainerProps<React.ComponentPropsWithoutRef<TComponent>>
97
+ >;
98
+
99
+ type PropsWithoutRelay<C extends keyof React.JSX.IntrinsicElements | React.JSXElementConstructor<any>> =
100
+ React.JSX.LibraryManagedAttributes<C, Omit<React.ComponentProps<C>, 'relay'>>;
101
+
102
+ export function createFragmentContainer<
103
+ C extends React.ComponentType<React.ComponentProps<C> & { relay?: RelayProp | undefined }>,
104
+ >(Component: C, fragmentSpec: Record<string, GraphQLTaggedNode>): Container<PropsWithoutRelay<C>>;
105
+
106
+ export { fetchQuery_DEPRECATED } from 'relay-runtime';
107
+
108
+ export { graphql } from 'relay-runtime';
109
+ export { readInlineData } from 'relay-runtime';
110
+ export { requestSubscription } from 'relay-runtime';
111
+
112
+ export function createPaginationContainer<
113
+ C extends React.ComponentType<React.ComponentProps<C> & { relay: RelayPaginationProp }>,
114
+ >(
115
+ Component: C,
116
+ fragmentSpec: Record<string, GraphQLTaggedNode>,
117
+ connectionConfig: ConnectionConfig<PropsWithoutRelay<C>>,
118
+ ): Container<PropsWithoutRelay<C>>;
119
+
120
+ export function createRefetchContainer<
121
+ C extends React.ComponentType<React.ComponentProps<C> & { relay: RelayRefetchProp }>,
122
+ >(
123
+ Component: C,
124
+ fragmentSpec: Record<string, GraphQLTaggedNode>,
125
+ refetchQuery: GraphQLTaggedNode,
126
+ ): Container<PropsWithoutRelay<C>>;
127
+
128
+ export interface ConnectionConfig<Props = object> {
129
+ direction?: 'backward' | 'forward' | undefined;
130
+ getConnectionFromProps?: ((props: Props) => ConnectionData | null | undefined) | undefined;
131
+ getFragmentVariables?: ((prevVars: Variables, totalCount: number) => Variables) | undefined;
132
+ getVariables: (
133
+ props: Props,
134
+ paginationInfo: { count: number; cursor?: string | null | undefined },
135
+ fragmentVariables: Variables,
136
+ ) => Variables;
137
+ query: GraphQLTaggedNode;
138
+ }
139
+
140
+ interface ConnectionData {
141
+ edges?: readonly any[] | null | undefined;
142
+ pageInfo?: Partial<PageInfo> | null | undefined;
143
+ }
package/legacy.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v0.0.0-main-ff9b2fed
2
+ * Relay v0.0.0-main-dc0b087a
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-relay",
3
3
  "description": "A framework for building GraphQL-driven React applications.",
4
- "version": "0.0.0-main-ff9b2fed",
4
+ "version": "0.0.0-main-dc0b087a",
5
5
  "keywords": [
6
6
  "graphql",
7
7
  "relay",
@@ -20,7 +20,7 @@
20
20
  "fbjs": "^3.0.2",
21
21
  "invariant": "^2.2.4",
22
22
  "nullthrows": "^1.1.1",
23
- "relay-runtime": "0.0.0-main-ff9b2fed"
23
+ "relay-runtime": "0.0.0-main-dc0b087a"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "react": "^16.9.0 || ^17 || ^18 || ^19"
@@ -0,0 +1,22 @@
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 {EntryPointComponent, PreloadedEntryPoint} from '../ReactRelayTypes';
9
+ import { ReactElement } from 'react';
10
+
11
+ type GetComponentFromPreloadedEntryPoint<T> = T extends PreloadedEntryPoint<infer C> ? C : never;
12
+ type GetRuntimePropsFromComponent<T> = T extends EntryPointComponent<any, any, infer R, any> ? R : never;
13
+
14
+ export function EntryPointContainer<TPreloadedEntryPoint extends PreloadedEntryPoint<any>>({
15
+ entryPointReference,
16
+ props,
17
+ }: Readonly<{
18
+ entryPointReference: TPreloadedEntryPoint;
19
+ props: GetRuntimePropsFromComponent<GetComponentFromPreloadedEntryPoint<TPreloadedEntryPoint>>;
20
+ }>): ReactElement;
21
+
22
+ export {};
@@ -0,0 +1,95 @@
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 {ComponentType, ElementType, ReactNode} from 'react';
9
+
10
+ /**
11
+ * Renders the results of a data-driven dependency fetched with the `@match`
12
+ * directive. The `@match` directive can be used to specify a mapping of
13
+ * result types to the containers used to render those types. The result
14
+ * value is an opaque object that described which component was selected
15
+ * and a reference to its data. Use <MatchContainer/> to render these
16
+ * values.
17
+ *
18
+ * ## Example
19
+ *
20
+ * For example, consider a piece of media content that might be text or
21
+ * an image, where for clients that don't support images the application
22
+ * should fall back to rendering the image caption as text. @match can be
23
+ * used to dynamically select whether to render a given media item as
24
+ * an image or text (on the server) and then fetch the corresponding
25
+ * React component and its data dependencies (information about the
26
+ * image or about the text).
27
+ *
28
+ * ```
29
+ * // Media.react.js
30
+ *
31
+ * // Define a React component that uses <MatchContainer /> to render the
32
+ * // results of a @module selection
33
+ * function Media(props) {
34
+ * const {media, ...restProps} = props;
35
+ *
36
+ * const loader = moduleReference => {
37
+ * // given the data returned by your server for the @module directive,
38
+ * // return the React component (or throw a Suspense promise if
39
+ * // it is loading asynchronously).
40
+ * todo_returnModuleOrThrowPromise(moduleReference);
41
+ * };
42
+ * return <MatchContainer
43
+ * loader={loader}
44
+ * match={media.mediaAttachment}
45
+ * props={restProps}
46
+ * />;
47
+ * }
48
+ *
49
+ * module.exports = createSuspenseFragmentContainer(
50
+ * Media,
51
+ * {
52
+ * media: graphql`
53
+ * fragment Media_media on Media {
54
+ * # ...
55
+ * mediaAttachment @match {
56
+ * ...ImageContainer_image @module(name: "ImageContainer.react")
57
+ * ...TextContainer_text @module(name: "TextContainer.react")
58
+ * }
59
+ * }
60
+ * `
61
+ * },
62
+ * );
63
+ * ```
64
+ *
65
+ * ## API
66
+ *
67
+ * MatchContainer accepts the following props:
68
+ * - `match`: The results (an opaque object) of a `@match` field.
69
+ * - `props`: Props that should be passed through to the dynamically
70
+ * selected component. Note that any of the components listed in
71
+ * `@module()` could be selected, so all components should accept
72
+ * the value passed here.
73
+ * - `loader`: A function to load a module given a reference (whatever
74
+ * your server returns for the `js(moduleName: String)` field).
75
+ */
76
+
77
+ type TypenameOnlyPointer = Readonly<{ __typename: string }>;
78
+ export type MatchPointer = Readonly<{
79
+ __fragmentPropName?: string | null | undefined;
80
+ __module_component?: unknown | undefined;
81
+ ' $fragmentSpreads': unknown;
82
+ }>;
83
+
84
+ export type MatchContainerProps<TProps = Record<string, unknown>, TFallback = ReactNode> = Readonly<{
85
+ fallback?: TFallback | null | undefined;
86
+ loader: (module: unknown) => ComponentType<TProps>;
87
+ match?: MatchPointer | TypenameOnlyPointer | null | undefined;
88
+ props?: TProps | undefined;
89
+ }>;
90
+
91
+ export function MatchContainer<TProps = Record<string, unknown>, TFallback = ReactNode>(
92
+ props: MatchContainerProps<TProps, TFallback>,
93
+ ): ElementType<TProps> | TFallback | null;
94
+
95
+ export {};
@@ -0,0 +1,18 @@
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
+ // This contextual profiler can be used to wrap a react sub-tree. It will bind
9
+ // the RelayProfiler during the render phase of these components. Allows
10
+ // collecting metrics for a specific part of your application.
11
+
12
+ import { Context } from 'react';
13
+
14
+ export interface ProfilerContextType {
15
+ wrapPrepareQueryResource: <T>(cb: () => T) => T;
16
+ }
17
+
18
+ export const ProfilerContext: Context<ProfilerContextType>;
@@ -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 {ProviderProps, ReactElement, ReactNode} from 'react';
9
+ import {IEnvironment, RelayContext} from 'relay-runtime';
10
+
11
+ export interface Props {
12
+ children: ReactNode;
13
+ environment: IEnvironment;
14
+ }
15
+
16
+ export function RelayEnvironmentProvider(props: Props): ReactElement<ProviderProps<RelayContext>>;
@@ -0,0 +1,14 @@
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 {EnvironmentProviderOptions, GetEntryPointComponentFromEntryPoint, GetEntryPointParamsFromEntryPoint, IEnvironmentProvider, PreloadedEntryPoint} from '../ReactRelayTypes';
9
+
10
+ export function loadEntryPoint<TEntryPoint>(
11
+ environmentProvider: IEnvironmentProvider<EnvironmentProviderOptions>,
12
+ entryPoint: TEntryPoint,
13
+ entryPointParams: GetEntryPointParamsFromEntryPoint<TEntryPoint>,
14
+ ): PreloadedEntryPoint<GetEntryPointComponentFromEntryPoint<TEntryPoint>>;
@@ -0,0 +1,20 @@
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 {EnvironmentProviderOptions, LoadQueryOptions, PreloadedQuery} from '../ReactRelayTypes';
9
+ import {GraphQLTaggedNode, IEnvironment, OperationType, PreloadableConcreteRequest, VariablesOf} from 'relay-runtime';
10
+
11
+ export function loadQuery<
12
+ TQuery extends OperationType,
13
+ TEnvironmentProviderOptions extends EnvironmentProviderOptions = Record<string, unknown>,
14
+ >(
15
+ environment: IEnvironment,
16
+ preloadableRequest: GraphQLTaggedNode | PreloadableConcreteRequest<TQuery>,
17
+ variables: VariablesOf<TQuery>,
18
+ options?: LoadQueryOptions,
19
+ environmentProviderOptions?: TEnvironmentProviderOptions,
20
+ ): PreloadedQuery<TQuery, TEnvironmentProviderOptions>;
@@ -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 {GraphQLTaggedNode, OperationType, RenderPolicy, VariablesOf} from 'relay-runtime';
9
+
10
+ export function useClientQuery<TQuery extends OperationType>(
11
+ gqlQuery: GraphQLTaggedNode,
12
+ variables: VariablesOf<TQuery>,
13
+ options?: {
14
+ UNSTABLE_renderPolicy?: RenderPolicy | undefined;
15
+ },
16
+ ): TQuery['response'];
@@ -0,0 +1,21 @@
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 {EnvironmentProviderOptions, GetEntryPointComponentFromEntryPoint, GetEntryPointParamsFromEntryPoint, IEnvironmentProvider, PreloadedEntryPoint} from '../ReactRelayTypes';
9
+ import { DisposeFn } from 'relay-runtime';
10
+
11
+ export type UseEntryPointLoaderHookType<TEntryPoint> = [
12
+ PreloadedEntryPoint<GetEntryPointComponentFromEntryPoint<TEntryPoint>> | null | undefined,
13
+ (entryPointParams: GetEntryPointParamsFromEntryPoint<TEntryPoint>) => void,
14
+ DisposeFn,
15
+ ];
16
+
17
+ export function useEntryPointLoader<TEntryPoint>(
18
+ environmentProvider: IEnvironmentProvider<EnvironmentProviderOptions>,
19
+ entryPoint: TEntryPoint,
20
+ // Have opted to not include the TEST_ONLY__initialEntryPointData object here—as is FB internal
21
+ ): UseEntryPointLoaderHookType<TEntryPoint>;
@@ -0,0 +1,36 @@
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 {ArrayKeyType, ArrayKeyTypeData, KeyType, KeyTypeData} from '../ReactRelayTypes';
9
+ import { GraphQLTaggedNode } from 'relay-runtime';
10
+
11
+ // NOTE: These declares ensure that the type of the returned data is:
12
+ // - non-nullable if the provided ref type is non-nullable
13
+ // - nullable if the provided ref type is nullable
14
+ // - array of non-nullable if the provided ref type is an array of
15
+ // non-nullable refs
16
+ // - array of nullable if the provided ref type is an array of nullable refs
17
+
18
+ export function useFragment<TKey extends KeyType>(
19
+ fragmentInput: GraphQLTaggedNode,
20
+ fragmentRef: TKey,
21
+ ): KeyTypeData<TKey>;
22
+
23
+ export function useFragment<TKey extends KeyType>(
24
+ fragmentInput: GraphQLTaggedNode,
25
+ fragmentRef: TKey | null | undefined,
26
+ ): KeyTypeData<TKey> | null | undefined;
27
+
28
+ export function useFragment<TKey extends ArrayKeyType>(
29
+ fragmentInput: GraphQLTaggedNode,
30
+ fragmentRef: TKey,
31
+ ): ArrayKeyTypeData<TKey>;
32
+
33
+ export function useFragment<TKey extends ArrayKeyType>(
34
+ fragmentInput: GraphQLTaggedNode,
35
+ fragmentRef: TKey | null | undefined,
36
+ ): ArrayKeyTypeData<TKey> | null | undefined;
@@ -0,0 +1,19 @@
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 {CacheConfig, FetchPolicy, GraphQLTaggedNode, OperationType, RenderPolicy, VariablesOf} from 'relay-runtime';
9
+
10
+ export function useLazyLoadQuery<TQuery extends OperationType>(
11
+ gqlQuery: GraphQLTaggedNode,
12
+ variables: VariablesOf<TQuery>,
13
+ options?: {
14
+ fetchKey?: string | number | undefined;
15
+ fetchPolicy?: FetchPolicy | undefined;
16
+ networkCacheConfig?: CacheConfig | undefined;
17
+ UNSTABLE_renderPolicy?: RenderPolicy | undefined;
18
+ },
19
+ ): TQuery['response'];
@@ -0,0 +1,56 @@
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
+ ConcreteRequest,
10
+ Disposable,
11
+ DisposeFn,
12
+ GraphQLResponse,
13
+ Observer,
14
+ OperationType,
15
+ ReaderFragment,
16
+ ReaderPaginationMetadata,
17
+ VariablesOf,
18
+ } from 'relay-runtime';
19
+
20
+ export type Direction = 'forward' | 'backward';
21
+
22
+ export type LoadMoreFn<TQuery extends OperationType> = (
23
+ count: number,
24
+ options?: {
25
+ onComplete?: ((arg: Error | null) => void) | undefined;
26
+ UNSTABLE_extraVariables?: Partial<VariablesOf<TQuery>> | undefined;
27
+ },
28
+ ) => Disposable;
29
+
30
+ export interface UseLoadMoreFunctionArgs {
31
+ direction: Direction;
32
+ fragmentNode: ReaderFragment;
33
+ fragmentRef: unknown;
34
+ fragmentIdentifier: string;
35
+ fragmentData: unknown;
36
+ connectionPathInFragmentData: ReadonlyArray<string | number>;
37
+ identifierField?: string | null | undefined;
38
+ paginationRequest: ConcreteRequest;
39
+ paginationMetadata: ReaderPaginationMetadata;
40
+ componentDisplayName: string;
41
+ observer: Observer<GraphQLResponse>;
42
+ onReset: () => void;
43
+ }
44
+ export function useLoadMoreFunction<TQuery extends OperationType>(
45
+ args: UseLoadMoreFunctionArgs,
46
+ ): [LoadMoreFn<TQuery>, boolean, DisposeFn];
47
+
48
+ export function getConnectionState(
49
+ direction: Direction,
50
+ fragmentNode: ReaderFragment,
51
+ fragmentData: unknown,
52
+ connectionPathInFragmentData: ReadonlyArray<string | number>,
53
+ ): {
54
+ cursor?: string | null | undefined;
55
+ hasMore: boolean;
56
+ };
@@ -0,0 +1,36 @@
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
+ DeclarativeMutationConfig,
10
+ Disposable,
11
+ GraphQLTaggedNode,
12
+ IEnvironment,
13
+ MutationConfig,
14
+ MutationParameters,
15
+ PayloadError,
16
+ SelectorStoreUpdater,
17
+ UploadableMap,
18
+ VariablesOf,
19
+ } from 'relay-runtime';
20
+
21
+ export interface UseMutationConfig<TMutation extends MutationParameters> {
22
+ variables: VariablesOf<TMutation>;
23
+ updater?: SelectorStoreUpdater<TMutation['response']> | null | undefined;
24
+ uploadables?: UploadableMap | undefined;
25
+ optimisticUpdater?: SelectorStoreUpdater<TMutation['response']> | null | undefined;
26
+ optimisticResponse?: TMutation['rawResponse'] | undefined;
27
+ configs?: DeclarativeMutationConfig[] | undefined;
28
+ onError?: ((error: Error) => void | null) | undefined;
29
+ onCompleted?: ((response: TMutation['response'], errors: PayloadError[] | null) => void | null) | undefined;
30
+ onUnsubscribe?: (() => void | null) | undefined;
31
+ }
32
+
33
+ export function useMutation<TMutation extends MutationParameters>(
34
+ mutation: GraphQLTaggedNode,
35
+ commitMutationFn?: (environment: IEnvironment, config: MutationConfig<TMutation>) => Disposable,
36
+ ): [(config: UseMutationConfig<TMutation>) => Disposable, boolean];
@@ -0,0 +1,33 @@
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 {KeyType, KeyTypeData, RefetchFnDynamic} from '../ReactRelayTypes';
9
+ import { LoadMoreFn } from './useLoadMoreFunction';
10
+ import {GraphQLTaggedNode, OperationType} from 'relay-runtime';
11
+
12
+ export interface usePaginationFragmentHookType<
13
+ TQuery extends OperationType,
14
+ TKey extends KeyType | null | undefined,
15
+ TFragmentData,
16
+ > {
17
+ data: TFragmentData;
18
+ loadNext: LoadMoreFn<TQuery>;
19
+ loadPrevious: LoadMoreFn<TQuery>;
20
+ hasNext: boolean;
21
+ hasPrevious: boolean;
22
+ isLoadingNext: boolean;
23
+ isLoadingPrevious: boolean;
24
+ refetch: RefetchFnDynamic<TQuery, TKey>;
25
+ }
26
+ export function usePaginationFragment<TQuery extends OperationType, TKey extends KeyType>(
27
+ fragmentInput: GraphQLTaggedNode,
28
+ parentFragmentRef: TKey,
29
+ ): usePaginationFragmentHookType<TQuery, TKey, KeyTypeData<TKey>>;
30
+ export function usePaginationFragment<TQuery extends OperationType, TKey extends KeyType>(
31
+ fragmentInput: GraphQLTaggedNode,
32
+ parentFragmentRef: TKey | null | undefined,
33
+ ): usePaginationFragmentHookType<TQuery, TKey | null, KeyTypeData<TKey> | null | undefined>;
@@ -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 { PreloadedQuery } from '../ReactRelayTypes';
9
+ import {GraphQLTaggedNode, OperationType, RenderPolicy} from 'relay-runtime';
10
+
11
+ export function usePreloadedQuery<TQuery extends OperationType>(
12
+ gqlQuery: GraphQLTaggedNode,
13
+ preloadedQuery: PreloadedQuery<TQuery>,
14
+ options?: {
15
+ UNSTABLE_renderPolicy?: RenderPolicy | undefined;
16
+ },
17
+ ): TQuery['response'];
@@ -0,0 +1,33 @@
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 {LoadQueryOptions, PreloadedQuery} from '../ReactRelayTypes';
9
+ import {
10
+ DisposeFn,
11
+ GraphQLTaggedNode,
12
+ IEnvironment,
13
+ OperationType,
14
+ PreloadableConcreteRequest,
15
+ VariablesOf,
16
+ } from 'relay-runtime';
17
+
18
+ export type useQueryLoaderHookType<TQuery extends OperationType> = [
19
+ PreloadedQuery<TQuery> | null | undefined,
20
+ (variables: VariablesOf<TQuery>, options?: UseQueryLoaderLoadQueryOptions) => void,
21
+ DisposeFn,
22
+ ];
23
+
24
+ export type UseQueryLoaderLoadQueryOptions =
25
+ & LoadQueryOptions
26
+ & Readonly<{
27
+ __environment?: IEnvironment | null | undefined;
28
+ }>;
29
+
30
+ export function useQueryLoader<TQuery extends OperationType>(
31
+ preloadableRequest: GraphQLTaggedNode | PreloadableConcreteRequest<TQuery>,
32
+ initialQueryReference?: PreloadedQuery<TQuery> | null,
33
+ ): useQueryLoaderHookType<TQuery>;
@@ -0,0 +1,23 @@
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 {KeyType, KeyTypeData, RefetchFnDynamic} from '../ReactRelayTypes';
9
+ import {GraphQLTaggedNode, OperationType} from 'relay-runtime';
10
+
11
+ export type useRefetchableFragmentHookType<
12
+ TQuery extends OperationType,
13
+ TKey extends KeyType | null | undefined,
14
+ TFragmentData,
15
+ > = [TFragmentData, RefetchFnDynamic<TQuery, TKey>];
16
+ export function useRefetchableFragment<TQuery extends OperationType, TKey extends KeyType>(
17
+ fragmentInput: GraphQLTaggedNode,
18
+ fragmentRef: TKey,
19
+ ): useRefetchableFragmentHookType<TQuery, TKey, KeyTypeData<TKey>>;
20
+ export function useRefetchableFragment<TQuery extends OperationType, TKey extends KeyType>(
21
+ fragmentInput: GraphQLTaggedNode,
22
+ fragmentRef: TKey | null | undefined,
23
+ ): useRefetchableFragmentHookType<TQuery, TKey, KeyTypeData<TKey> | null | undefined>;
@@ -0,0 +1,10 @@
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 { Environment } from 'relay-runtime';
9
+
10
+ export function useRelayEnvironment(): Environment;
@@ -0,0 +1,19 @@
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, Disposable} from 'relay-runtime';
9
+
10
+ /**
11
+ * This hook subscribes a callback to the invalidation state of the given data
12
+ * ids.
13
+ * Any time the invalidation state of the given data ids changes, the provided
14
+ * callback will be called.
15
+ * If new ids or a new callback are provided, the subscription will be
16
+ * re-established and the previous one will be disposed.
17
+ * The subscription will automatically be disposed on unmount
18
+ */
19
+ export function useSubscribeToInvalidationState(dataIDs: readonly DataID[], callback: () => void): Disposable;
@@ -0,0 +1,14 @@
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 {GraphQLSubscriptionConfig, OperationType, requestSubscription} from 'relay-runtime';
9
+
10
+ export function useSubscription<TSubscriptionPayload extends OperationType>(
11
+ // The actual subtype of OperationType is required to allow for type inference inside GraphQLSubscriptionConfig.s
12
+ config: GraphQLSubscriptionConfig<TSubscriptionPayload>,
13
+ requestSubscriptionFn?: typeof requestSubscription,
14
+ ): void;
@@ -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 { PreloadedQueryRef } from './rsc_EXPERIMENTAL';
9
+ import {GraphQLTaggedNode, OperationType} from 'relay-runtime';
10
+
11
+ export function useQueryFromServer<T extends OperationType>(
12
+ query: GraphQLTaggedNode,
13
+ queryRef: PreloadedQueryRef<T['variables'], T['response']>,
14
+ options?: { staleThresholdMs?: number },
15
+ ): T['response'];
16
+
17
+ export { PreloadedQueryRef };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v0.0.0-main-ff9b2fed
2
+ * Relay v0.0.0-main-dc0b087a
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
@@ -0,0 +1,48 @@
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 {ArrayKeyType, ArrayKeyTypeData, KeyType, KeyTypeData} from './ReactRelayTypes';
9
+ import {GraphQLTaggedNode, IEnvironment, OperationType} from 'relay-runtime';
10
+
11
+ export interface PreloadedQueryResponse<TData> {
12
+ readonly data: TData;
13
+ readonly errors?: ReadonlyArray<{ readonly message: string }>;
14
+ }
15
+
16
+ export interface PreloadedQueryRef<TVariables, TData> {
17
+ readonly kind: 'PreloadedQueryRef';
18
+ readonly queryId: string;
19
+ readonly variables: TVariables;
20
+ readonly _response: Promise<PreloadedQueryResponse<TData>>;
21
+ readonly fetchedAt: number;
22
+ }
23
+
24
+ export interface ServerEnvironment {
25
+ readonly getEnvironment: () => IEnvironment;
26
+ readonly serverFetchQuery: <T extends OperationType>(
27
+ query: GraphQLTaggedNode,
28
+ variables: T['variables'],
29
+ ) => Promise<T['response']>;
30
+ readonly serverPreloadQuery: <T extends OperationType>(
31
+ query: GraphQLTaggedNode,
32
+ variables: T['variables'],
33
+ ) => PreloadedQueryRef<T['variables'], T['response']>;
34
+ readonly serverReadFragment: {
35
+ <TKey extends KeyType>(
36
+ fragment: GraphQLTaggedNode,
37
+ fragmentRef: TKey,
38
+ ): Promise<KeyTypeData<TKey>>;
39
+ <TKey extends ArrayKeyType>(
40
+ fragment: GraphQLTaggedNode,
41
+ fragmentRef: TKey,
42
+ ): Promise<ArrayKeyTypeData<TKey>>;
43
+ };
44
+ }
45
+
46
+ export function createServerEnvironment(
47
+ create: () => IEnvironment,
48
+ ): ServerEnvironment;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v0.0.0-main-ff9b2fed
2
+ * Relay v0.0.0-main-dc0b087a
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *