react-relay 0.0.0-main-87aabe9a → 0.0.0-main-ee43b7b9
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/ReactRelayContext.js +1 -1
- package/ReactRelayFragmentContainer.js.flow +6 -3
- package/ReactRelayLocalQueryRenderer.js.flow +1 -1
- package/ReactRelayPaginationContainer.js.flow +6 -3
- package/ReactRelayRefetchContainer.js.flow +9 -6
- package/ReactRelayTypes.js.flow +6 -8
- package/buildReactRelayContainer.js.flow +1 -1
- package/getRootVariablesForFragments.js.flow +1 -1
- package/hooks.js +1 -1
- package/index.js +1 -1
- package/legacy.js +1 -1
- package/package.json +2 -2
- package/relay-hooks/EntryPointContainer.react.js.flow +3 -3
- package/relay-hooks/EntryPointTypes.flow.js.flow +12 -12
- package/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js.flow +10 -10
- package/relay-hooks/MatchContainer.js.flow +8 -2
- package/relay-hooks/RelayEnvironmentProvider.js.flow +1 -1
- package/relay-hooks/__flowtests__/useBlockingPaginationFragment-flowtest.js.flow +2 -2
- package/relay-hooks/__flowtests__/usePaginationFragment-flowtest.js.flow +2 -2
- package/relay-hooks/legacy/useBlockingPaginationFragment.js.flow +4 -4
- package/relay-hooks/legacy/useFragmentNode.js.flow +2 -2
- package/relay-hooks/legacy/useRefetchableFragmentNode.js.flow +13 -13
- package/relay-hooks/loadEntryPoint.js.flow +6 -6
- package/relay-hooks/loadQuery.js.flow +1 -1
- package/relay-hooks/preloadQuery_DEPRECATED.js.flow +5 -2
- package/relay-hooks/prepareEntryPoint_DEPRECATED.js.flow +6 -6
- package/relay-hooks/useClientQuery.js.flow +1 -1
- package/relay-hooks/useEntryPointLoader.js.flow +11 -11
- package/relay-hooks/useFragment.js.flow +4 -4
- package/relay-hooks/useIsParentQueryActive.js.flow +1 -1
- package/relay-hooks/useLazyLoadQuery.js.flow +5 -2
- package/relay-hooks/useLazyLoadQueryNode.js.flow +2 -2
- package/relay-hooks/useLoadMoreFunction.js.flow +3 -3
- package/relay-hooks/useLoadMoreFunction_EXPERIMENTAL.js.flow +2 -2
- package/relay-hooks/useMemoVariables.js.flow +1 -1
- package/relay-hooks/useMutation.js.flow +2 -2
- package/relay-hooks/usePaginationFragment.js.flow +11 -8
- package/relay-hooks/usePrefetchableForwardPaginationFragment.js.flow +4 -4
- package/relay-hooks/usePrefetchableForwardPaginationFragment_EXPERIMENTAL.js.flow +4 -4
- package/relay-hooks/usePreloadedQuery.js.flow +8 -8
- package/relay-hooks/useQueryLoader.js.flow +18 -14
- package/relay-hooks/useQueryLoader_EXPERIMENTAL.js.flow +5 -5
- package/relay-hooks/useRefetchableFragment.js.flow +11 -8
- package/relay-hooks/useRefetchableFragmentInternal.js.flow +13 -13
package/ReactRelayContext.js
CHANGED
|
@@ -45,8 +45,8 @@ type ContainerState = {
|
|
|
45
45
|
* updates.
|
|
46
46
|
*/
|
|
47
47
|
function createContainerWithFragments<
|
|
48
|
-
Props
|
|
49
|
-
TComponent
|
|
48
|
+
Props extends {...},
|
|
49
|
+
TComponent extends component(...Props),
|
|
50
50
|
>(
|
|
51
51
|
Component: TComponent,
|
|
52
52
|
fragments: FragmentMap,
|
|
@@ -265,7 +265,10 @@ function getRelayProp(environment: IEnvironment) {
|
|
|
265
265
|
* `fragmentSpec` is memoized once per environment, rather than once per
|
|
266
266
|
* instance of the container constructed/rendered.
|
|
267
267
|
*/
|
|
268
|
-
function createContainer<
|
|
268
|
+
function createContainer<
|
|
269
|
+
Props extends {...},
|
|
270
|
+
TComponent extends component(...Props),
|
|
271
|
+
>(
|
|
269
272
|
Component: TComponent,
|
|
270
273
|
fragmentSpec: GeneratedNodeMap,
|
|
271
274
|
): component(...$RelayProps<Props, RelayProp>) {
|
|
@@ -45,7 +45,7 @@ const queryRendererContext: ReactRelayQueryRendererContextType = {
|
|
|
45
45
|
rootIsQueryRenderer: true,
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
-
hook useDeepCompare<T
|
|
48
|
+
hook useDeepCompare<T extends {...}>(value: T): T {
|
|
49
49
|
const latestValue = React.useRef(value);
|
|
50
50
|
// $FlowFixMe[react-rule-unsafe-ref]
|
|
51
51
|
if (!areEqual(latestValue.current, value)) {
|
|
@@ -318,8 +318,8 @@ function toObserver(observerOrCallback: ?ObserverOrCallback): Observer<void> {
|
|
|
318
318
|
}
|
|
319
319
|
|
|
320
320
|
function createContainerWithFragments<
|
|
321
|
-
Props
|
|
322
|
-
TComponent
|
|
321
|
+
Props extends {...},
|
|
322
|
+
TComponent extends component(...Props),
|
|
323
323
|
>(
|
|
324
324
|
Component: TComponent,
|
|
325
325
|
fragments: FragmentMap,
|
|
@@ -941,7 +941,10 @@ function createContainerWithFragments<
|
|
|
941
941
|
* `fragmentSpec` is memoized once per environment, rather than once per
|
|
942
942
|
* instance of the container constructed/rendered.
|
|
943
943
|
*/
|
|
944
|
-
function createContainer<
|
|
944
|
+
function createContainer<
|
|
945
|
+
Props extends {...},
|
|
946
|
+
TComponent extends component(...Props),
|
|
947
|
+
>(
|
|
945
948
|
Component: TComponent,
|
|
946
949
|
fragmentSpec: GeneratedNodeMap,
|
|
947
950
|
connectionConfig: ConnectionConfig,
|
|
@@ -68,8 +68,8 @@ type ContainerState = {
|
|
|
68
68
|
* updates.
|
|
69
69
|
*/
|
|
70
70
|
function createContainerWithFragments<
|
|
71
|
-
Props
|
|
72
|
-
TComponent
|
|
71
|
+
Props extends {...},
|
|
72
|
+
TComponent extends component(...Props),
|
|
73
73
|
>(
|
|
74
74
|
Component: TComponent,
|
|
75
75
|
fragments: FragmentMap,
|
|
@@ -146,7 +146,7 @@ function createContainerWithFragments<
|
|
|
146
146
|
prevState: ContainerState,
|
|
147
147
|
): Partial<ContainerState> | null {
|
|
148
148
|
// Any props change could impact the query, so we mirror props in state.
|
|
149
|
-
// This is an unusual pattern, but necessary for this container
|
|
149
|
+
// This is an unusual pattern, but necessary for this container use case.
|
|
150
150
|
const {prevProps} = prevState;
|
|
151
151
|
const relayContext = assertRelayContext(nextProps.__relayContext);
|
|
152
152
|
const rootIsQueryRenderer = nextProps.__rootIsQueryRenderer ?? false;
|
|
@@ -350,7 +350,7 @@ function createContainerWithFragments<
|
|
|
350
350
|
typeof observerOrCallback === 'function'
|
|
351
351
|
? {
|
|
352
352
|
error: observerOrCallback,
|
|
353
|
-
// callback is not
|
|
353
|
+
// callback is not executed on complete or unsubscribe
|
|
354
354
|
// for backward compatibility
|
|
355
355
|
next: observerOrCallback,
|
|
356
356
|
}
|
|
@@ -429,7 +429,7 @@ function createContainerWithFragments<
|
|
|
429
429
|
})
|
|
430
430
|
.finally(() => {
|
|
431
431
|
// Finalizing a refetch should only clear this._refetchSubscription
|
|
432
|
-
// if the
|
|
432
|
+
// if the finalizing subscription is the most recent call.
|
|
433
433
|
if (this._refetchSubscription === refetchSubscription) {
|
|
434
434
|
this._refetchSubscription = null;
|
|
435
435
|
}
|
|
@@ -486,7 +486,10 @@ function getRelayProp(
|
|
|
486
486
|
* `fragmentSpec` is memoized once per environment, rather than once per
|
|
487
487
|
* instance of the container constructed/rendered.
|
|
488
488
|
*/
|
|
489
|
-
function createContainer<
|
|
489
|
+
function createContainer<
|
|
490
|
+
Props extends {...},
|
|
491
|
+
TComponent extends component(...Props),
|
|
492
|
+
>(
|
|
490
493
|
Component: TComponent,
|
|
491
494
|
fragmentSpec: GeneratedNodeMap,
|
|
492
495
|
taggedNode: GraphQLTaggedNode,
|
package/ReactRelayTypes.js.flow
CHANGED
|
@@ -99,7 +99,7 @@ export type $FragmentRef<T> = {
|
|
|
99
99
|
|
|
100
100
|
/* $FlowExpectedError[unclear-type]: Intentional so that it won't fail,
|
|
101
101
|
* even if the type we want to exclude doesn't exist in Props */
|
|
102
|
-
type LooseOmitRelayProps<Props, K
|
|
102
|
+
type LooseOmitRelayProps<Props, K extends keyof any> = Pick<
|
|
103
103
|
Props,
|
|
104
104
|
Exclude<keyof Props, K>,
|
|
105
105
|
>;
|
|
@@ -150,15 +150,13 @@ type MapRelayProp<T> = [+t: T] extends [+t: {+$fragmentType: empty, ...}]
|
|
|
150
150
|
? ?ReadonlyArray<?$FragmentRef<NonNullable<V>>>
|
|
151
151
|
: T;
|
|
152
152
|
|
|
153
|
-
export type RelayFragmentContainer<TComponent
|
|
154
|
-
...$RelayProps<React.ElementConfig<TComponent>, RelayProp>
|
|
155
|
-
);
|
|
153
|
+
export type RelayFragmentContainer<TComponent extends component(...empty)> =
|
|
154
|
+
component(...$RelayProps<React.ElementConfig<TComponent>, RelayProp>);
|
|
156
155
|
|
|
157
|
-
export type RelayPaginationContainer<TComponent
|
|
156
|
+
export type RelayPaginationContainer<TComponent extends component(...empty)> =
|
|
158
157
|
component(
|
|
159
158
|
...$RelayProps<React.ElementConfig<TComponent>, RelayPaginationProp>
|
|
160
159
|
);
|
|
161
160
|
|
|
162
|
-
export type RelayRefetchContainer<TComponent
|
|
163
|
-
...$RelayProps<React.ElementConfig<TComponent>, RelayRefetchProp>
|
|
164
|
-
);
|
|
161
|
+
export type RelayRefetchContainer<TComponent extends component(...empty)> =
|
|
162
|
+
component(...$RelayProps<React.ElementConfig<TComponent>, RelayRefetchProp>);
|
|
@@ -36,7 +36,7 @@ type ContainerCreator = (
|
|
|
36
36
|
* Helper to create the Relay HOCs with ref forwarding, setting the displayName
|
|
37
37
|
* and reading the React context.
|
|
38
38
|
*/
|
|
39
|
-
function buildReactRelayContainer<TBase
|
|
39
|
+
function buildReactRelayContainer<TBase extends component(...empty)>(
|
|
40
40
|
ComponentClass: TBase,
|
|
41
41
|
fragmentSpec: GeneratedNodeMap,
|
|
42
42
|
createContainerWithFragments: ContainerCreator,
|
|
@@ -15,7 +15,7 @@ import type {FragmentMap, Variables} from 'relay-runtime';
|
|
|
15
15
|
|
|
16
16
|
const {getSelector} = require('relay-runtime');
|
|
17
17
|
|
|
18
|
-
function getRootVariablesForFragments<TProps
|
|
18
|
+
function getRootVariablesForFragments<TProps extends {...}>(
|
|
19
19
|
fragments: FragmentMap,
|
|
20
20
|
props: TProps,
|
|
21
21
|
): Variables {
|
package/hooks.js
CHANGED
package/index.js
CHANGED
package/legacy.js
CHANGED
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-
|
|
4
|
+
"version": "0.0.0-main-ee43b7b9",
|
|
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-
|
|
23
|
+
"relay-runtime": "0.0.0-main-ee43b7b9"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"react": "^16.9.0 || ^17 || ^18 || ^19"
|
|
@@ -24,10 +24,10 @@ const warning = require('warning');
|
|
|
24
24
|
|
|
25
25
|
component EntryPointContainer<
|
|
26
26
|
// $FlowFixMe[unsupported-variance-annotation]
|
|
27
|
-
TRuntimeProps
|
|
28
|
-
TRenders
|
|
27
|
+
TRuntimeProps extends {...},
|
|
28
|
+
TRenders extends React.Node,
|
|
29
29
|
// $FlowFixMe[unsupported-variance-annotation]
|
|
30
|
-
TEntryPointComponent
|
|
30
|
+
TEntryPointComponent extends EntryPointComponent<
|
|
31
31
|
// $FlowExpectedError[unclear-type] s[unclear-type] Use any to accept all kinds of EntryPointComponent
|
|
32
32
|
any,
|
|
33
33
|
// $FlowExpectedError[unclear-type] s[unclear-type] Use any to accept all kinds of EntryPointComponent
|
|
@@ -48,7 +48,7 @@ export type LoadQueryOptions = {
|
|
|
48
48
|
+__nameForWarning?: ?string,
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
export type PreloadableConcreteRequest<+TQuery
|
|
51
|
+
export type PreloadableConcreteRequest<+TQuery extends OperationType> = {
|
|
52
52
|
kind: 'PreloadableConcreteRequest',
|
|
53
53
|
params: RequestParameters,
|
|
54
54
|
// Note: the phantom type parameter here helps ensures that the
|
|
@@ -62,14 +62,14 @@ export type PreloadableConcreteRequest<+TQuery: OperationType> = {
|
|
|
62
62
|
export type EnvironmentProviderOptions = {+[string]: unknown, ...};
|
|
63
63
|
|
|
64
64
|
export type PreloadedQuery<
|
|
65
|
-
+TQuery
|
|
65
|
+
+TQuery extends OperationType,
|
|
66
66
|
TEnvironmentProviderOptions = EnvironmentProviderOptions,
|
|
67
67
|
> =
|
|
68
68
|
| PreloadedQueryInner_DEPRECATED<TQuery, TEnvironmentProviderOptions>
|
|
69
69
|
| PreloadedQueryInner<TQuery, TEnvironmentProviderOptions>;
|
|
70
70
|
|
|
71
71
|
export type PreloadedQueryInner_DEPRECATED<
|
|
72
|
-
+TQuery
|
|
72
|
+
+TQuery extends OperationType,
|
|
73
73
|
TEnvironmentProviderOptions = EnvironmentProviderOptions,
|
|
74
74
|
> = {
|
|
75
75
|
+kind: 'PreloadedQuery_DEPRECATED',
|
|
@@ -86,7 +86,7 @@ export type PreloadedQueryInner_DEPRECATED<
|
|
|
86
86
|
};
|
|
87
87
|
|
|
88
88
|
export type PreloadedQueryInner<
|
|
89
|
-
+TQuery
|
|
89
|
+
+TQuery extends OperationType,
|
|
90
90
|
TEnvironmentProviderOptions = EnvironmentProviderOptions,
|
|
91
91
|
> = {
|
|
92
92
|
// Releases query data and cancels network request if still in flight
|
|
@@ -131,7 +131,7 @@ TEntryPointComponent - the root components
|
|
|
131
131
|
export type EntryPoint<
|
|
132
132
|
-TEntryPointParams,
|
|
133
133
|
// $FlowExpectedError[unclear-type] accepts any root component
|
|
134
|
-
+TEntryPointComponent
|
|
134
|
+
+TEntryPointComponent extends EntryPointComponent<any, any, any, any, any>,
|
|
135
135
|
> = Readonly<{
|
|
136
136
|
getPreloadProps: (
|
|
137
137
|
entryPointParams: TEntryPointParams,
|
|
@@ -178,7 +178,7 @@ export type EntryPointComponent<
|
|
|
178
178
|
TPreloadedEntryPoints = {},
|
|
179
179
|
TRuntimeProps = {},
|
|
180
180
|
TExtraProps = null,
|
|
181
|
-
+TRenders
|
|
181
|
+
+TRenders extends React.Node = React.Node,
|
|
182
182
|
> = component(
|
|
183
183
|
...EntryPointProps<
|
|
184
184
|
TPreloadedQueries,
|
|
@@ -191,8 +191,8 @@ export type EntryPointComponent<
|
|
|
191
191
|
// Return type of the `getPreloadProps(...)` of the entry point
|
|
192
192
|
export type PreloadProps<
|
|
193
193
|
// $FlowExpectedError[unclear-type] Need any to make it supertype of all PreloadedQuery
|
|
194
|
-
TPreloadedQueries
|
|
195
|
-
TPreloadedEntryPoints
|
|
194
|
+
TPreloadedQueries extends {+[string]: ?PreloadedQuery<any>},
|
|
195
|
+
TPreloadedEntryPoints extends {...},
|
|
196
196
|
TExtraProps = null,
|
|
197
197
|
TEnvironmentProviderOptions = EnvironmentProviderOptions,
|
|
198
198
|
> = Readonly<{
|
|
@@ -215,7 +215,7 @@ export type PreloadedEntryPoint<TEntryPointComponent> = Readonly<{
|
|
|
215
215
|
}>;
|
|
216
216
|
|
|
217
217
|
export type EntryPointElementConfig<
|
|
218
|
-
+TEntryPoint
|
|
218
|
+
+TEntryPoint extends EntryPoint<
|
|
219
219
|
// $FlowExpectedError[unclear-type] Need any to make it supertype of all InternalEntryPointRepresentation
|
|
220
220
|
any,
|
|
221
221
|
// $FlowExpectedError[unclear-type] Need any to make it supertype of all InternalEntryPointRepresentation
|
|
@@ -230,7 +230,7 @@ export type EntryPointElementConfig<
|
|
|
230
230
|
: empty;
|
|
231
231
|
|
|
232
232
|
export type ThinQueryParams<
|
|
233
|
-
+TQuery
|
|
233
|
+
+TQuery extends OperationType,
|
|
234
234
|
TEnvironmentProviderOptions,
|
|
235
235
|
> = Readonly<{
|
|
236
236
|
environmentProviderOptions?: ?TEnvironmentProviderOptions,
|
|
@@ -272,7 +272,7 @@ type ExtractThinQueryParams<T, TEnvironmentProviderOptions> = [+t: T] extends [
|
|
|
272
272
|
export type ExtractQueryTypes<
|
|
273
273
|
TEnvironmentProviderOptions,
|
|
274
274
|
// $FlowExpectedError[unclear-type] Need any to make it supertype of all PreloadedQuery
|
|
275
|
-
PreloadedQueries
|
|
275
|
+
PreloadedQueries extends {+[string]: ?PreloadedQuery<any>} | void,
|
|
276
276
|
> = {
|
|
277
277
|
[K in keyof PreloadedQueries]: ExtractThinQueryParams<
|
|
278
278
|
PreloadedQueries[K],
|
|
@@ -281,7 +281,7 @@ export type ExtractQueryTypes<
|
|
|
281
281
|
};
|
|
282
282
|
|
|
283
283
|
// $FlowFixMe[unclear-type]: we don't care about the props
|
|
284
|
-
export type RootComponentRenders<+C
|
|
284
|
+
export type RootComponentRenders<+C extends component(...any)> =
|
|
285
285
|
// $FlowFixMe[unclear-type]: we don't care about the props
|
|
286
286
|
C extends component(...any) renders infer R extends React.Node ? R : empty;
|
|
287
287
|
|
|
@@ -62,19 +62,19 @@ function stableStringify(value: unknown): string {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
function prepareEntryPoint<
|
|
65
|
-
TEntryPointParams
|
|
65
|
+
TEntryPointParams extends {...},
|
|
66
66
|
// $FlowExpectedError[unclear-type] Need any to make it supertype of all PreloadedQuery
|
|
67
|
-
TPreloadedQueries
|
|
68
|
-
TPreloadedEntryPoints
|
|
69
|
-
TRuntimeProps
|
|
67
|
+
TPreloadedQueries extends {+[string]: PreloadedQuery<any>},
|
|
68
|
+
TPreloadedEntryPoints extends {...},
|
|
69
|
+
TRuntimeProps extends {...},
|
|
70
70
|
TExtraProps,
|
|
71
|
-
TEntryPointComponent
|
|
71
|
+
TEntryPointComponent extends EntryPointComponent<
|
|
72
72
|
TPreloadedQueries,
|
|
73
73
|
TPreloadedEntryPoints,
|
|
74
74
|
TRuntimeProps,
|
|
75
75
|
TExtraProps,
|
|
76
76
|
>,
|
|
77
|
-
TEntryPoint
|
|
77
|
+
TEntryPoint extends EntryPoint<TEntryPointParams, TEntryPointComponent>,
|
|
78
78
|
>(
|
|
79
79
|
environmentProvider: IEnvironmentProvider<EnvironmentProviderOptions>,
|
|
80
80
|
entryPoint: TEntryPoint,
|
|
@@ -155,11 +155,11 @@ function prepareEntryPoint<
|
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
function LazyLoadEntryPointContainer_DEPRECATED<
|
|
158
|
-
TEntryPointParams
|
|
158
|
+
TEntryPointParams extends {...},
|
|
159
159
|
// $FlowExpectedError[unclear-type] Need any to make it supertype of all PreloadedQuery
|
|
160
|
-
TPreloadedQueries
|
|
161
|
-
TPreloadedEntryPoints
|
|
162
|
-
TRuntimeProps
|
|
160
|
+
TPreloadedQueries extends {+[string]: PreloadedQuery<any>},
|
|
161
|
+
TPreloadedEntryPoints extends {...},
|
|
162
|
+
TRuntimeProps extends {...},
|
|
163
163
|
TExtraProps,
|
|
164
164
|
>({
|
|
165
165
|
entryPoint,
|
|
@@ -93,14 +93,20 @@ export type MatchPointer = {
|
|
|
93
93
|
...
|
|
94
94
|
};
|
|
95
95
|
|
|
96
|
-
export type MatchContainerProps<
|
|
96
|
+
export type MatchContainerProps<
|
|
97
|
+
TProps extends {...},
|
|
98
|
+
TFallback extends React.Node,
|
|
99
|
+
> = {
|
|
97
100
|
+fallback?: ?TFallback,
|
|
98
101
|
+loader: (module: unknown) => component(...TProps),
|
|
99
102
|
+match: ?MatchPointer | ?TypenameOnlyPointer,
|
|
100
103
|
+props?: TProps,
|
|
101
104
|
};
|
|
102
105
|
|
|
103
|
-
function MatchContainer<
|
|
106
|
+
function MatchContainer<
|
|
107
|
+
TProps extends {...},
|
|
108
|
+
TFallback extends React.Node | null,
|
|
109
|
+
>({
|
|
104
110
|
fallback,
|
|
105
111
|
loader,
|
|
106
112
|
match,
|
|
@@ -30,7 +30,7 @@ type Props<TChildren> = Readonly<{
|
|
|
30
30
|
) => IActorEnvironment,
|
|
31
31
|
}>;
|
|
32
32
|
|
|
33
|
-
component RelayEnvironmentProvider<TChildren
|
|
33
|
+
component RelayEnvironmentProvider<TChildren extends React.Node>(
|
|
34
34
|
...props: Props<TChildren>
|
|
35
35
|
) renders TChildren {
|
|
36
36
|
const {children, environment, getEnvironmentForActor} = props;
|
|
@@ -30,8 +30,8 @@ import {
|
|
|
30
30
|
} from './utils';
|
|
31
31
|
|
|
32
32
|
type ExpectedReturnType<
|
|
33
|
-
TRefetchVariables
|
|
34
|
-
TLoadMoreVariables
|
|
33
|
+
TRefetchVariables extends Variables,
|
|
34
|
+
TLoadMoreVariables extends Variables,
|
|
35
35
|
TFragmentData,
|
|
36
36
|
> = {
|
|
37
37
|
data: TFragmentData,
|
|
@@ -30,8 +30,8 @@ import {
|
|
|
30
30
|
} from './utils';
|
|
31
31
|
|
|
32
32
|
type ExpectedReturnType<
|
|
33
|
-
TRefetchVariables
|
|
34
|
-
TLoadMoreVariables
|
|
33
|
+
TRefetchVariables extends Variables,
|
|
34
|
+
TLoadMoreVariables extends Variables,
|
|
35
35
|
TFragmentData,
|
|
36
36
|
> = {
|
|
37
37
|
data: TFragmentData,
|
|
@@ -60,10 +60,10 @@ type ReturnType<TVariables, TData, TKey> = {
|
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
hook useBlockingPaginationFragment<
|
|
63
|
-
TFragmentType
|
|
64
|
-
TVariables
|
|
63
|
+
TFragmentType extends FragmentType,
|
|
64
|
+
TVariables extends Variables,
|
|
65
65
|
TData,
|
|
66
|
-
TKey
|
|
66
|
+
TKey extends ?{+$fragmentSpreads: TFragmentType, ...},
|
|
67
67
|
>(
|
|
68
68
|
fragmentInput: RefetchableFragment<TFragmentType, TData, TVariables>,
|
|
69
69
|
parentFragmentRef: TKey,
|
|
@@ -161,7 +161,7 @@ hook useBlockingPaginationFragment<
|
|
|
161
161
|
};
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
hook useLoadMore<TVariables
|
|
164
|
+
hook useLoadMore<TVariables extends Variables>(args: {
|
|
165
165
|
disableStoreUpdates: () => void,
|
|
166
166
|
enableStoreUpdates: () => void,
|
|
167
167
|
...$Exact<Omit<UseLoadMoreFunctionArgs, 'observer' | 'onReset'>>,
|
|
@@ -20,13 +20,13 @@ const {useEffect, useState} = require('react');
|
|
|
20
20
|
const {RelayFeatureFlags, getFragmentIdentifier} = require('relay-runtime');
|
|
21
21
|
const warning = require('warning');
|
|
22
22
|
|
|
23
|
-
type ReturnType<TFragmentData
|
|
23
|
+
type ReturnType<TFragmentData extends unknown> = {
|
|
24
24
|
data: TFragmentData,
|
|
25
25
|
disableStoreUpdates: () => void,
|
|
26
26
|
enableStoreUpdates: () => void,
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
hook useFragmentNode<TFragmentData
|
|
29
|
+
hook useFragmentNode<TFragmentData extends unknown>(
|
|
30
30
|
fragmentNode: ReaderFragment,
|
|
31
31
|
fragmentRef: unknown,
|
|
32
32
|
componentDisplayName: string,
|
|
@@ -46,7 +46,7 @@ const {
|
|
|
46
46
|
const warning = require('warning');
|
|
47
47
|
|
|
48
48
|
export type RefetchFn<
|
|
49
|
-
TQuery
|
|
49
|
+
TQuery extends OperationType,
|
|
50
50
|
TOptions = Options,
|
|
51
51
|
> = RefetchFnExact<TQuery, TOptions>;
|
|
52
52
|
|
|
@@ -56,16 +56,16 @@ export type RefetchFn<
|
|
|
56
56
|
// - Or, expects /a subset/ of the query variables if the provided key type is
|
|
57
57
|
// /non-null/.
|
|
58
58
|
export type RefetchFnDynamic<
|
|
59
|
-
TQuery
|
|
60
|
-
TKey
|
|
59
|
+
TQuery extends OperationType,
|
|
60
|
+
TKey extends ?{+$data?: unknown, ...},
|
|
61
61
|
TOptions = Options,
|
|
62
62
|
> = [TKey] extends [{+$data?: unknown, ...}]
|
|
63
63
|
? RefetchFnInexact<TQuery, TOptions>
|
|
64
64
|
: RefetchFnExact<TQuery, TOptions>;
|
|
65
65
|
|
|
66
66
|
export type ReturnType<
|
|
67
|
-
TQuery
|
|
68
|
-
TKey
|
|
67
|
+
TQuery extends OperationType,
|
|
68
|
+
TKey extends ?{+$data?: unknown, ...},
|
|
69
69
|
TOptions = Options,
|
|
70
70
|
> = {
|
|
71
71
|
fragmentData: unknown,
|
|
@@ -91,12 +91,12 @@ type RefetchFnBase<TVars, TOptions> = (
|
|
|
91
91
|
options?: TOptions,
|
|
92
92
|
) => Disposable;
|
|
93
93
|
|
|
94
|
-
type RefetchFnExact<
|
|
95
|
-
|
|
96
|
-
TOptions,
|
|
97
|
-
>;
|
|
94
|
+
type RefetchFnExact<
|
|
95
|
+
TQuery extends OperationType,
|
|
96
|
+
TOptions = Options,
|
|
97
|
+
> = RefetchFnBase<VariablesOf<TQuery>, TOptions>;
|
|
98
98
|
type RefetchFnInexact<
|
|
99
|
-
TQuery
|
|
99
|
+
TQuery extends OperationType,
|
|
100
100
|
TOptions = Options,
|
|
101
101
|
> = RefetchFnBase<Partial<VariablesOf<TQuery>>, TOptions>;
|
|
102
102
|
|
|
@@ -163,8 +163,8 @@ function reducer(state: RefetchState, action: Action): RefetchState {
|
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
hook useRefetchableFragmentNode<
|
|
166
|
-
TQuery
|
|
167
|
-
TKey
|
|
166
|
+
TQuery extends OperationType,
|
|
167
|
+
TKey extends ?{+$data?: unknown, ...},
|
|
168
168
|
>(
|
|
169
169
|
fragmentNode: ReaderFragment,
|
|
170
170
|
parentFragmentRef: unknown,
|
|
@@ -367,7 +367,7 @@ hook useRefetchableFragmentNode<
|
|
|
367
367
|
};
|
|
368
368
|
}
|
|
369
369
|
|
|
370
|
-
hook useRefetchFunction<TQuery
|
|
370
|
+
hook useRefetchFunction<TQuery extends OperationType>(
|
|
371
371
|
componentDisplayName: string,
|
|
372
372
|
dispatch: (
|
|
373
373
|
| {
|
|
@@ -23,19 +23,19 @@ import type {
|
|
|
23
23
|
const {loadQuery} = require('./loadQuery');
|
|
24
24
|
|
|
25
25
|
function loadEntryPoint<
|
|
26
|
-
TEntryPointParams
|
|
26
|
+
TEntryPointParams extends {...},
|
|
27
27
|
// $FlowExpectedError[unclear-type] Need any to make it supertype of all PreloadedQuery
|
|
28
|
-
TPreloadedQueries
|
|
29
|
-
TPreloadedEntryPoints
|
|
30
|
-
TRuntimeProps
|
|
28
|
+
TPreloadedQueries extends {+[string]: PreloadedQuery<any>},
|
|
29
|
+
TPreloadedEntryPoints extends {...},
|
|
30
|
+
TRuntimeProps extends {...},
|
|
31
31
|
TExtraProps,
|
|
32
|
-
TEntryPointComponent
|
|
32
|
+
TEntryPointComponent extends EntryPointComponent<
|
|
33
33
|
TPreloadedQueries,
|
|
34
34
|
TPreloadedEntryPoints,
|
|
35
35
|
TRuntimeProps,
|
|
36
36
|
TExtraProps,
|
|
37
37
|
>,
|
|
38
|
-
TEntryPoint
|
|
38
|
+
TEntryPoint extends EntryPoint<TEntryPointParams, TEntryPointComponent>,
|
|
39
39
|
>(
|
|
40
40
|
environmentProvider: IEnvironmentProvider<EnvironmentProviderOptions>,
|
|
41
41
|
entryPoint: TEntryPoint,
|
|
@@ -66,7 +66,7 @@ declare function loadQuery<
|
|
|
66
66
|
): PreloadedQueryInner<QueryType<T>, TEnvironmentProviderOptions>;
|
|
67
67
|
|
|
68
68
|
function loadQuery<
|
|
69
|
-
TQuery
|
|
69
|
+
TQuery extends OperationType,
|
|
70
70
|
TEnvironmentProviderOptions = EnvironmentProviderOptions,
|
|
71
71
|
>(
|
|
72
72
|
environment: IEnvironment,
|
|
@@ -70,7 +70,10 @@ type PendingQueryEntry =
|
|
|
70
70
|
status: PreloadQueryStatus,
|
|
71
71
|
}>;
|
|
72
72
|
|
|
73
|
-
function preloadQuery<
|
|
73
|
+
function preloadQuery<
|
|
74
|
+
TQuery extends OperationType,
|
|
75
|
+
TEnvironmentProviderOptions,
|
|
76
|
+
>(
|
|
74
77
|
environment: IEnvironment,
|
|
75
78
|
preloadableRequest: GraphQLTaggedNode | PreloadableConcreteRequest<TQuery>,
|
|
76
79
|
variables: VariablesOf<TQuery>,
|
|
@@ -138,7 +141,7 @@ function preloadQuery<TQuery: OperationType, TEnvironmentProviderOptions>(
|
|
|
138
141
|
};
|
|
139
142
|
}
|
|
140
143
|
|
|
141
|
-
function preloadQueryDeduped<TQuery
|
|
144
|
+
function preloadQueryDeduped<TQuery extends OperationType>(
|
|
142
145
|
environment: IEnvironment,
|
|
143
146
|
pendingQueries: Map<string, PendingQueryEntry>,
|
|
144
147
|
preloadableRequest: GraphQLTaggedNode | PreloadableConcreteRequest<TQuery>,
|
|
@@ -22,19 +22,19 @@ import type {
|
|
|
22
22
|
const preloadQuery = require('./preloadQuery_DEPRECATED');
|
|
23
23
|
|
|
24
24
|
function prepareEntryPoint<
|
|
25
|
-
TEntryPointParams
|
|
25
|
+
TEntryPointParams extends {...},
|
|
26
26
|
// $FlowExpectedError[unclear-type] Need any to make it supertype of all PreloadedQuery
|
|
27
|
-
TPreloadedQueries
|
|
28
|
-
TPreloadedEntryPoints
|
|
29
|
-
TRuntimeProps
|
|
27
|
+
TPreloadedQueries extends {+[string]: PreloadedQuery<any>},
|
|
28
|
+
TPreloadedEntryPoints extends {...},
|
|
29
|
+
TRuntimeProps extends {...},
|
|
30
30
|
TExtraProps,
|
|
31
|
-
TEntryPointComponent
|
|
31
|
+
TEntryPointComponent extends EntryPointComponent<
|
|
32
32
|
TPreloadedQueries,
|
|
33
33
|
TPreloadedEntryPoints,
|
|
34
34
|
TRuntimeProps,
|
|
35
35
|
TExtraProps,
|
|
36
36
|
>,
|
|
37
|
-
TEntryPoint
|
|
37
|
+
TEntryPoint extends EntryPoint<TEntryPointParams, TEntryPointComponent>,
|
|
38
38
|
>(
|
|
39
39
|
environmentProvider: IEnvironmentProvider<EnvironmentProviderOptions>,
|
|
40
40
|
entryPoint: TEntryPoint,
|
|
@@ -20,7 +20,7 @@ const useLazyLoadQuery = require('./useLazyLoadQuery');
|
|
|
20
20
|
* These queries are consist of queries for client-only data,
|
|
21
21
|
* schematized via local schema extensions and/or Relay resolvers.
|
|
22
22
|
*/
|
|
23
|
-
hook useClientQuery<TVariables
|
|
23
|
+
hook useClientQuery<TVariables extends Variables, TData, TRawResponse>(
|
|
24
24
|
gqlQuery: ClientQuery<TVariables, TData, TRawResponse>,
|
|
25
25
|
variables: NoInfer<TVariables>,
|
|
26
26
|
options?: {
|
|
@@ -25,12 +25,12 @@ const useIsMountedRef = require('./useIsMountedRef');
|
|
|
25
25
|
const {useCallback, useEffect, useRef, useState} = require('react');
|
|
26
26
|
|
|
27
27
|
type UseEntryPointLoaderHookReturnType<
|
|
28
|
-
TEntryPointParams
|
|
29
|
-
TPreloadedQueries
|
|
30
|
-
TPreloadedEntryPoints
|
|
31
|
-
TRuntimeProps
|
|
28
|
+
TEntryPointParams extends {...},
|
|
29
|
+
TPreloadedQueries extends {...},
|
|
30
|
+
TPreloadedEntryPoints extends {...},
|
|
31
|
+
TRuntimeProps extends {...},
|
|
32
32
|
TExtraProps,
|
|
33
|
-
TEntryPointComponent
|
|
33
|
+
TEntryPointComponent extends EntryPointComponent<
|
|
34
34
|
TPreloadedQueries,
|
|
35
35
|
TPreloadedEntryPoints,
|
|
36
36
|
TRuntimeProps,
|
|
@@ -53,19 +53,19 @@ const initialNullEntryPointReferenceState: NullEntryPointReference = {
|
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
hook useLoadEntryPoint<
|
|
56
|
-
TEntryPointParams
|
|
56
|
+
TEntryPointParams extends {...},
|
|
57
57
|
// $FlowExpectedError[unclear-type] Need any to make it supertype of all PreloadedQuery
|
|
58
|
-
TPreloadedQueries
|
|
59
|
-
TPreloadedEntryPoints
|
|
60
|
-
TRuntimeProps
|
|
58
|
+
TPreloadedQueries extends {+[string]: PreloadedQuery<any>},
|
|
59
|
+
TPreloadedEntryPoints extends {...},
|
|
60
|
+
TRuntimeProps extends {...},
|
|
61
61
|
TExtraProps,
|
|
62
|
-
TEntryPointComponent
|
|
62
|
+
TEntryPointComponent extends EntryPointComponent<
|
|
63
63
|
TPreloadedQueries,
|
|
64
64
|
TPreloadedEntryPoints,
|
|
65
65
|
TRuntimeProps,
|
|
66
66
|
TExtraProps,
|
|
67
67
|
>,
|
|
68
|
-
TEntryPoint
|
|
68
|
+
TEntryPoint extends EntryPoint<TEntryPointParams, TEntryPointComponent>,
|
|
69
69
|
>(
|
|
70
70
|
environmentProvider: IEnvironmentProvider<EnvironmentProviderOptions>,
|
|
71
71
|
entryPoint: TEntryPoint,
|
|
@@ -24,25 +24,25 @@ type HasSpread<TFragmentType> = {
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
// if the key is non-nullable, return non-nullable value
|
|
27
|
-
declare hook useFragment<TFragmentType
|
|
27
|
+
declare hook useFragment<TFragmentType extends FragmentType, TData>(
|
|
28
28
|
fragment: Fragment<TFragmentType, TData>,
|
|
29
29
|
key: HasSpread<TFragmentType>,
|
|
30
30
|
): TData;
|
|
31
31
|
|
|
32
32
|
// if the key is nullable, return nullable value
|
|
33
|
-
declare hook useFragment<TFragmentType
|
|
33
|
+
declare hook useFragment<TFragmentType extends FragmentType, TData>(
|
|
34
34
|
fragment: Fragment<TFragmentType, TData>,
|
|
35
35
|
key: ?HasSpread<TFragmentType>,
|
|
36
36
|
): ?TData;
|
|
37
37
|
|
|
38
38
|
// if the key is a non-nullable array of keys, return non-nullable array
|
|
39
|
-
declare hook useFragment<TFragmentType
|
|
39
|
+
declare hook useFragment<TFragmentType extends FragmentType, TData>(
|
|
40
40
|
fragment: Fragment<TFragmentType, TData>,
|
|
41
41
|
key: ReadonlyArray<HasSpread<TFragmentType>>,
|
|
42
42
|
): TData;
|
|
43
43
|
|
|
44
44
|
// if the key is a nullable array of keys, return nullable array
|
|
45
|
-
declare hook useFragment<TFragmentType
|
|
45
|
+
declare hook useFragment<TFragmentType extends FragmentType, TData>(
|
|
46
46
|
fragment: Fragment<TFragmentType, TData>,
|
|
47
47
|
key: ?ReadonlyArray<HasSpread<TFragmentType>>,
|
|
48
48
|
): ?TData;
|
|
@@ -18,7 +18,7 @@ const useStaticFragmentNodeWarning = require('./useStaticFragmentNodeWarning');
|
|
|
18
18
|
const {getFragment} = require('relay-runtime');
|
|
19
19
|
|
|
20
20
|
hook useIsParentQueryActive<
|
|
21
|
-
TKey
|
|
21
|
+
TKey extends ?{+$data?: unknown, +$fragmentSpreads: FragmentType, ...},
|
|
22
22
|
>(
|
|
23
23
|
fragmentInput: GraphQLTaggedNode,
|
|
24
24
|
fragmentRef: TKey,
|
|
@@ -30,7 +30,10 @@ const {
|
|
|
30
30
|
// This separate type export is only needed as long as we are injecting
|
|
31
31
|
// a separate hooks implementation in ./HooksImplementation -- it can
|
|
32
32
|
// be removed after we stop doing that.
|
|
33
|
-
export type UseLazyLoadQueryHookType = hook <
|
|
33
|
+
export type UseLazyLoadQueryHookType = hook <
|
|
34
|
+
TVariables extends Variables,
|
|
35
|
+
TData,
|
|
36
|
+
>(
|
|
34
37
|
gqlQuery: Query<TVariables, TData>,
|
|
35
38
|
variables: TVariables,
|
|
36
39
|
options?: Options,
|
|
@@ -86,7 +89,7 @@ type Options = {
|
|
|
86
89
|
* @returns - `data`: Object that contains data which has been read out from the Relay store; the object matches the shape of specified query.
|
|
87
90
|
* - The Flow type for data will also match this shape, and contain types derived from the GraphQL Schema. For example, the type of `data` above is: `{| user: ?{| name: ?string |} |}`.
|
|
88
91
|
*/
|
|
89
|
-
hook useLazyLoadQuery<TVariables
|
|
92
|
+
hook useLazyLoadQuery<TVariables extends Variables, TData>(
|
|
90
93
|
/**
|
|
91
94
|
* GraphQL query specified using a `graphql` template literal.
|
|
92
95
|
*/
|
|
@@ -56,8 +56,8 @@ export type LazyLoadQueryNodeParams =
|
|
|
56
56
|
| LazyLoadQueryNodeParamsWithoutQuery;
|
|
57
57
|
|
|
58
58
|
hook useLazyLoadQueryNode<
|
|
59
|
-
TQuery
|
|
60
|
-
TParams
|
|
59
|
+
TQuery extends OperationType,
|
|
60
|
+
TParams extends LazyLoadQueryNodeParams = LazyLoadQueryNodeParams,
|
|
61
61
|
>(
|
|
62
62
|
params: TParams,
|
|
63
63
|
): TParams extends LazyLoadQueryNodeParamsWithQuery
|
|
@@ -40,7 +40,7 @@ const {
|
|
|
40
40
|
} = require('relay-runtime');
|
|
41
41
|
const warning = require('warning');
|
|
42
42
|
|
|
43
|
-
export type LoadMoreFn<TVariables
|
|
43
|
+
export type LoadMoreFn<TVariables extends Variables> = (
|
|
44
44
|
count: number,
|
|
45
45
|
options?: {
|
|
46
46
|
onComplete?: (Error | null) => void,
|
|
@@ -62,7 +62,7 @@ export type UseLoadMoreFunctionArgs = {
|
|
|
62
62
|
onReset: () => void,
|
|
63
63
|
};
|
|
64
64
|
|
|
65
|
-
hook useLoadMoreFunction<TVariables
|
|
65
|
+
hook useLoadMoreFunction<TVariables extends Variables>(
|
|
66
66
|
args: UseLoadMoreFunctionArgs,
|
|
67
67
|
): [LoadMoreFn<TVariables>, boolean, () => void] {
|
|
68
68
|
if (RelayFeatureFlags.ENABLE_ACTIVITY_COMPATIBILITY) {
|
|
@@ -76,7 +76,7 @@ hook useLoadMoreFunction<TVariables: Variables>(
|
|
|
76
76
|
return useLoadMoreFunction_CURRENT(args);
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
hook useLoadMoreFunction_CURRENT<TVariables
|
|
79
|
+
hook useLoadMoreFunction_CURRENT<TVariables extends Variables>(
|
|
80
80
|
args: UseLoadMoreFunctionArgs,
|
|
81
81
|
): [LoadMoreFn<TVariables>, boolean, () => void] {
|
|
82
82
|
const {
|
|
@@ -38,7 +38,7 @@ const {
|
|
|
38
38
|
} = require('relay-runtime');
|
|
39
39
|
const warning = require('warning');
|
|
40
40
|
|
|
41
|
-
export type LoadMoreFn<TVariables
|
|
41
|
+
export type LoadMoreFn<TVariables extends Variables> = (
|
|
42
42
|
count: number,
|
|
43
43
|
options?: {
|
|
44
44
|
onComplete?: (Error | null) => void,
|
|
@@ -60,7 +60,7 @@ export type UseLoadMoreFunctionArgs = {
|
|
|
60
60
|
onReset: () => void,
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
hook useLoadMoreFunction_EXPERIMENTAL<TVariables
|
|
63
|
+
hook useLoadMoreFunction_EXPERIMENTAL<TVariables extends Variables>(
|
|
64
64
|
args: UseLoadMoreFunctionArgs,
|
|
65
65
|
): [
|
|
66
66
|
// Function to load more data
|
|
@@ -21,7 +21,7 @@ const {useState} = require('react');
|
|
|
21
21
|
* This is useful when a `variables` object is used as a value in a depencency
|
|
22
22
|
* array as it might often be constructed during render.
|
|
23
23
|
*/
|
|
24
|
-
hook useMemoVariables<TVariables
|
|
24
|
+
hook useMemoVariables<TVariables extends Variables | null>(
|
|
25
25
|
variables: TVariables,
|
|
26
26
|
): TVariables {
|
|
27
27
|
const [mirroredVariables, setMirroredVariables] = useState(variables);
|
|
@@ -30,7 +30,7 @@ const {commitMutation: defaultCommitMutation} = require('relay-runtime');
|
|
|
30
30
|
|
|
31
31
|
const {useState, useEffect, useRef, useCallback} = React;
|
|
32
32
|
|
|
33
|
-
export type UseMutationConfig<TMutation
|
|
33
|
+
export type UseMutationConfig<TMutation extends MutationParameters> = {
|
|
34
34
|
configs?: Array<DeclarativeMutationConfig>,
|
|
35
35
|
onError?: ?(error: Error) => void,
|
|
36
36
|
onCompleted?: ?(
|
|
@@ -63,7 +63,7 @@ type UseMutationConfigInternal<TVariables, TData, TRawResponse> = {
|
|
|
63
63
|
variables: TVariables,
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
-
hook useMutation<TVariables
|
|
66
|
+
hook useMutation<TVariables extends Variables, TData, TRawResponse = {...}>(
|
|
67
67
|
mutation: Mutation<TVariables, TData, TRawResponse>,
|
|
68
68
|
commitMutationFn?: (
|
|
69
69
|
environment: IEnvironment,
|
|
@@ -32,7 +32,10 @@ const {
|
|
|
32
32
|
getPaginationMetadata,
|
|
33
33
|
} = require('relay-runtime');
|
|
34
34
|
|
|
35
|
-
type RefetchVariables<
|
|
35
|
+
type RefetchVariables<
|
|
36
|
+
TVariables,
|
|
37
|
+
TKey extends ?{+$fragmentSpreads: unknown, ...},
|
|
38
|
+
> =
|
|
36
39
|
// NOTE: This type ensures that the type of the returned variables is either:
|
|
37
40
|
// - nullable if the provided ref type is nullable
|
|
38
41
|
// - non-nullable if the provided ref type is non-nullable
|
|
@@ -70,20 +73,20 @@ export type ReturnType<TVariables, TData, TKey> = {
|
|
|
70
73
|
// a separate hooks implementation in ./HooksImplementation -- it can
|
|
71
74
|
// be removed after we stop doing that.
|
|
72
75
|
export type UsePaginationFragmentType = <
|
|
73
|
-
TFragmentType
|
|
74
|
-
TVariables
|
|
76
|
+
TFragmentType extends FragmentType,
|
|
77
|
+
TVariables extends Variables,
|
|
75
78
|
TData,
|
|
76
|
-
TKey
|
|
79
|
+
TKey extends ?{+$fragmentSpreads: TFragmentType, ...},
|
|
77
80
|
>(
|
|
78
81
|
fragmentInput: RefetchableFragment<TFragmentType, TData, TVariables>,
|
|
79
82
|
parentFragmentRef: TKey,
|
|
80
83
|
) => ReturnType<TVariables, TData, TKey>;
|
|
81
84
|
|
|
82
85
|
hook usePaginationFragment<
|
|
83
|
-
TFragmentType
|
|
84
|
-
TVariables
|
|
86
|
+
TFragmentType extends FragmentType,
|
|
87
|
+
TVariables extends Variables,
|
|
85
88
|
TData,
|
|
86
|
-
TKey
|
|
89
|
+
TKey extends ?{+$fragmentSpreads: TFragmentType, ...},
|
|
87
90
|
>(
|
|
88
91
|
fragmentInput: RefetchableFragment<TFragmentType, TData, TVariables>,
|
|
89
92
|
parentFragmentRef: TKey,
|
|
@@ -168,7 +171,7 @@ hook usePaginationFragment<
|
|
|
168
171
|
};
|
|
169
172
|
}
|
|
170
173
|
|
|
171
|
-
hook useLoadMore<TVariables
|
|
174
|
+
hook useLoadMore<TVariables extends Variables>(
|
|
172
175
|
args: Omit<UseLoadMoreFunctionArgs, 'observer' | 'onReset'>,
|
|
173
176
|
): [LoadMoreFn<TVariables>, boolean, boolean, () => void] {
|
|
174
177
|
const environment = useRelayEnvironment();
|
|
@@ -43,7 +43,7 @@ const {
|
|
|
43
43
|
getValueAtPath,
|
|
44
44
|
} = require('relay-runtime');
|
|
45
45
|
|
|
46
|
-
type LoadMoreFn<TVariables
|
|
46
|
+
type LoadMoreFn<TVariables extends Variables> = (
|
|
47
47
|
count: number,
|
|
48
48
|
options?: {
|
|
49
49
|
onComplete?: (Error | null) => void,
|
|
@@ -79,11 +79,11 @@ export type GetExtraVariablesFn<TEdgeData, TData, TVariables, TKey> = ({
|
|
|
79
79
|
}) => Partial<TVariables>;
|
|
80
80
|
|
|
81
81
|
hook usePrefetchableForwardPaginationFragment<
|
|
82
|
-
TFragmentType
|
|
83
|
-
TVariables
|
|
82
|
+
TFragmentType extends FragmentType,
|
|
83
|
+
TVariables extends Variables,
|
|
84
84
|
TData,
|
|
85
85
|
TEdgeData,
|
|
86
|
-
TKey
|
|
86
|
+
TKey extends ?{+$fragmentSpreads: TFragmentType, ...},
|
|
87
87
|
>(
|
|
88
88
|
fragmentInput: PrefetchableRefetchableFragment<
|
|
89
89
|
TFragmentType,
|
|
@@ -43,7 +43,7 @@ const {
|
|
|
43
43
|
getValueAtPath,
|
|
44
44
|
} = require('relay-runtime');
|
|
45
45
|
|
|
46
|
-
type LoadMoreFn<TVariables
|
|
46
|
+
type LoadMoreFn<TVariables extends Variables> = (
|
|
47
47
|
count: number,
|
|
48
48
|
options?: {
|
|
49
49
|
onComplete?: (Error | null) => void,
|
|
@@ -79,11 +79,11 @@ export type GetExtraVariablesFn<TEdgeData, TData, TVariables, TKey> = ({
|
|
|
79
79
|
}) => Partial<TVariables>;
|
|
80
80
|
|
|
81
81
|
hook usePrefetchableForwardPaginationFragment_EXPERIMENTAL<
|
|
82
|
-
TFragmentType
|
|
83
|
-
TVariables
|
|
82
|
+
TFragmentType extends FragmentType,
|
|
83
|
+
TVariables extends Variables,
|
|
84
84
|
TData,
|
|
85
85
|
TEdgeData,
|
|
86
|
-
TKey
|
|
86
|
+
TKey extends ?{+$fragmentSpreads: TFragmentType, ...},
|
|
87
87
|
>(
|
|
88
88
|
fragmentInput: PrefetchableRefetchableFragment<
|
|
89
89
|
TFragmentType,
|
|
@@ -29,7 +29,7 @@ const {
|
|
|
29
29
|
const warning = require('warning');
|
|
30
30
|
|
|
31
31
|
type PreloadedQuery<
|
|
32
|
-
TVariables
|
|
32
|
+
TVariables extends Variables,
|
|
33
33
|
TData,
|
|
34
34
|
TRawResponse,
|
|
35
35
|
TEnvironmentProviderOptions = EnvironmentProviderOptions,
|
|
@@ -52,9 +52,9 @@ type PreloadedQuery<
|
|
|
52
52
|
>;
|
|
53
53
|
|
|
54
54
|
declare hook usePreloadedQuery<
|
|
55
|
-
TVariables
|
|
55
|
+
TVariables extends Variables,
|
|
56
56
|
TData,
|
|
57
|
-
TRawResponse
|
|
57
|
+
TRawResponse extends ?{...} = void,
|
|
58
58
|
>(
|
|
59
59
|
gqlQuery:
|
|
60
60
|
| Query<TVariables, TData, TRawResponse>
|
|
@@ -66,9 +66,9 @@ declare hook usePreloadedQuery<
|
|
|
66
66
|
): TData;
|
|
67
67
|
|
|
68
68
|
declare hook usePreloadedQuery<
|
|
69
|
-
TVariables
|
|
69
|
+
TVariables extends Variables,
|
|
70
70
|
TData,
|
|
71
|
-
TRawResponse
|
|
71
|
+
TRawResponse extends ?{...} = void,
|
|
72
72
|
>(
|
|
73
73
|
gqlQuery:
|
|
74
74
|
| Query<TVariables, TData, TRawResponse>
|
|
@@ -80,10 +80,10 @@ declare hook usePreloadedQuery<
|
|
|
80
80
|
): ?TData;
|
|
81
81
|
|
|
82
82
|
hook usePreloadedQuery<
|
|
83
|
-
TVariables
|
|
83
|
+
TVariables extends Variables,
|
|
84
84
|
TData,
|
|
85
|
-
TRawResponse
|
|
86
|
-
TPreloadedQuery
|
|
85
|
+
TRawResponse extends ?{...} = void,
|
|
86
|
+
TPreloadedQuery extends ?PreloadedQuery<
|
|
87
87
|
TVariables,
|
|
88
88
|
TData,
|
|
89
89
|
NonNullable<TRawResponse>,
|
|
@@ -30,7 +30,7 @@ const useRelayEnvironment = require('./useRelayEnvironment');
|
|
|
30
30
|
const {useCallback, useEffect, useRef, useState} = require('react');
|
|
31
31
|
const {RelayFeatureFlags, getRequest} = require('relay-runtime');
|
|
32
32
|
|
|
33
|
-
export type LoaderFn<TQuery
|
|
33
|
+
export type LoaderFn<TQuery extends OperationType> = (
|
|
34
34
|
variables: TQuery['variables'],
|
|
35
35
|
options?: UseQueryLoaderLoadQueryOptions,
|
|
36
36
|
) => void;
|
|
@@ -51,10 +51,10 @@ const initialNullQueryReferenceState: NullQueryReference = {
|
|
|
51
51
|
};
|
|
52
52
|
|
|
53
53
|
function requestIsLiveQuery<
|
|
54
|
-
TVariables
|
|
54
|
+
TVariables extends Variables,
|
|
55
55
|
TData,
|
|
56
|
-
TRawResponse
|
|
57
|
-
TQuery
|
|
56
|
+
TRawResponse extends ?{...} = void,
|
|
57
|
+
TQuery extends OperationType = {
|
|
58
58
|
response: TData,
|
|
59
59
|
variables: TVariables,
|
|
60
60
|
rawResponse?: NonNullable<TRawResponse>,
|
|
@@ -72,9 +72,9 @@ function requestIsLiveQuery<
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
export type UseQueryLoaderHookReturnType<
|
|
75
|
-
TVariables
|
|
75
|
+
TVariables extends Variables,
|
|
76
76
|
TData,
|
|
77
|
-
TRawResponse
|
|
77
|
+
TRawResponse extends ?{...} = void,
|
|
78
78
|
> = [
|
|
79
79
|
?PreloadedQuery<{
|
|
80
80
|
response: TData,
|
|
@@ -86,17 +86,17 @@ export type UseQueryLoaderHookReturnType<
|
|
|
86
86
|
];
|
|
87
87
|
|
|
88
88
|
declare function useQueryLoader<
|
|
89
|
-
TVariables
|
|
89
|
+
TVariables extends Variables,
|
|
90
90
|
TData,
|
|
91
|
-
TRawResponse
|
|
91
|
+
TRawResponse extends ?{...} = void,
|
|
92
92
|
>(
|
|
93
93
|
preloadableRequest: Query<TVariables, TData, TRawResponse>,
|
|
94
94
|
): UseQueryLoaderHookReturnType<TVariables, TData>;
|
|
95
95
|
|
|
96
96
|
declare function useQueryLoader<
|
|
97
|
-
TVariables
|
|
97
|
+
TVariables extends Variables,
|
|
98
98
|
TData,
|
|
99
|
-
TRawResponse
|
|
99
|
+
TRawResponse extends ?{...} = void,
|
|
100
100
|
>(
|
|
101
101
|
preloadableRequest: Query<TVariables, TData, TRawResponse>,
|
|
102
102
|
initialQueryReference: ?PreloadedQuery<{
|
|
@@ -106,12 +106,16 @@ declare function useQueryLoader<
|
|
|
106
106
|
}>,
|
|
107
107
|
): UseQueryLoaderHookReturnType<TVariables, TData>;
|
|
108
108
|
|
|
109
|
-
declare function useQueryLoader<TQuery
|
|
109
|
+
declare function useQueryLoader<TQuery extends OperationType>(
|
|
110
110
|
preloadableRequest: PreloadableConcreteRequest<TQuery>,
|
|
111
111
|
initialQueryReference?: ?PreloadedQuery<TQuery>,
|
|
112
112
|
): UseQueryLoaderHookReturnType<TQuery['variables'], TQuery['response']>;
|
|
113
113
|
|
|
114
|
-
hook useQueryLoader<
|
|
114
|
+
hook useQueryLoader<
|
|
115
|
+
TVariables extends Variables,
|
|
116
|
+
TData,
|
|
117
|
+
TRawResponse extends ?{...} = void,
|
|
118
|
+
>(
|
|
115
119
|
preloadableRequest: Query<TVariables, TData, TRawResponse>,
|
|
116
120
|
initialQueryReference?: ?PreloadedQuery<{
|
|
117
121
|
response: TData,
|
|
@@ -133,9 +137,9 @@ hook useQueryLoader<TVariables: Variables, TData, TRawResponse: ?{...} = void>(
|
|
|
133
137
|
}
|
|
134
138
|
|
|
135
139
|
hook useQueryLoader_CURRENT<
|
|
136
|
-
TVariables
|
|
140
|
+
TVariables extends Variables,
|
|
137
141
|
TData,
|
|
138
|
-
TRawResponse
|
|
142
|
+
TRawResponse extends ?{...} = void,
|
|
139
143
|
>(
|
|
140
144
|
preloadableRequest: Query<TVariables, TData, TRawResponse>,
|
|
141
145
|
initialQueryReference?: ?PreloadedQuery<{
|
|
@@ -40,10 +40,10 @@ const initialNullQueryReferenceState: NullQueryReference = {
|
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
function requestIsLiveQuery<
|
|
43
|
-
TVariables
|
|
43
|
+
TVariables extends Variables,
|
|
44
44
|
TData,
|
|
45
|
-
TRawResponse
|
|
46
|
-
TQuery
|
|
45
|
+
TRawResponse extends ?{...} = void,
|
|
46
|
+
TQuery extends OperationType = {
|
|
47
47
|
response: TData,
|
|
48
48
|
variables: TVariables,
|
|
49
49
|
rawResponse?: NonNullable<TRawResponse>,
|
|
@@ -63,9 +63,9 @@ function requestIsLiveQuery<
|
|
|
63
63
|
const CLEANUP_TIMEOUT = 1000 * 60 * 5; // 5 minutes;
|
|
64
64
|
|
|
65
65
|
hook useQueryLoader_EXPERIMENTAL<
|
|
66
|
-
TVariables
|
|
66
|
+
TVariables extends Variables,
|
|
67
67
|
TData,
|
|
68
|
-
TRawResponse
|
|
68
|
+
TRawResponse extends ?{...} = void,
|
|
69
69
|
>(
|
|
70
70
|
preloadableRequest: Query<TVariables, TData, TRawResponse>,
|
|
71
71
|
initialQueryReference?: ?PreloadedQuery<{
|
|
@@ -24,7 +24,10 @@ const useStaticFragmentNodeWarning = require('./useStaticFragmentNodeWarning');
|
|
|
24
24
|
const {useDebugValue} = require('react');
|
|
25
25
|
const {getFragment} = require('relay-runtime');
|
|
26
26
|
|
|
27
|
-
type RefetchVariables<
|
|
27
|
+
type RefetchVariables<
|
|
28
|
+
TVariables,
|
|
29
|
+
TKey extends ?{+$fragmentSpreads: unknown, ...},
|
|
30
|
+
> =
|
|
28
31
|
// NOTE: This type ensures that the type of the returned variables is either:
|
|
29
32
|
// - nullable if the provided ref type is nullable
|
|
30
33
|
// - non-nullable if the provided ref type is non-nullable
|
|
@@ -45,7 +48,7 @@ export type RefetchFn<TVariables, TKey, TOptions = Options> = RefetchFnBase<
|
|
|
45
48
|
export type ReturnType<
|
|
46
49
|
TVariables,
|
|
47
50
|
TData,
|
|
48
|
-
TKey
|
|
51
|
+
TKey extends ?{+$fragmentSpreads: unknown, ...},
|
|
49
52
|
> = [
|
|
50
53
|
// NOTE: This type ensures that the type of the returned data is either:
|
|
51
54
|
// - nullable if the provided ref type is nullable
|
|
@@ -57,20 +60,20 @@ export type ReturnType<
|
|
|
57
60
|
];
|
|
58
61
|
|
|
59
62
|
export type UseRefetchableFragmentType = <
|
|
60
|
-
TFragmentType
|
|
61
|
-
TVariables
|
|
63
|
+
TFragmentType extends FragmentType,
|
|
64
|
+
TVariables extends Variables,
|
|
62
65
|
TData,
|
|
63
|
-
TKey
|
|
66
|
+
TKey extends ?{+$fragmentSpreads: TFragmentType, ...},
|
|
64
67
|
>(
|
|
65
68
|
fragment: RefetchableFragment<TFragmentType, TData, TVariables>,
|
|
66
69
|
key: TKey,
|
|
67
70
|
) => ReturnType<TVariables, TData, TKey>;
|
|
68
71
|
|
|
69
72
|
hook useRefetchableFragment<
|
|
70
|
-
TFragmentType
|
|
71
|
-
TVariables
|
|
73
|
+
TFragmentType extends FragmentType,
|
|
74
|
+
TVariables extends Variables,
|
|
72
75
|
TData,
|
|
73
|
-
TKey
|
|
76
|
+
TKey extends ?{+$fragmentSpreads: TFragmentType, ...},
|
|
74
77
|
>(
|
|
75
78
|
fragmentInput: RefetchableFragment<TFragmentType, TData, TVariables>,
|
|
76
79
|
fragmentRef: TKey,
|
|
@@ -46,7 +46,7 @@ const {
|
|
|
46
46
|
const warning = require('warning');
|
|
47
47
|
|
|
48
48
|
export type RefetchFn<
|
|
49
|
-
TQuery
|
|
49
|
+
TQuery extends OperationType,
|
|
50
50
|
TOptions = Options,
|
|
51
51
|
> = RefetchFnExact<TQuery, TOptions>;
|
|
52
52
|
|
|
@@ -56,16 +56,16 @@ export type RefetchFn<
|
|
|
56
56
|
// - Or, expects /a subset/ of the query variables if the provided key type is
|
|
57
57
|
// /non-null/.
|
|
58
58
|
export type RefetchFnDynamic<
|
|
59
|
-
TQuery
|
|
60
|
-
TKey
|
|
59
|
+
TQuery extends OperationType,
|
|
60
|
+
TKey extends ?{+$data?: unknown, ...},
|
|
61
61
|
TOptions = Options,
|
|
62
62
|
> = [TKey] extends [{+$data?: unknown, ...}]
|
|
63
63
|
? RefetchFnInexact<TQuery, TOptions>
|
|
64
64
|
: RefetchFnExact<TQuery, TOptions>;
|
|
65
65
|
|
|
66
66
|
export type ReturnType<
|
|
67
|
-
TQuery
|
|
68
|
-
TKey
|
|
67
|
+
TQuery extends OperationType,
|
|
68
|
+
TKey extends ?{+$data?: unknown, ...},
|
|
69
69
|
TOptions = Options,
|
|
70
70
|
> = {
|
|
71
71
|
fragmentData: unknown,
|
|
@@ -89,12 +89,12 @@ type RefetchFnBase<TVars, TOptions> = (
|
|
|
89
89
|
options?: TOptions,
|
|
90
90
|
) => Disposable;
|
|
91
91
|
|
|
92
|
-
type RefetchFnExact<
|
|
93
|
-
|
|
94
|
-
TOptions,
|
|
95
|
-
>;
|
|
92
|
+
type RefetchFnExact<
|
|
93
|
+
TQuery extends OperationType,
|
|
94
|
+
TOptions = Options,
|
|
95
|
+
> = RefetchFnBase<VariablesOf<TQuery>, TOptions>;
|
|
96
96
|
type RefetchFnInexact<
|
|
97
|
-
TQuery
|
|
97
|
+
TQuery extends OperationType,
|
|
98
98
|
TOptions = Options,
|
|
99
99
|
> = RefetchFnBase<Readonly<Partial<VariablesOf<TQuery>>>, TOptions>;
|
|
100
100
|
|
|
@@ -161,8 +161,8 @@ function reducer(state: RefetchState, action: Action): RefetchState {
|
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
hook useRefetchableFragmentInternal<
|
|
164
|
-
TQuery
|
|
165
|
-
TKey
|
|
164
|
+
TQuery extends OperationType,
|
|
165
|
+
TKey extends ?{+$data?: unknown, ...},
|
|
166
166
|
>(
|
|
167
167
|
fragmentNode: ReaderFragment,
|
|
168
168
|
parentFragmentRef: unknown,
|
|
@@ -355,7 +355,7 @@ hook useRefetchableFragmentInternal<
|
|
|
355
355
|
};
|
|
356
356
|
}
|
|
357
357
|
|
|
358
|
-
hook useRefetchFunction<TQuery
|
|
358
|
+
hook useRefetchFunction<TQuery extends OperationType>(
|
|
359
359
|
componentDisplayName: string,
|
|
360
360
|
dispatch: (
|
|
361
361
|
| {
|