react-relay 0.0.0-main-45ac6913 → 0.0.0-main-44d06d6c
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/ReactRelayLocalQueryRenderer.js.flow +8 -2
- package/hooks.js +1 -1
- package/index.js +1 -1
- package/legacy.js +1 -1
- package/multi-actor/ActorChange.js.flow +1 -3
- package/package.json +2 -2
- package/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js.flow +15 -13
- package/relay-hooks/MatchContainer.js.flow +2 -10
- package/relay-hooks/__flowtests__/useFragment-flowtest.js.flow +10 -0
- package/relay-hooks/rsc/useQueryFromServer.js.flow +1 -1
- package/relay-hooks/useQueryLoader.js.flow +3 -3
- package/rsc-client_EXPERIMENTAL.js +1 -1
- package/rsc_EXPERIMENTAL.js +1 -1
package/ReactRelayContext.js
CHANGED
|
@@ -59,7 +59,7 @@ hook useDeepCompare<T extends {...}>(value: T): T {
|
|
|
59
59
|
return latestValue.current;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
component ReactRelayLocalQueryRenderer(...props: Props) {
|
|
63
63
|
const {environment, query, variables, render} = props;
|
|
64
64
|
const latestVariables = useDeepCompare(variables);
|
|
65
65
|
const operation = useMemo(() => {
|
|
@@ -81,6 +81,7 @@ function ReactRelayLocalQueryRenderer(props: Props): React.Node {
|
|
|
81
81
|
const snapshot = useMemo(() => {
|
|
82
82
|
environment.check(operation);
|
|
83
83
|
const res = environment.lookup(operation.fragment);
|
|
84
|
+
// $FlowFixMe[react-rule-unsafe-ref]
|
|
84
85
|
dataRef.current = res.data;
|
|
85
86
|
|
|
86
87
|
// Run effects here so that the data can be retained
|
|
@@ -100,8 +101,10 @@ function ReactRelayLocalQueryRenderer(props: Props): React.Node {
|
|
|
100
101
|
}
|
|
101
102
|
}
|
|
102
103
|
if (cleanupFnRef.current) {
|
|
104
|
+
// $FlowFixMe[react-rule-unsafe-ref]
|
|
103
105
|
cleanupFnRef.current();
|
|
104
106
|
}
|
|
107
|
+
// $FlowFixMe[react-rule-unsafe-ref]
|
|
105
108
|
cleanupFnRef.current = nextCleanupFn;
|
|
106
109
|
return res;
|
|
107
110
|
}, [environment, operation]);
|
|
@@ -116,7 +119,10 @@ function ReactRelayLocalQueryRenderer(props: Props): React.Node {
|
|
|
116
119
|
return (
|
|
117
120
|
<ReactRelayContext.Provider value={relayContext}>
|
|
118
121
|
<ReactRelayQueryRendererContext.Provider value={queryRendererContext}>
|
|
119
|
-
{
|
|
122
|
+
{
|
|
123
|
+
// $FlowFixMe[react-rule-unsafe-ref]
|
|
124
|
+
render({props: dataRef.current})
|
|
125
|
+
}
|
|
120
126
|
</ReactRelayQueryRendererContext.Provider>
|
|
121
127
|
</ReactRelayContext.Provider>
|
|
122
128
|
);
|
package/hooks.js
CHANGED
package/index.js
CHANGED
package/legacy.js
CHANGED
|
@@ -30,9 +30,7 @@ type ActorChangeProps<TFragmentRef> = {
|
|
|
30
30
|
) => React.MixedElement,
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
props: ActorChangeProps<TFragmentRef>,
|
|
35
|
-
): React.MixedElement {
|
|
33
|
+
component ActorChange<TFragmentRef>(...props: ActorChangeProps<TFragmentRef>) {
|
|
36
34
|
const actorEnvironment = useRelayActorEnvironment(
|
|
37
35
|
props.actorChangePoint.__viewer,
|
|
38
36
|
);
|
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-44d06d6c",
|
|
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-44d06d6c"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"react": "^16.9.0 || ^17 || ^18 || ^19"
|
|
@@ -154,25 +154,27 @@ function prepareEntryPoint<
|
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
|
|
157
|
+
component LazyLoadEntryPointContainer_DEPRECATED<
|
|
158
158
|
TEntryPointParams extends {...},
|
|
159
159
|
// $FlowExpectedError[unclear-type] Need any to make it supertype of all PreloadedQuery
|
|
160
160
|
TPreloadedQueries extends {readonly [string]: PreloadedQuery<any>},
|
|
161
161
|
TPreloadedEntryPoints extends {...},
|
|
162
162
|
TRuntimeProps extends {...},
|
|
163
163
|
TExtraProps,
|
|
164
|
-
>(
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
164
|
+
>(
|
|
165
|
+
...{
|
|
166
|
+
entryPoint,
|
|
167
|
+
entryPointParams,
|
|
168
|
+
props,
|
|
169
|
+
environmentProvider,
|
|
170
|
+
}: EntryPointContainerProps<
|
|
171
|
+
TEntryPointParams,
|
|
172
|
+
TPreloadedQueries,
|
|
173
|
+
TPreloadedEntryPoints,
|
|
174
|
+
TRuntimeProps,
|
|
175
|
+
TExtraProps,
|
|
176
|
+
>
|
|
177
|
+
) {
|
|
176
178
|
const environment = useRelayEnvironment();
|
|
177
179
|
const {getPreloadProps} = entryPoint;
|
|
178
180
|
// IMPORTANT: Loading the component may suspend (throw), so the props
|
|
@@ -103,18 +103,10 @@ export type MatchContainerProps<
|
|
|
103
103
|
readonly props?: TProps,
|
|
104
104
|
};
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
component MatchContainer<
|
|
107
107
|
TProps extends {...},
|
|
108
108
|
TFallback extends React.Node | null,
|
|
109
|
-
>({
|
|
110
|
-
fallback,
|
|
111
|
-
loader,
|
|
112
|
-
match,
|
|
113
|
-
props,
|
|
114
|
-
}: MatchContainerProps<TProps, TFallback>):
|
|
115
|
-
| React.MixedElement
|
|
116
|
-
| TFallback
|
|
117
|
-
| null {
|
|
109
|
+
>(...{fallback, loader, match, props}: MatchContainerProps<TProps, TFallback>) {
|
|
118
110
|
if (match != null && typeof match !== 'object') {
|
|
119
111
|
throw new Error(
|
|
120
112
|
'MatchContainer: Expected `match` value to be an object or null/undefined.',
|
|
@@ -40,44 +40,54 @@ const usersFragment: useFragmentFlowtest_users$fragment = graphql`
|
|
|
40
40
|
/* eslint-disable react-hooks/rules-of-hooks */
|
|
41
41
|
|
|
42
42
|
// Nullability of returned data type is correct
|
|
43
|
+
// $FlowExpectedError[react-rule-hook]
|
|
43
44
|
useFragment(
|
|
44
45
|
userFragment,
|
|
45
46
|
Any as useFragmentFlowtest_user$key,
|
|
46
47
|
) as useFragmentFlowtest_user$data;
|
|
48
|
+
// $FlowExpectedError[react-rule-hook]
|
|
47
49
|
useFragment(
|
|
48
50
|
userFragment,
|
|
49
51
|
Any as ?useFragmentFlowtest_user$key,
|
|
50
52
|
) as ?useFragmentFlowtest_user$data;
|
|
53
|
+
// $FlowExpectedError[react-rule-hook]
|
|
51
54
|
useFragment(
|
|
52
55
|
usersFragment,
|
|
53
56
|
Any as useFragmentFlowtest_users$key,
|
|
54
57
|
) as useFragmentFlowtest_users$data;
|
|
58
|
+
// $FlowExpectedError[react-rule-hook]
|
|
55
59
|
useFragment(
|
|
56
60
|
usersFragment,
|
|
57
61
|
Any as ?useFragmentFlowtest_users$key,
|
|
58
62
|
) as ?useFragmentFlowtest_users$data;
|
|
59
63
|
|
|
60
64
|
// $FlowExpectedError[incompatible-type] : can't cast nullable to non-nullable
|
|
65
|
+
// $FlowExpectedError[react-rule-hook]
|
|
61
66
|
useFragment(
|
|
62
67
|
userFragment,
|
|
63
68
|
Any as ?useFragmentFlowtest_user$key,
|
|
64
69
|
) as useFragmentFlowtest_user$data;
|
|
65
70
|
// $FlowExpectedError[incompatible-type] : can't cast nullable plural to non-nullable plural
|
|
71
|
+
// $FlowExpectedError[react-rule-hook]
|
|
66
72
|
useFragment(
|
|
67
73
|
usersFragment,
|
|
68
74
|
Any as ?useFragmentFlowtest_users$key,
|
|
69
75
|
) as useFragmentFlowtest_users$data;
|
|
70
76
|
|
|
71
77
|
// $FlowExpectedError[incompatible-type] : Key should be one of the generated types
|
|
78
|
+
// $FlowExpectedError[react-rule-hook]
|
|
72
79
|
useFragment(userFragment, 'INVALID_KEY');
|
|
73
80
|
|
|
74
81
|
// $FlowExpectedError[incompatible-type] : Key should not be a user provided object
|
|
82
|
+
// $FlowExpectedError[react-rule-hook]
|
|
75
83
|
useFragment(userFragment, {a: 123});
|
|
76
84
|
|
|
77
85
|
// $FlowExpectedError[incompatible-type] : Key should not be an empty object
|
|
86
|
+
// $FlowExpectedError[react-rule-hook]
|
|
78
87
|
useFragment(userFragment, {});
|
|
79
88
|
|
|
80
89
|
// $FlowExpectedError[incompatible-type] : Key should be the `<name>$key` type from generated flow
|
|
90
|
+
// $FlowExpectedError[react-rule-hook]
|
|
81
91
|
useFragment(userFragment, Any as useFragmentFlowtest_user$data);
|
|
82
92
|
|
|
83
93
|
/* eslint-enable react-hooks/rules-of-hooks */
|
|
@@ -36,7 +36,7 @@ const committedRefs: WeakSet<any> = new WeakSet();
|
|
|
36
36
|
|
|
37
37
|
const DEFAULT_STALE_MS = 30_000;
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
hook useQueryFromServer<TVariables extends Variables, TData>(
|
|
40
40
|
query: Query<TVariables, TData>,
|
|
41
41
|
queryRef: PreloadedQueryRef<TVariables, TData>,
|
|
42
42
|
options?: {staleThresholdMs?: number},
|
|
@@ -85,7 +85,7 @@ export type UseQueryLoaderHookReturnType<
|
|
|
85
85
|
() => void,
|
|
86
86
|
];
|
|
87
87
|
|
|
88
|
-
declare
|
|
88
|
+
declare hook useQueryLoader<
|
|
89
89
|
TVariables extends Variables,
|
|
90
90
|
TData,
|
|
91
91
|
TRawResponse extends ?{...} = void,
|
|
@@ -93,7 +93,7 @@ declare function useQueryLoader<
|
|
|
93
93
|
preloadableRequest: Query<TVariables, TData, TRawResponse>,
|
|
94
94
|
): UseQueryLoaderHookReturnType<TVariables, TData>;
|
|
95
95
|
|
|
96
|
-
declare
|
|
96
|
+
declare hook useQueryLoader<
|
|
97
97
|
TVariables extends Variables,
|
|
98
98
|
TData,
|
|
99
99
|
TRawResponse extends ?{...} = void,
|
|
@@ -106,7 +106,7 @@ declare function useQueryLoader<
|
|
|
106
106
|
}>,
|
|
107
107
|
): UseQueryLoaderHookReturnType<TVariables, TData>;
|
|
108
108
|
|
|
109
|
-
declare
|
|
109
|
+
declare hook useQueryLoader<TQuery extends OperationType>(
|
|
110
110
|
preloadableRequest: PreloadableConcreteRequest<TQuery>,
|
|
111
111
|
initialQueryReference?: ?PreloadedQuery<TQuery>,
|
|
112
112
|
): UseQueryLoaderHookReturnType<TQuery['variables'], TQuery['response']>;
|
package/rsc_EXPERIMENTAL.js
CHANGED