react-relay 0.0.0-main-84ea7a01 → 0.0.0-main-d9628ba3
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/ReactRelayPaginationContainer.js.flow +1 -1
- package/ReactRelayTypes.js.flow +8 -8
- package/__flowtests__/RelayModern-flowtest.js.flow +1 -1
- package/__flowtests__/RelayModernFlowtest_users.graphql.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/__flowtests__/utils.js.flow +4 -4
- package/relay-hooks/getConnectionState.js.flow +1 -1
- package/relay-hooks/legacy/FragmentResource.js.flow +5 -5
- package/relay-hooks/legacy/useRefetchableFragmentNode.js.flow +2 -2
- package/relay-hooks/readFragmentInternal.js.flow +2 -2
- package/relay-hooks/useFragment.js.flow +2 -2
- package/relay-hooks/useFragmentInternal_CURRENT.js.flow +3 -3
- package/relay-hooks/useFragmentInternal_EXPERIMENTAL.js.flow +3 -3
- package/relay-hooks/useLoadMoreFunction.js.flow +1 -1
- package/relay-hooks/useLoadMoreFunction_EXPERIMENTAL.js.flow +1 -1
- package/relay-hooks/usePrefetchableForwardPaginationFragment.js.flow +1 -1
- package/relay-hooks/usePrefetchableForwardPaginationFragment_EXPERIMENTAL.js.flow +1 -1
- package/relay-hooks/useRefetchableFragmentInternal.js.flow +2 -2
- package/relay-hooks/useSubscribeToInvalidationState.js.flow +1 -1
package/ReactRelayContext.js
CHANGED
package/ReactRelayTypes.js.flow
CHANGED
|
@@ -123,31 +123,31 @@ type MapRelayProp<T> = [+t: T] extends [+t: {+$fragmentType: empty, ...}]
|
|
|
123
123
|
: [+t: T] extends [+t: ?{+$fragmentType: FragmentType, ...}]
|
|
124
124
|
? ?$FragmentRef<NonNullable<T>>
|
|
125
125
|
: [+t: T] extends [
|
|
126
|
-
+t:
|
|
126
|
+
+t: ReadonlyArray<
|
|
127
127
|
infer V extends {+$fragmentType: FragmentType, ...},
|
|
128
128
|
>,
|
|
129
129
|
]
|
|
130
|
-
?
|
|
130
|
+
? ReadonlyArray<$FragmentRef<V>>
|
|
131
131
|
: [+t: T] extends [
|
|
132
|
-
+t:
|
|
132
|
+
+t: ?ReadonlyArray<
|
|
133
133
|
infer V extends {+$fragmentType: FragmentType, ...},
|
|
134
134
|
>,
|
|
135
135
|
]
|
|
136
|
-
?
|
|
136
|
+
? ?ReadonlyArray<$FragmentRef<V>>
|
|
137
137
|
: [+t: T] extends [
|
|
138
|
-
+t:
|
|
138
|
+
+t: ReadonlyArray<?infer V extends {
|
|
139
139
|
+$fragmentType: FragmentType,
|
|
140
140
|
...
|
|
141
141
|
}>,
|
|
142
142
|
]
|
|
143
|
-
?
|
|
143
|
+
? ReadonlyArray<?$FragmentRef<NonNullable<V>>>
|
|
144
144
|
: [+t: T] extends [
|
|
145
|
-
+t:
|
|
145
|
+
+t: ?ReadonlyArray<?infer V extends {
|
|
146
146
|
+$fragmentType: FragmentType,
|
|
147
147
|
...
|
|
148
148
|
}>,
|
|
149
149
|
]
|
|
150
|
-
?
|
|
150
|
+
? ?ReadonlyArray<?$FragmentRef<NonNullable<V>>>
|
|
151
151
|
: T;
|
|
152
152
|
|
|
153
153
|
export type RelayFragmentContainer<TComponent: component(...empty)> = component(
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
import type {FragmentType} from 'relay-runtime';
|
|
15
15
|
|
|
16
16
|
declare export opaque type RelayModernFlowtest_users$ref: FragmentType;
|
|
17
|
-
export type RelayModernFlowtest_users =
|
|
17
|
+
export type RelayModernFlowtest_users = ReadonlyArray<{
|
|
18
18
|
+name: ?string,
|
|
19
19
|
+$fragmentType: RelayModernFlowtest_users$ref,
|
|
20
20
|
}>;
|
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-d9628ba3",
|
|
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-d9628ba3"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"react": "^16.9.0 || ^17 || ^18 || ^19"
|
|
@@ -42,8 +42,8 @@ export type NonNullableData = {
|
|
|
42
42
|
+count: number,
|
|
43
43
|
};
|
|
44
44
|
export type NullableData = ?NonNullableData;
|
|
45
|
-
export type NonNullablePluralData =
|
|
46
|
-
export type NullablePluralData =
|
|
45
|
+
export type NonNullablePluralData = ReadonlyArray<NonNullableData>;
|
|
46
|
+
export type NullablePluralData = ?ReadonlyArray<NonNullableData>;
|
|
47
47
|
|
|
48
48
|
export type AnotherNonNullableData = {
|
|
49
49
|
+name: ?string,
|
|
@@ -52,9 +52,9 @@ export type AnotherNonNullableData = {
|
|
|
52
52
|
|
|
53
53
|
declare export var keyNonNullable: Example_user$key;
|
|
54
54
|
|
|
55
|
-
declare export var keyNonNullablePlural:
|
|
55
|
+
declare export var keyNonNullablePlural: ReadonlyArray<Example_user$key>;
|
|
56
56
|
|
|
57
|
-
declare export var keyNullablePlural:
|
|
57
|
+
declare export var keyNullablePlural: ?ReadonlyArray<Example_user$key>;
|
|
58
58
|
|
|
59
59
|
declare export var keyNullable: ?Example_user$key;
|
|
60
60
|
|
|
@@ -20,7 +20,7 @@ function getConnectionState(
|
|
|
20
20
|
direction: Direction,
|
|
21
21
|
fragmentNode: ReaderFragment,
|
|
22
22
|
fragmentData: unknown,
|
|
23
|
-
connectionPathInFragmentData:
|
|
23
|
+
connectionPathInFragmentData: ReadonlyArray<string | number>,
|
|
24
24
|
): {
|
|
25
25
|
cursor: ?string,
|
|
26
26
|
hasMore: boolean,
|
|
@@ -45,7 +45,7 @@ export type FragmentResource = FragmentResourceImpl;
|
|
|
45
45
|
type FragmentResourceCache = Cache<
|
|
46
46
|
| {
|
|
47
47
|
kind: 'pending',
|
|
48
|
-
pendingOperations:
|
|
48
|
+
pendingOperations: ReadonlyArray<RequestDescriptor>,
|
|
49
49
|
promise: Promise<unknown>,
|
|
50
50
|
result: FragmentResult,
|
|
51
51
|
}
|
|
@@ -63,7 +63,7 @@ interface IMap<K, V> {
|
|
|
63
63
|
set(key: K, value: V): IMap<K, V>;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
type SingularOrPluralSnapshot = Snapshot |
|
|
66
|
+
type SingularOrPluralSnapshot = Snapshot | ReadonlyArray<Snapshot>;
|
|
67
67
|
|
|
68
68
|
opaque type FragmentResult: {data: unknown, ...} = {
|
|
69
69
|
cacheKey: string,
|
|
@@ -97,7 +97,7 @@ function hasMissingClientEdges(snapshot: SingularOrPluralSnapshot): boolean {
|
|
|
97
97
|
|
|
98
98
|
function missingLiveResolverFields(
|
|
99
99
|
snapshot: SingularOrPluralSnapshot,
|
|
100
|
-
):
|
|
100
|
+
): ?ReadonlyArray<DataID> {
|
|
101
101
|
if (Array.isArray(snapshot)) {
|
|
102
102
|
return snapshot
|
|
103
103
|
.map(s => s.missingLiveResolverFields)
|
|
@@ -804,7 +804,7 @@ class FragmentResourceImpl {
|
|
|
804
804
|
fragmentResult: FragmentResult,
|
|
805
805
|
): {
|
|
806
806
|
promise: Promise<void>,
|
|
807
|
-
pendingOperations:
|
|
807
|
+
pendingOperations: ReadonlyArray<RequestDescriptor>,
|
|
808
808
|
} | null {
|
|
809
809
|
const pendingOperationsResult = getPendingOperationsForFragment(
|
|
810
810
|
this._environment,
|
|
@@ -840,7 +840,7 @@ class FragmentResourceImpl {
|
|
|
840
840
|
|
|
841
841
|
_updatePluralSnapshot(
|
|
842
842
|
cacheKey: string,
|
|
843
|
-
baseSnapshots:
|
|
843
|
+
baseSnapshots: ReadonlyArray<Snapshot>,
|
|
844
844
|
latestSnapshot: Snapshot,
|
|
845
845
|
idx: number,
|
|
846
846
|
storeEpoch: number,
|
|
@@ -388,7 +388,7 @@ hook useRefetchFunction<TQuery: OperationType>(
|
|
|
388
388
|
fragmentData: unknown,
|
|
389
389
|
fragmentIdentifier: string,
|
|
390
390
|
fragmentNode: ReaderFragment,
|
|
391
|
-
fragmentRefPathInResponse:
|
|
391
|
+
fragmentRefPathInResponse: ReadonlyArray<string | number>,
|
|
392
392
|
identifierInfo: ?RefetchableIdentifierInfo,
|
|
393
393
|
loadQuery: LoaderFn<TQuery>,
|
|
394
394
|
parentFragmentRef: unknown,
|
|
@@ -586,7 +586,7 @@ if (__DEV__) {
|
|
|
586
586
|
},
|
|
587
587
|
getInitialIDAndType(
|
|
588
588
|
memoRefetchVariables: ?Variables,
|
|
589
|
-
fragmentRefPathInResponse:
|
|
589
|
+
fragmentRefPathInResponse: ReadonlyArray<string | number>,
|
|
590
590
|
identifierQueryVariableName: ?string,
|
|
591
591
|
environment: IEnvironment,
|
|
592
592
|
): ?DebugIDandTypename {
|
|
@@ -44,7 +44,7 @@ type FragmentQueryOptions = {
|
|
|
44
44
|
type FragmentState = Readonly<
|
|
45
45
|
| {kind: 'bailout'}
|
|
46
46
|
| {kind: 'singular', snapshot: Snapshot, epoch: number}
|
|
47
|
-
| {kind: 'plural', snapshots:
|
|
47
|
+
| {kind: 'plural', snapshots: ReadonlyArray<Snapshot>, epoch: number},
|
|
48
48
|
>;
|
|
49
49
|
|
|
50
50
|
function isMissingData(state: FragmentState): boolean {
|
|
@@ -59,7 +59,7 @@ function isMissingData(state: FragmentState): boolean {
|
|
|
59
59
|
|
|
60
60
|
function getMissingClientEdges(
|
|
61
61
|
state: FragmentState,
|
|
62
|
-
):
|
|
62
|
+
): ReadonlyArray<MissingClientEdgeRequestInfo> | null {
|
|
63
63
|
if (state.kind === 'bailout') {
|
|
64
64
|
return null;
|
|
65
65
|
} else if (state.kind === 'singular') {
|
|
@@ -38,13 +38,13 @@ declare hook useFragment<TFragmentType: FragmentType, TData>(
|
|
|
38
38
|
// if the key is a non-nullable array of keys, return non-nullable array
|
|
39
39
|
declare hook useFragment<TFragmentType: FragmentType, TData>(
|
|
40
40
|
fragment: Fragment<TFragmentType, TData>,
|
|
41
|
-
key:
|
|
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
45
|
declare hook useFragment<TFragmentType: FragmentType, TData>(
|
|
46
46
|
fragment: Fragment<TFragmentType, TData>,
|
|
47
|
-
key:
|
|
47
|
+
key: ?ReadonlyArray<HasSpread<TFragmentType>>,
|
|
48
48
|
): ?TData;
|
|
49
49
|
|
|
50
50
|
hook useFragment(fragment: GraphQLTaggedNode, key: unknown): unknown {
|
|
@@ -50,7 +50,7 @@ type FragmentQueryOptions = {
|
|
|
50
50
|
type FragmentState = Readonly<
|
|
51
51
|
| {kind: 'bailout'}
|
|
52
52
|
| {kind: 'singular', snapshot: Snapshot, epoch: number}
|
|
53
|
-
| {kind: 'plural', snapshots:
|
|
53
|
+
| {kind: 'plural', snapshots: ReadonlyArray<Snapshot>, epoch: number},
|
|
54
54
|
>;
|
|
55
55
|
|
|
56
56
|
type StateUpdaterFunction<T> = ((T) => T) => void;
|
|
@@ -67,7 +67,7 @@ function isMissingData(state: FragmentState): boolean {
|
|
|
67
67
|
|
|
68
68
|
function getMissingClientEdges(
|
|
69
69
|
state: FragmentState,
|
|
70
|
-
):
|
|
70
|
+
): ReadonlyArray<MissingClientEdgeRequestInfo> | null {
|
|
71
71
|
if (state.kind === 'bailout') {
|
|
72
72
|
return null;
|
|
73
73
|
} else if (state.kind === 'singular') {
|
|
@@ -88,7 +88,7 @@ function getMissingClientEdges(
|
|
|
88
88
|
|
|
89
89
|
function getSuspendingLiveResolver(
|
|
90
90
|
state: FragmentState,
|
|
91
|
-
):
|
|
91
|
+
): ReadonlyArray<DataID> | null {
|
|
92
92
|
if (state.kind === 'bailout') {
|
|
93
93
|
return null;
|
|
94
94
|
} else if (state.kind === 'singular') {
|
|
@@ -58,7 +58,7 @@ type FragmentState = Readonly<
|
|
|
58
58
|
}
|
|
59
59
|
| {
|
|
60
60
|
kind: 'plural',
|
|
61
|
-
snapshots:
|
|
61
|
+
snapshots: ReadonlyArray<Snapshot>,
|
|
62
62
|
epoch: number,
|
|
63
63
|
selector: ReaderSelector,
|
|
64
64
|
environment: IEnvironment,
|
|
@@ -79,7 +79,7 @@ function isMissingData(state: FragmentState): boolean {
|
|
|
79
79
|
|
|
80
80
|
function getMissingClientEdges(
|
|
81
81
|
state: FragmentState,
|
|
82
|
-
):
|
|
82
|
+
): ReadonlyArray<MissingClientEdgeRequestInfo> | null {
|
|
83
83
|
if (state.kind === 'bailout') {
|
|
84
84
|
return null;
|
|
85
85
|
} else if (state.kind === 'singular') {
|
|
@@ -100,7 +100,7 @@ function getMissingClientEdges(
|
|
|
100
100
|
|
|
101
101
|
function getSuspendingLiveResolver(
|
|
102
102
|
state: FragmentState,
|
|
103
|
-
):
|
|
103
|
+
): ReadonlyArray<DataID> | null {
|
|
104
104
|
if (state.kind === 'bailout') {
|
|
105
105
|
return null;
|
|
106
106
|
} else if (state.kind === 'singular') {
|
|
@@ -54,7 +54,7 @@ export type UseLoadMoreFunctionArgs = {
|
|
|
54
54
|
fragmentRef: unknown,
|
|
55
55
|
fragmentIdentifier: string,
|
|
56
56
|
fragmentData: unknown,
|
|
57
|
-
connectionPathInFragmentData:
|
|
57
|
+
connectionPathInFragmentData: ReadonlyArray<string | number>,
|
|
58
58
|
paginationRequest: ConcreteRequest,
|
|
59
59
|
paginationMetadata: ReaderPaginationMetadata,
|
|
60
60
|
componentDisplayName: string,
|
|
@@ -52,7 +52,7 @@ export type UseLoadMoreFunctionArgs = {
|
|
|
52
52
|
fragmentRef: unknown,
|
|
53
53
|
fragmentIdentifier: string,
|
|
54
54
|
fragmentData: unknown,
|
|
55
|
-
connectionPathInFragmentData:
|
|
55
|
+
connectionPathInFragmentData: ReadonlyArray<string | number>,
|
|
56
56
|
paginationRequest: ConcreteRequest,
|
|
57
57
|
paginationMetadata: ReaderPaginationMetadata,
|
|
58
58
|
componentDisplayName: string,
|
|
@@ -375,7 +375,7 @@ hook usePrefetchableForwardPaginationFragment<
|
|
|
375
375
|
|
|
376
376
|
const realNumInUse = Math.min(numInUse, sourceSize);
|
|
377
377
|
|
|
378
|
-
const derivedEdgeKeys:
|
|
378
|
+
const derivedEdgeKeys: ReadonlyArray<unknown> = useMemo(
|
|
379
379
|
() => edgeKeys?.slice(0, realNumInUse) ?? [],
|
|
380
380
|
[edgeKeys, realNumInUse],
|
|
381
381
|
);
|
|
@@ -374,7 +374,7 @@ hook usePrefetchableForwardPaginationFragment_EXPERIMENTAL<
|
|
|
374
374
|
|
|
375
375
|
const realNumInUse = Math.min(numInUse, sourceSize);
|
|
376
376
|
|
|
377
|
-
const derivedEdgeKeys:
|
|
377
|
+
const derivedEdgeKeys: ReadonlyArray<unknown> = useMemo(
|
|
378
378
|
() => edgeKeys?.slice(0, realNumInUse) ?? [],
|
|
379
379
|
[edgeKeys, realNumInUse],
|
|
380
380
|
);
|
|
@@ -376,7 +376,7 @@ hook useRefetchFunction<TQuery: OperationType>(
|
|
|
376
376
|
fragmentData: unknown,
|
|
377
377
|
fragmentIdentifier: string,
|
|
378
378
|
fragmentNode: ReaderFragment,
|
|
379
|
-
fragmentRefPathInResponse:
|
|
379
|
+
fragmentRefPathInResponse: ReadonlyArray<string | number>,
|
|
380
380
|
identifierInfo: ?RefetchableIdentifierInfo,
|
|
381
381
|
loadQuery: LoaderFn<TQuery>,
|
|
382
382
|
parentFragmentRef: unknown,
|
|
@@ -576,7 +576,7 @@ if (__DEV__) {
|
|
|
576
576
|
},
|
|
577
577
|
getInitialIDAndType(
|
|
578
578
|
memoRefetchVariables: ?Variables,
|
|
579
|
-
fragmentRefPathInResponse:
|
|
579
|
+
fragmentRefPathInResponse: ReadonlyArray<string | number>,
|
|
580
580
|
identifierQueryVariableName: ?string,
|
|
581
581
|
environment: IEnvironment,
|
|
582
582
|
): ?DebugIDandTypename {
|
|
@@ -26,7 +26,7 @@ const {useEffect, useRef} = require('react');
|
|
|
26
26
|
* The subscription will automatically be disposed on unmount
|
|
27
27
|
*/
|
|
28
28
|
hook useSubscribeToInvalidationState(
|
|
29
|
-
dataIDs:
|
|
29
|
+
dataIDs: ReadonlyArray<DataID>,
|
|
30
30
|
callback: () => void,
|
|
31
31
|
): Disposable {
|
|
32
32
|
const environment = useRelayEnvironment();
|