react-relay 20.0.0 → 20.1.0
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/ReactRelayRefetchContainer.js.flow +1 -1
- package/getRootVariablesForFragments.js.flow +2 -0
- package/hooks.js +1 -1
- package/index.js +1 -1
- package/legacy.js +1 -1
- package/lib/relay-hooks/legacy/FragmentResource.js +1 -1
- package/lib/relay-hooks/readFragmentInternal.js +1 -1
- package/lib/relay-hooks/useFragmentInternal_CURRENT.js +1 -1
- package/lib/relay-hooks/useFragmentInternal_EXPERIMENTAL.js +1 -1
- package/package.json +2 -2
- package/relay-hooks/EntryPointTypes.flow.js.flow +2 -2
- package/relay-hooks/RelayEnvironmentProvider.js.flow +5 -3
- package/relay-hooks/legacy/FragmentResource.js.flow +3 -2
- package/relay-hooks/loadQuery.js.flow +6 -0
- package/relay-hooks/readFragmentInternal.js.flow +3 -2
- package/relay-hooks/useFragmentInternal_CURRENT.js.flow +4 -2
- package/relay-hooks/useFragmentInternal_EXPERIMENTAL.js.flow +4 -3
- package/relay-hooks/useLazyLoadQuery.js.flow +1 -1
- package/relay-hooks/usePreloadedQuery.js.flow +6 -2
package/ReactRelayContext.js
CHANGED
@@ -805,7 +805,7 @@ function createContainerWithFragments<
|
|
805
805
|
...fragmentVariables,
|
806
806
|
}: Variables);
|
807
807
|
|
808
|
-
const cacheConfig: ?CacheConfig = options
|
808
|
+
const cacheConfig: ?{...CacheConfig} = options
|
809
809
|
? {force: !!options.force}
|
810
810
|
: undefined;
|
811
811
|
if (cacheConfig != null && options?.metadata != null) {
|
@@ -339,7 +339,7 @@ function createContainerWithFragments<
|
|
339
339
|
? {...fetchVariables, ...renderVariables}
|
340
340
|
: fetchVariables;
|
341
341
|
|
342
|
-
const cacheConfig: ?CacheConfig = options
|
342
|
+
const cacheConfig: ?{...CacheConfig} = options
|
343
343
|
? {force: !!options.force}
|
344
344
|
: undefined;
|
345
345
|
if (cacheConfig != null && options?.metadata != null) {
|
@@ -32,6 +32,8 @@ function getRootVariablesForFragments<TProps: {...}>(
|
|
32
32
|
selector != null && selector.kind === 'PluralReaderSelector'
|
33
33
|
? selector.selectors[0]?.owner.variables ?? {}
|
34
34
|
: selector?.owner.variables ?? {};
|
35
|
+
/* $FlowFixMe[incompatible-indexer] Natural Inference rollout. See
|
36
|
+
* https://fburl.com/gdoc/y8dn025u */
|
35
37
|
rootVariables = {
|
36
38
|
...rootVariables,
|
37
39
|
...fragmentOwnerVariables,
|
package/hooks.js
CHANGED
package/index.js
CHANGED
package/legacy.js
CHANGED
@@ -193,7 +193,7 @@ var FragmentResourceImpl = /*#__PURE__*/function () {
|
|
193
193
|
}
|
194
194
|
}
|
195
195
|
var fragmentSelector = getSelector(fragmentNode, fragmentRef);
|
196
|
-
!(fragmentSelector != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Relay: Expected to receive an object where `...%s` was spread, ' + 'but the fragment reference was not found`. This is most ' + 'likely the result of:\n' + "- Forgetting to spread `%s` in `%s`'s parent's fragment.\n" + '- Conditionally fetching `%s` but unconditionally passing %s prop ' + 'to `%s`. If the parent fragment only fetches the fragment conditionally ' + '- with e.g. `@include`, `@skip`, or inside a `... on SomeType { }` ' + 'spread - then the fragment reference will not exist. ' + '
|
196
|
+
!(fragmentSelector != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Relay: Expected to receive an object where `...%s` was spread, ' + 'but the fragment reference was not found`. This is most ' + 'likely the result of:\n' + "- Forgetting to spread `%s` in `%s`'s parent's fragment.\n" + '- Conditionally fetching `%s` but unconditionally passing %s prop ' + 'to `%s`. If the parent fragment only fetches the fragment conditionally ' + '- with e.g. `@include`, `@skip`, or inside a `... on SomeType { }` ' + 'spread - then the fragment reference will not exist. ' + 'This issue can generally be fixed by adding `@alias` after `...%s`.\n' + 'See https://relay.dev/docs/next/guides/alias-directive/', fragmentNode.name, fragmentNode.name, componentDisplayName, fragmentNode.name, fragmentKey == null ? 'a fragment reference' : "the `".concat(fragmentKey, "`"), componentDisplayName, fragmentNode.name) : invariant(false) : void 0;
|
197
197
|
var fragmentResult = null;
|
198
198
|
var snapshot = null;
|
199
199
|
if (RelayFeatureFlags.ENABLE_RELAY_OPERATION_TRACKER_SUSPENSE && cachedValue != null && cachedValue.kind === 'missing') {
|
@@ -127,7 +127,7 @@ function readFragmentInternal(environment, fragmentNode, fragmentRef, hookDispla
|
|
127
127
|
} else {
|
128
128
|
!!Array.isArray(fragmentRef) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Relay: Expected fragment pointer%s for fragment `%s` not to be ' + 'an array, instead got `%s`. Add `@relay(plural: true)` ' + 'to fragment `%s` to allow the prop to be an array.', fragmentKey != null ? " for key `".concat(fragmentKey, "`") : '', fragmentNode.name, typeof fragmentRef, fragmentNode.name) : invariant(false) : void 0;
|
129
129
|
}
|
130
|
-
!(fragmentRef == null || isPlural && Array.isArray(fragmentRef) && fragmentRef.length === 0 || fragmentSelector != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Relay: Expected to receive an object where `...%s` was spread, ' + 'but the fragment reference was not found`. This is most ' + 'likely the result of:\n' + "- Forgetting to spread `%s` in `%s`'s parent's fragment.\n" + '- Conditionally fetching `%s` but unconditionally passing %s prop ' + 'to `%s`. If the parent fragment only fetches the fragment conditionally ' + '- with e.g. `@include`, `@skip`, or inside a `... on SomeType { }` ' + 'spread - then the fragment reference will not exist. ' + '
|
130
|
+
!(fragmentRef == null || isPlural && Array.isArray(fragmentRef) && fragmentRef.length === 0 || fragmentSelector != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Relay: Expected to receive an object where `...%s` was spread, ' + 'but the fragment reference was not found`. This is most ' + 'likely the result of:\n' + "- Forgetting to spread `%s` in `%s`'s parent's fragment.\n" + '- Conditionally fetching `%s` but unconditionally passing %s prop ' + 'to `%s`. If the parent fragment only fetches the fragment conditionally ' + '- with e.g. `@include`, `@skip`, or inside a `... on SomeType { }` ' + 'spread - then the fragment reference will not exist. ' + 'This issue can generally be fixed by adding `@alias` after `...%s`.\n' + 'See https://relay.dev/docs/next/guides/alias-directive/', fragmentNode.name, fragmentNode.name, hookDisplayName, fragmentNode.name, fragmentKey == null ? 'a fragment reference' : "the `".concat(fragmentKey, "`"), hookDisplayName, fragmentNode.name) : invariant(false) : void 0;
|
131
131
|
var state = getFragmentState(environment, fragmentSelector);
|
132
132
|
var clientEdgeQueries = null;
|
133
133
|
if (((_fragmentNode$metadat2 = fragmentNode.metadata) === null || _fragmentNode$metadat2 === void 0 ? void 0 : _fragmentNode$metadat2.hasClientEdges) === true || RelayFeatureFlags.CHECK_ALL_FRAGMENTS_FOR_MISSING_CLIENT_EDGES) {
|
@@ -308,7 +308,7 @@ function useFragmentInternal(fragmentNode, fragmentRef, hookDisplayName, queryOp
|
|
308
308
|
} else {
|
309
309
|
!!Array.isArray(fragmentRef) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Relay: Expected fragment pointer%s for fragment `%s` not to be ' + 'an array, instead got `%s`. Add `@relay(plural: true)` ' + 'to fragment `%s` to allow the prop to be an array.', fragmentNode.name, typeof fragmentRef, fragmentNode.name) : invariant(false) : void 0;
|
310
310
|
}
|
311
|
-
!(fragmentRef == null || isPlural && Array.isArray(fragmentRef) && fragmentRef.length === 0 || fragmentSelector != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Relay: Expected to receive an object where `...%s` was spread, ' + 'but the fragment reference was not found`. This is most ' + 'likely the result of:\n' + "- Forgetting to spread `%s` in `%s`'s parent's fragment.\n" + '- Conditionally fetching `%s` but unconditionally passing %s prop ' + 'to `%s`. If the parent fragment only fetches the fragment conditionally ' + '- with e.g. `@include`, `@skip`, or inside a `... on SomeType { }` ' + 'spread - then the fragment reference will not exist. ' + '
|
311
|
+
!(fragmentRef == null || isPlural && Array.isArray(fragmentRef) && fragmentRef.length === 0 || fragmentSelector != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Relay: Expected to receive an object where `...%s` was spread, ' + 'but the fragment reference was not found`. This is most ' + 'likely the result of:\n' + "- Forgetting to spread `%s` in `%s`'s parent's fragment.\n" + '- Conditionally fetching `%s` but unconditionally passing %s prop ' + 'to `%s`. If the parent fragment only fetches the fragment conditionally ' + '- with e.g. `@include`, `@skip`, or inside a `... on SomeType { }` ' + 'spread - then the fragment reference will not exist. ' + 'This issue can generally be fixed by adding `@alias` after `...%s`.\n' + 'See https://relay.dev/docs/next/guides/alias-directive/', fragmentNode.name, fragmentNode.name, hookDisplayName, fragmentNode.name, hookDisplayName, fragmentNode.name) : invariant(false) : void 0;
|
312
312
|
var environment = useRelayEnvironment();
|
313
313
|
var loggerContext;
|
314
314
|
if (RelayFeatureFlags.ENABLE_UI_CONTEXT_ON_RELAY_LOGGER) {
|
@@ -327,7 +327,7 @@ function useFragmentInternal_EXPERIMENTAL(fragmentNode, fragmentRef, hookDisplay
|
|
327
327
|
} else {
|
328
328
|
!!Array.isArray(fragmentRef) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Relay: Expected fragment pointer%s for fragment `%s` not to be ' + 'an array, instead got `%s`. Add `@relay(plural: true)` ' + 'to fragment `%s` to allow the prop to be an array.', fragmentNode.name, typeof fragmentRef, fragmentNode.name) : invariant(false) : void 0;
|
329
329
|
}
|
330
|
-
!(fragmentRef == null || isPlural && Array.isArray(fragmentRef) && fragmentRef.length === 0 || fragmentSelector != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Relay: Expected to receive an object where `...%s` was spread, ' + 'but the fragment reference was not found`. This is most ' + 'likely the result of:\n' + "- Forgetting to spread `%s` in `%s`'s parent's fragment.\n" + '- Conditionally fetching `%s` but unconditionally passing %s prop ' + 'to `%s`. If the parent fragment only fetches the fragment conditionally ' + '- with e.g. `@include`, `@skip`, or inside a `... on SomeType { }` ' + 'spread
|
330
|
+
!(fragmentRef == null || isPlural && Array.isArray(fragmentRef) && fragmentRef.length === 0 || fragmentSelector != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Relay: Expected to receive an object where `...%s` was spread, ' + 'but the fragment reference was not found`. This is most ' + 'likely the result of:\n' + "- Forgetting to spread `%s` in `%s`'s parent's fragment.\n" + '- Conditionally fetching `%s` but unconditionally passing %s prop ' + 'to `%s`. If the parent fragment only fetches the fragment conditionally ' + '- with e.g. `@include`, `@skip`, or inside a `... on SomeType { }` ' + 'spread - then the fragment reference will not exist. ' + 'This issue can generally be fixed by adding `@alias` after `...%s`.\n' + 'See https://relay.dev/docs/next/guides/alias-directive/', fragmentNode.name, fragmentNode.name, hookDisplayName, fragmentNode.name, hookDisplayName) : invariant(false) : void 0;
|
331
331
|
var environment = useRelayEnvironment();
|
332
332
|
var loggerContext;
|
333
333
|
if (RelayFeatureFlags.ENABLE_UI_CONTEXT_ON_RELAY_LOGGER) {
|
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": "20.
|
4
|
+
"version": "20.1.0",
|
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": "20.
|
23
|
+
"relay-runtime": "20.1.0"
|
24
24
|
},
|
25
25
|
"peerDependencies": {
|
26
26
|
"react": "^16.9.0 || ^17 || ^18 || ^19"
|
@@ -293,6 +293,6 @@ export type EntryPoint<TEntryPointParams, +TEntryPointComponent> =
|
|
293
293
|
|
294
294
|
export type PreloadParamsOf<T> = Parameters<T['getPreloadProps']>[0];
|
295
295
|
|
296
|
-
export type IEnvironmentProvider<TOptions> = {
|
296
|
+
export type IEnvironmentProvider<TOptions> = $ReadOnly<{
|
297
297
|
getEnvironment: (options: ?TOptions) => IEnvironment,
|
298
|
-
}
|
298
|
+
}>;
|
@@ -22,15 +22,17 @@ const React = require('react');
|
|
22
22
|
|
23
23
|
const {useMemo} = React;
|
24
24
|
|
25
|
-
type Props = $ReadOnly<{
|
26
|
-
children:
|
25
|
+
type Props<TChildren> = $ReadOnly<{
|
26
|
+
children: TChildren,
|
27
27
|
environment: IEnvironment,
|
28
28
|
getEnvironmentForActor?: ?(
|
29
29
|
actorIdentifier: ActorIdentifier,
|
30
30
|
) => IActorEnvironment,
|
31
31
|
}>;
|
32
32
|
|
33
|
-
|
33
|
+
component RelayEnvironmentProvider<TChildren: React.Node>(
|
34
|
+
...props: Props<TChildren>
|
35
|
+
) renders TChildren {
|
34
36
|
const {children, environment, getEnvironmentForActor} = props;
|
35
37
|
const context = useMemo(
|
36
38
|
() => ({environment, getEnvironmentForActor}),
|
@@ -340,14 +340,15 @@ class FragmentResourceImpl {
|
|
340
340
|
'to `%s`. If the parent fragment only fetches the fragment conditionally ' +
|
341
341
|
'- with e.g. `@include`, `@skip`, or inside a `... on SomeType { }` ' +
|
342
342
|
'spread - then the fragment reference will not exist. ' +
|
343
|
-
'
|
344
|
-
'
|
343
|
+
'This issue can generally be fixed by adding `@alias` after `...%s`.\n' +
|
344
|
+
'See https://relay.dev/docs/next/guides/alias-directive/',
|
345
345
|
fragmentNode.name,
|
346
346
|
fragmentNode.name,
|
347
347
|
componentDisplayName,
|
348
348
|
fragmentNode.name,
|
349
349
|
fragmentKey == null ? 'a fragment reference' : `the \`${fragmentKey}\``,
|
350
350
|
componentDisplayName,
|
351
|
+
fragmentNode.name,
|
351
352
|
);
|
352
353
|
|
353
354
|
let fragmentResult = null;
|
@@ -351,10 +351,16 @@ function loadQuery<
|
|
351
351
|
return;
|
352
352
|
}
|
353
353
|
if (didExecuteNetworkSource) {
|
354
|
+
/* $FlowFixMe[constant-condition] Error discovered during Constant
|
355
|
+
* Condition roll out. See https://fburl.com/workplace/1v97vimq. */
|
354
356
|
unsubscribeFromExecution && unsubscribeFromExecution();
|
355
357
|
} else {
|
358
|
+
/* $FlowFixMe[constant-condition] Error discovered during Constant
|
359
|
+
* Condition roll out. See https://fburl.com/workplace/1v97vimq. */
|
356
360
|
unsubscribeFromNetworkRequest && unsubscribeFromNetworkRequest();
|
357
361
|
}
|
362
|
+
/* $FlowFixMe[constant-condition] Error discovered during Constant
|
363
|
+
* Condition roll out. See https://fburl.com/workplace/1v97vimq. */
|
358
364
|
cancelOnLoadCallback && cancelOnLoadCallback();
|
359
365
|
isNetworkRequestCancelled = true;
|
360
366
|
};
|
@@ -198,14 +198,15 @@ function readFragmentInternal(
|
|
198
198
|
'to `%s`. If the parent fragment only fetches the fragment conditionally ' +
|
199
199
|
'- with e.g. `@include`, `@skip`, or inside a `... on SomeType { }` ' +
|
200
200
|
'spread - then the fragment reference will not exist. ' +
|
201
|
-
'
|
202
|
-
'
|
201
|
+
'This issue can generally be fixed by adding `@alias` after `...%s`.\n' +
|
202
|
+
'See https://relay.dev/docs/next/guides/alias-directive/',
|
203
203
|
fragmentNode.name,
|
204
204
|
fragmentNode.name,
|
205
205
|
hookDisplayName,
|
206
206
|
fragmentNode.name,
|
207
207
|
fragmentKey == null ? 'a fragment reference' : `the \`${fragmentKey}\``,
|
208
208
|
hookDisplayName,
|
209
|
+
fragmentNode.name,
|
209
210
|
);
|
210
211
|
|
211
212
|
const state = getFragmentState(environment, fragmentSelector);
|
@@ -400,13 +400,14 @@ hook useFragmentInternal(
|
|
400
400
|
'to `%s`. If the parent fragment only fetches the fragment conditionally ' +
|
401
401
|
'- with e.g. `@include`, `@skip`, or inside a `... on SomeType { }` ' +
|
402
402
|
'spread - then the fragment reference will not exist. ' +
|
403
|
-
'
|
404
|
-
'
|
403
|
+
'This issue can generally be fixed by adding `@alias` after `...%s`.\n' +
|
404
|
+
'See https://relay.dev/docs/next/guides/alias-directive/',
|
405
405
|
fragmentNode.name,
|
406
406
|
fragmentNode.name,
|
407
407
|
hookDisplayName,
|
408
408
|
fragmentNode.name,
|
409
409
|
hookDisplayName,
|
410
|
+
fragmentNode.name,
|
410
411
|
);
|
411
412
|
|
412
413
|
const environment = useRelayEnvironment();
|
@@ -537,6 +538,7 @@ hook useFragmentInternal(
|
|
537
538
|
if (
|
538
539
|
RelayFeatureFlags.ENABLE_RELAY_OPERATION_TRACKER_SUSPENSE ||
|
539
540
|
environment !== previousEnvironment ||
|
541
|
+
// $FlowFixMe[sketchy-null-bool]
|
540
542
|
!committedFragmentSelectorRef.current ||
|
541
543
|
// $FlowFixMe[react-rule-unsafe-ref]
|
542
544
|
!areEqualSelectors(committedFragmentSelectorRef.current, fragmentSelector)
|
@@ -436,9 +436,9 @@ hook useFragmentInternal_EXPERIMENTAL(
|
|
436
436
|
'- Conditionally fetching `%s` but unconditionally passing %s prop ' +
|
437
437
|
'to `%s`. If the parent fragment only fetches the fragment conditionally ' +
|
438
438
|
'- with e.g. `@include`, `@skip`, or inside a `... on SomeType { }` ' +
|
439
|
-
'spread
|
440
|
-
'
|
441
|
-
'
|
439
|
+
'spread - then the fragment reference will not exist. ' +
|
440
|
+
'This issue can generally be fixed by adding `@alias` after `...%s`.\n' +
|
441
|
+
'See https://relay.dev/docs/next/guides/alias-directive/',
|
442
442
|
fragmentNode.name,
|
443
443
|
fragmentNode.name,
|
444
444
|
hookDisplayName,
|
@@ -569,6 +569,7 @@ hook useFragmentInternal_EXPERIMENTAL(
|
|
569
569
|
if (
|
570
570
|
RelayFeatureFlags.ENABLE_RELAY_OPERATION_TRACKER_SUSPENSE ||
|
571
571
|
environment !== previousEnvironment ||
|
572
|
+
// $FlowFixMe[sketchy-null-bool]
|
572
573
|
!committedFragmentSelectorRef.current ||
|
573
574
|
// $FlowFixMe[react-rule-unsafe-ref]
|
574
575
|
!areEqualSelectors(committedFragmentSelectorRef.current, fragmentSelector)
|
@@ -93,7 +93,7 @@ hook useLazyLoadQuery<TVariables: Variables, TData>(
|
|
93
93
|
/**
|
94
94
|
* Object containing the variable values to fetch the query. These variables need to match GraphQL variables declared inside the query.
|
95
95
|
*/
|
96
|
-
variables: TVariables
|
96
|
+
variables: NoInfer<TVariables>,
|
97
97
|
/**
|
98
98
|
* options object
|
99
99
|
*/
|
@@ -16,7 +16,7 @@ import type {
|
|
16
16
|
PreloadedQueryInner,
|
17
17
|
PreloadedQueryInner_DEPRECATED,
|
18
18
|
} from './EntryPointTypes.flow';
|
19
|
-
import type {Query, RenderPolicy, Variables} from 'relay-runtime';
|
19
|
+
import type {ClientQuery, Query, RenderPolicy, Variables} from 'relay-runtime';
|
20
20
|
|
21
21
|
const useLazyLoadQueryNode = require('./useLazyLoadQueryNode');
|
22
22
|
const useMemoOperationDescriptor = require('./useMemoOperationDescriptor');
|
@@ -56,7 +56,9 @@ hook usePreloadedQuery<
|
|
56
56
|
TData,
|
57
57
|
TRawResponse: ?{...} = void,
|
58
58
|
>(
|
59
|
-
gqlQuery:
|
59
|
+
gqlQuery:
|
60
|
+
| Query<TVariables, TData, TRawResponse>
|
61
|
+
| ClientQuery<TVariables, TData, TRawResponse>,
|
60
62
|
preloadedQuery: PreloadedQuery<
|
61
63
|
TVariables,
|
62
64
|
TData,
|
@@ -155,6 +157,8 @@ hook usePreloadedQuery<
|
|
155
157
|
variables: TVariables,
|
156
158
|
response: TData,
|
157
159
|
rawResponse?: $NonMaybeType<TRawResponse>,
|
160
|
+
/* $FlowFixMe[incompatible-call] Natural Inference rollout. See
|
161
|
+
* https://fburl.com/gdoc/y8dn025u */
|
158
162
|
}>(useLazyLoadQueryNodeParams);
|
159
163
|
|
160
164
|
if (__DEV__) {
|