react-relay 0.0.0-main-edcb69da → 0.0.0-main-9af45f9c
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 +1 -1
- package/ReactRelayLoggingContext.js.flow +3 -3
- package/ReactRelayPaginationContainer.js.flow +2 -2
- package/ReactRelayQueryFetcher.js.flow +1 -1
- package/ReactRelayRefetchContainer.js.flow +1 -1
- package/ReactRelayTypes.js.flow +5 -5
- package/RelayContext.js.flow +2 -2
- package/buildReactRelayContainer.js.flow +1 -1
- package/hooks.js +1 -1
- package/index.js +1 -1
- package/isRelayEnvironment.js.flow +1 -1
- package/legacy.js +1 -1
- package/lib/relay-hooks/useLazyLoadQueryNode.js +32 -19
- package/lib/relay-hooks/usePreloadedQuery.js +52 -47
- package/package.json +2 -2
- package/relay-hooks/EntryPointTypes.flow.js.flow +1 -1
- package/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js.flow +4 -4
- package/relay-hooks/MatchContainer.js.flow +3 -3
- package/relay-hooks/QueryResource.js.flow +6 -6
- package/relay-hooks/__flowtests__/EntryPointTypes/ExtractQueryTypes-flowtest.js.flow +1 -1
- package/relay-hooks/getConnectionState.js.flow +1 -1
- package/relay-hooks/legacy/FragmentResource.js.flow +7 -7
- package/relay-hooks/legacy/useBlockingPaginationFragment.js.flow +5 -5
- package/relay-hooks/legacy/useFragmentNode.js.flow +3 -3
- package/relay-hooks/legacy/useRefetchableFragmentNode.js.flow +11 -11
- package/relay-hooks/loadEntryPoint.js.flow +2 -2
- package/relay-hooks/loadQuery.js.flow +1 -1
- package/relay-hooks/prepareEntryPoint_DEPRECATED.js.flow +1 -1
- package/relay-hooks/readFragmentInternal.js.flow +2 -2
- package/relay-hooks/useFragment.js.flow +1 -1
- package/relay-hooks/useFragmentInternal.js.flow +1 -1
- package/relay-hooks/useFragmentInternal_CURRENT.js.flow +4 -4
- package/relay-hooks/useFragmentInternal_EXPERIMENTAL.js.flow +4 -4
- package/relay-hooks/useIsOperationNodeActive.js.flow +1 -1
- package/relay-hooks/useIsParentQueryActive.js.flow +1 -1
- package/relay-hooks/useLazyLoadQuery.js.flow +5 -1
- package/relay-hooks/useLazyLoadQueryNode.js.flow +67 -28
- package/relay-hooks/useLoadMoreFunction.js.flow +2 -2
- package/relay-hooks/useLoadMoreFunction_EXPERIMENTAL.js.flow +2 -2
- package/relay-hooks/usePaginationFragment.js.flow +3 -3
- package/relay-hooks/usePrefetchableForwardPaginationFragment.js.flow +3 -3
- package/relay-hooks/usePrefetchableForwardPaginationFragment_EXPERIMENTAL.js.flow +3 -3
- package/relay-hooks/usePreloadedQuery.js.flow +118 -78
- package/relay-hooks/useQueryLoader.js.flow +6 -6
- package/relay-hooks/useQueryLoader_EXPERIMENTAL.js.flow +3 -3
- package/relay-hooks/useRefetchableFragment.js.flow +6 -4
- package/relay-hooks/useRefetchableFragmentInternal.js.flow +10 -10
- package/relay-hooks/useRelayLoggingContext.js.flow +1 -1
package/ReactRelayContext.js
CHANGED
|
@@ -16,6 +16,6 @@ const {
|
|
|
16
16
|
__internal: {createRelayLoggingContext},
|
|
17
17
|
} = require('relay-runtime');
|
|
18
18
|
|
|
19
|
-
module.exports = createRelayLoggingContext(
|
|
20
|
-
|
|
21
|
-
>;
|
|
19
|
+
module.exports = createRelayLoggingContext(
|
|
20
|
+
React,
|
|
21
|
+
) as React.Context<unknown | null>;
|
|
@@ -59,7 +59,7 @@ const {
|
|
|
59
59
|
const warning = require('warning');
|
|
60
60
|
|
|
61
61
|
type ContainerState = {
|
|
62
|
-
data: {[key: string]:
|
|
62
|
+
data: {[key: string]: unknown, ...},
|
|
63
63
|
relayProp: RelayPaginationProp,
|
|
64
64
|
prevContext: RelayContext,
|
|
65
65
|
contextForChildren: RelayContext,
|
|
@@ -829,7 +829,7 @@ function createContainerWithFragments<
|
|
|
829
829
|
}
|
|
830
830
|
this._hasFetched = true;
|
|
831
831
|
|
|
832
|
-
const onNext = (payload:
|
|
832
|
+
const onNext = (payload: unknown, complete: () => void) => {
|
|
833
833
|
const prevData = this._resolver.resolve();
|
|
834
834
|
this._resolver.setVariables(
|
|
835
835
|
getFragmentVariables(
|
|
@@ -116,7 +116,7 @@ class ReactRelayQueryFetcher {
|
|
|
116
116
|
environment,
|
|
117
117
|
operation,
|
|
118
118
|
preservePreviousReferences = false,
|
|
119
|
-
}: ExecuteConfig): Observable<
|
|
119
|
+
}: ExecuteConfig): Observable<unknown> {
|
|
120
120
|
const reference = environment.retain(operation);
|
|
121
121
|
const error = () => {
|
|
122
122
|
// We may have partially fulfilled the request, so let the next request
|
|
@@ -52,7 +52,7 @@ const warning = require('warning');
|
|
|
52
52
|
type ContainerProps = $FlowFixMe;
|
|
53
53
|
|
|
54
54
|
type ContainerState = {
|
|
55
|
-
data: {[key: string]:
|
|
55
|
+
data: {[key: string]: unknown, ...},
|
|
56
56
|
prevProps: ContainerProps,
|
|
57
57
|
localVariables: ?Variables,
|
|
58
58
|
prevPropsContext: RelayContext,
|
package/ReactRelayTypes.js.flow
CHANGED
|
@@ -22,7 +22,7 @@ import type {
|
|
|
22
22
|
|
|
23
23
|
export type GeneratedNodeMap = {[key: string]: GraphQLTaggedNode, ...};
|
|
24
24
|
|
|
25
|
-
export type ObserverOrCallback = Observer<void> | ((error: ?Error) =>
|
|
25
|
+
export type ObserverOrCallback = Observer<void> | ((error: ?Error) => unknown);
|
|
26
26
|
|
|
27
27
|
// NOTE: This is an inexact type in order to allow a RelayPaginationProp or
|
|
28
28
|
// RelayRefetchProp to flow into a RelayProp.
|
|
@@ -57,7 +57,7 @@ export type RelayRefetchProp = {
|
|
|
57
57
|
export type RefetchOptions = {
|
|
58
58
|
+force?: boolean,
|
|
59
59
|
+fetchPolicy?: 'store-or-network' | 'network-only',
|
|
60
|
-
+metadata?: {[key: string]:
|
|
60
|
+
+metadata?: {[key: string]: unknown, ...},
|
|
61
61
|
};
|
|
62
62
|
|
|
63
63
|
/**
|
|
@@ -121,7 +121,7 @@ type MapRelayProp<T> = [+t: T] extends [+t: {+$fragmentType: empty, ...}]
|
|
|
121
121
|
: [+t: T] extends [+t: {+$fragmentType: FragmentType, ...}]
|
|
122
122
|
? $FragmentRef<T>
|
|
123
123
|
: [+t: T] extends [+t: ?{+$fragmentType: FragmentType, ...}]
|
|
124
|
-
? ?$FragmentRef
|
|
124
|
+
? ?$FragmentRef<NonNullable<T>>
|
|
125
125
|
: [+t: T] extends [
|
|
126
126
|
+t: $ReadOnlyArray<
|
|
127
127
|
infer V extends {+$fragmentType: FragmentType, ...},
|
|
@@ -140,14 +140,14 @@ type MapRelayProp<T> = [+t: T] extends [+t: {+$fragmentType: empty, ...}]
|
|
|
140
140
|
...
|
|
141
141
|
}>,
|
|
142
142
|
]
|
|
143
|
-
? $ReadOnlyArray<?$FragmentRef
|
|
143
|
+
? $ReadOnlyArray<?$FragmentRef<NonNullable<V>>>
|
|
144
144
|
: [+t: T] extends [
|
|
145
145
|
+t: ?$ReadOnlyArray<?infer V extends {
|
|
146
146
|
+$fragmentType: FragmentType,
|
|
147
147
|
...
|
|
148
148
|
}>,
|
|
149
149
|
]
|
|
150
|
-
? ?$ReadOnlyArray<?$FragmentRef
|
|
150
|
+
? ?$ReadOnlyArray<?$FragmentRef<NonNullable<V>>>
|
|
151
151
|
: T;
|
|
152
152
|
|
|
153
153
|
export type RelayFragmentContainer<TComponent: component(...empty)> = component(
|
package/RelayContext.js.flow
CHANGED
|
@@ -20,7 +20,7 @@ const invariant = require('invariant');
|
|
|
20
20
|
* Asserts that the input is a matches the `RelayContext` type defined in
|
|
21
21
|
* `RelayEnvironmentTypes` and returns it as that type.
|
|
22
22
|
*/
|
|
23
|
-
function assertRelayContext(relay:
|
|
23
|
+
function assertRelayContext(relay: unknown): RelayContext {
|
|
24
24
|
invariant(
|
|
25
25
|
isRelayContext(relay),
|
|
26
26
|
'RelayContext: Expected `context.relay` to be an object conforming to ' +
|
|
@@ -34,7 +34,7 @@ function assertRelayContext(relay: mixed): RelayContext {
|
|
|
34
34
|
* Determine if the input is a plain object that matches the `RelayContext`
|
|
35
35
|
* type defined in `RelayEnvironmentTypes`.
|
|
36
36
|
*/
|
|
37
|
-
function isRelayContext(context:
|
|
37
|
+
function isRelayContext(context: unknown): boolean {
|
|
38
38
|
return (
|
|
39
39
|
typeof context === 'object' &&
|
|
40
40
|
context !== null &&
|
|
@@ -55,7 +55,7 @@ function buildReactRelayContainer<TBase: component(...empty)>(
|
|
|
55
55
|
function ForwardRef(
|
|
56
56
|
props: any,
|
|
57
57
|
ref:
|
|
58
|
-
| ((null | React.ElementRef<TBase>) =>
|
|
58
|
+
| ((null | React.ElementRef<TBase>) => unknown)
|
|
59
59
|
| {-current: null | React.ElementRef<TBase>, ...},
|
|
60
60
|
) {
|
|
61
61
|
// $FlowFixMe[react-rule-hook]
|
package/hooks.js
CHANGED
package/index.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* Determine if a given value is an object that implements the `Environment`
|
|
16
16
|
* interface defined in `RelayEnvironmentTypes`.
|
|
17
17
|
*/
|
|
18
|
-
function isRelayEnvironment(environment:
|
|
18
|
+
function isRelayEnvironment(environment: unknown): boolean {
|
|
19
19
|
return (
|
|
20
20
|
typeof environment === 'object' &&
|
|
21
21
|
environment !== null &&
|
package/legacy.js
CHANGED
|
@@ -12,13 +12,8 @@ var useContext = React.useContext,
|
|
|
12
12
|
useEffect = React.useEffect,
|
|
13
13
|
useState = React.useState,
|
|
14
14
|
useRef = React.useRef;
|
|
15
|
-
function useLazyLoadQueryNode(
|
|
16
|
-
var
|
|
17
|
-
componentDisplayName = _ref.componentDisplayName,
|
|
18
|
-
fetchObservable = _ref.fetchObservable,
|
|
19
|
-
fetchPolicy = _ref.fetchPolicy,
|
|
20
|
-
fetchKey = _ref.fetchKey,
|
|
21
|
-
renderPolicy = _ref.renderPolicy;
|
|
15
|
+
function useLazyLoadQueryNode(params) {
|
|
16
|
+
var _preparedQueryResult;
|
|
22
17
|
var environment = useRelayEnvironment();
|
|
23
18
|
var profilerContext = useContext(ProfilerContext);
|
|
24
19
|
var QueryResource = getQueryResourceForEnvironment(environment);
|
|
@@ -28,15 +23,29 @@ function useLazyLoadQueryNode(_ref) {
|
|
|
28
23
|
var _useFetchTrackingRef = useFetchTrackingRef(),
|
|
29
24
|
startFetch = _useFetchTrackingRef.startFetch,
|
|
30
25
|
completeFetch = _useFetchTrackingRef.completeFetch;
|
|
31
|
-
var
|
|
32
|
-
var
|
|
33
|
-
var
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
26
|
+
var cacheIdentifier = null;
|
|
27
|
+
var preparedQueryResult = null;
|
|
28
|
+
var fragmentNode;
|
|
29
|
+
if (params.query != null) {
|
|
30
|
+
var query = params.query,
|
|
31
|
+
fetchObservable = params.fetchObservable,
|
|
32
|
+
fetchPolicy = params.fetchPolicy,
|
|
33
|
+
fetchKey = params.fetchKey,
|
|
34
|
+
renderPolicy = params.renderPolicy;
|
|
35
|
+
var cacheBreaker = "".concat(forceUpdateKey, "-").concat(fetchKey !== null && fetchKey !== void 0 ? fetchKey : '');
|
|
36
|
+
var queryCacheIdentifier = getQueryCacheIdentifier(environment, query, fetchPolicy, renderPolicy, cacheBreaker);
|
|
37
|
+
cacheIdentifier = queryCacheIdentifier;
|
|
38
|
+
preparedQueryResult = profilerContext.wrapPrepareQueryResource(function () {
|
|
39
|
+
return QueryResource.prepareWithIdentifier(queryCacheIdentifier, query, fetchObservable, fetchPolicy, renderPolicy, {
|
|
40
|
+
start: startFetch,
|
|
41
|
+
complete: completeFetch,
|
|
42
|
+
error: completeFetch
|
|
43
|
+
}, profilerContext);
|
|
44
|
+
});
|
|
45
|
+
fragmentNode = preparedQueryResult.fragmentNode;
|
|
46
|
+
} else {
|
|
47
|
+
fragmentNode = params.fragmentNode;
|
|
48
|
+
}
|
|
40
49
|
var maybeHiddenOrFastRefresh = useRef(false);
|
|
41
50
|
useEffect(function () {
|
|
42
51
|
return function () {
|
|
@@ -51,17 +60,21 @@ function useLazyLoadQueryNode(_ref) {
|
|
|
51
60
|
});
|
|
52
61
|
return;
|
|
53
62
|
}
|
|
63
|
+
if (preparedQueryResult == null) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
54
66
|
var disposable = QueryResource.retain(preparedQueryResult, profilerContext);
|
|
55
67
|
return function () {
|
|
56
68
|
disposable.dispose();
|
|
57
69
|
};
|
|
58
70
|
}, [environment, cacheIdentifier]);
|
|
59
71
|
useEffect(function () {
|
|
72
|
+
if (preparedQueryResult == null) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
60
75
|
QueryResource.releaseTemporaryRetain(preparedQueryResult);
|
|
61
76
|
});
|
|
62
|
-
var fragmentNode = preparedQueryResult.
|
|
63
|
-
fragmentRef = preparedQueryResult.fragmentRef;
|
|
64
|
-
var data = useFragmentInternal(fragmentNode, fragmentRef, componentDisplayName);
|
|
77
|
+
var data = useFragmentInternal(fragmentNode, (_preparedQueryResult = preparedQueryResult) === null || _preparedQueryResult === void 0 ? void 0 : _preparedQueryResult.fragmentRef, params.componentDisplayName);
|
|
65
78
|
return data;
|
|
66
79
|
}
|
|
67
80
|
module.exports = useLazyLoadQueryNode;
|
|
@@ -13,64 +13,69 @@ var _require2 = require('relay-runtime'),
|
|
|
13
13
|
var warning = require("fbjs/lib/warning");
|
|
14
14
|
function usePreloadedQuery(gqlQuery, preloadedQuery, options) {
|
|
15
15
|
var environment = useRelayEnvironment();
|
|
16
|
-
var
|
|
17
|
-
fetchPolicy = preloadedQuery.fetchPolicy,
|
|
18
|
-
source = preloadedQuery.source,
|
|
19
|
-
variables = preloadedQuery.variables,
|
|
20
|
-
networkCacheConfig = preloadedQuery.networkCacheConfig;
|
|
21
|
-
var operation = useMemoOperationDescriptor(gqlQuery, variables, networkCacheConfig);
|
|
16
|
+
var operation = useMemoOperationDescriptor(gqlQuery, preloadedQuery != null ? preloadedQuery.variables : {}, preloadedQuery != null ? preloadedQuery.networkCacheConfig : undefined);
|
|
22
17
|
var useLazyLoadQueryNodeParams;
|
|
23
|
-
if (preloadedQuery
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if (source != null && environment === preloadedQuery.environment) {
|
|
49
|
-
fetchObservable = source.ifEmpty(fallbackFetchObservable);
|
|
50
|
-
} else if (environment !== preloadedQuery.environment) {
|
|
51
|
-
process.env.NODE_ENV !== "production" ? warning(false, 'usePreloadedQuery(): usePreloadedQuery was passed a preloaded query ' + 'that was created with a different environment than the one that is currently ' + 'in context. In the future, this will become a hard error.') : void 0;
|
|
52
|
-
fetchObservable = fallbackFetchObservable;
|
|
18
|
+
if (preloadedQuery != null) {
|
|
19
|
+
var fetchKey = preloadedQuery.fetchKey,
|
|
20
|
+
fetchPolicy = preloadedQuery.fetchPolicy,
|
|
21
|
+
source = preloadedQuery.source;
|
|
22
|
+
if (preloadedQuery.kind === 'PreloadedQuery_DEPRECATED') {
|
|
23
|
+
!(operation.request.node.params.name === preloadedQuery.name) ? process.env.NODE_ENV !== "production" ? invariant(false, 'usePreloadedQuery(): Expected data to be prefetched for query `%s`, ' + 'got prefetch results for query `%s`.', operation.request.node.params.name, preloadedQuery.name) : invariant(false) : void 0;
|
|
24
|
+
useLazyLoadQueryNodeParams = {
|
|
25
|
+
componentDisplayName: 'usePreloadedQuery()',
|
|
26
|
+
fetchKey: fetchKey,
|
|
27
|
+
fetchObservable: fetchQueryDeduped(environment, operation.request.identifier, function () {
|
|
28
|
+
if (environment === preloadedQuery.environment && source != null) {
|
|
29
|
+
return environment.executeWithSource({
|
|
30
|
+
operation: operation,
|
|
31
|
+
source: source
|
|
32
|
+
});
|
|
33
|
+
} else {
|
|
34
|
+
return environment.execute({
|
|
35
|
+
operation: operation
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}),
|
|
39
|
+
fetchPolicy: fetchPolicy,
|
|
40
|
+
query: operation,
|
|
41
|
+
renderPolicy: options === null || options === void 0 ? void 0 : options.UNSTABLE_renderPolicy
|
|
42
|
+
};
|
|
53
43
|
} else {
|
|
54
|
-
|
|
44
|
+
process.env.NODE_ENV !== "production" ? warning(preloadedQuery.isDisposed === false, 'usePreloadedQuery(): Expected preloadedQuery to not be disposed yet. ' + 'This is because disposing the query marks it for future garbage ' + 'collection, and as such query results may no longer be present in the Relay ' + 'store. In the future, this will become a hard error.') : void 0;
|
|
45
|
+
var fallbackFetchObservable = fetchQuery(environment, operation);
|
|
46
|
+
var fetchObservable;
|
|
47
|
+
if (source != null && environment === preloadedQuery.environment) {
|
|
48
|
+
fetchObservable = source.ifEmpty(fallbackFetchObservable);
|
|
49
|
+
} else if (environment !== preloadedQuery.environment) {
|
|
50
|
+
process.env.NODE_ENV !== "production" ? warning(false, 'usePreloadedQuery(): usePreloadedQuery was passed a preloaded query ' + 'that was created with a different environment than the one that is currently ' + 'in context. In the future, this will become a hard error.') : void 0;
|
|
51
|
+
fetchObservable = fallbackFetchObservable;
|
|
52
|
+
} else {
|
|
53
|
+
fetchObservable = fallbackFetchObservable;
|
|
54
|
+
}
|
|
55
|
+
useLazyLoadQueryNodeParams = {
|
|
56
|
+
componentDisplayName: 'usePreloadedQuery()',
|
|
57
|
+
fetchKey: fetchKey,
|
|
58
|
+
fetchObservable: fetchObservable,
|
|
59
|
+
fetchPolicy: fetchPolicy,
|
|
60
|
+
query: operation,
|
|
61
|
+
renderPolicy: options === null || options === void 0 ? void 0 : options.UNSTABLE_renderPolicy
|
|
62
|
+
};
|
|
55
63
|
}
|
|
64
|
+
} else {
|
|
56
65
|
useLazyLoadQueryNodeParams = {
|
|
57
66
|
componentDisplayName: 'usePreloadedQuery()',
|
|
58
|
-
|
|
59
|
-
fetchKey: fetchKey,
|
|
60
|
-
fetchPolicy: fetchPolicy,
|
|
61
|
-
query: operation,
|
|
62
|
-
renderPolicy: options === null || options === void 0 ? void 0 : options.UNSTABLE_renderPolicy
|
|
67
|
+
fragmentNode: gqlQuery.fragment
|
|
63
68
|
};
|
|
64
69
|
}
|
|
65
70
|
var data = useLazyLoadQueryNode(useLazyLoadQueryNodeParams);
|
|
66
71
|
if (process.env.NODE_ENV !== "production") {
|
|
67
72
|
useDebugValue({
|
|
68
|
-
query: preloadedQuery.name,
|
|
69
|
-
variables: preloadedQuery.variables,
|
|
70
73
|
data: data,
|
|
71
|
-
fetchKey: fetchKey,
|
|
72
|
-
fetchPolicy: fetchPolicy,
|
|
73
|
-
|
|
74
|
+
fetchKey: preloadedQuery === null || preloadedQuery === void 0 ? void 0 : preloadedQuery.fetchKey,
|
|
75
|
+
fetchPolicy: preloadedQuery === null || preloadedQuery === void 0 ? void 0 : preloadedQuery.fetchPolicy,
|
|
76
|
+
query: preloadedQuery === null || preloadedQuery === void 0 ? void 0 : preloadedQuery.name,
|
|
77
|
+
renderPolicy: options === null || options === void 0 ? void 0 : options.UNSTABLE_renderPolicy,
|
|
78
|
+
variables: preloadedQuery === null || preloadedQuery === void 0 ? void 0 : preloadedQuery.variables
|
|
74
79
|
});
|
|
75
80
|
}
|
|
76
81
|
return data;
|
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-9af45f9c",
|
|
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-9af45f9c"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"react": "^16.9.0 || ^17 || ^18 || ^19"
|
|
@@ -59,7 +59,7 @@ export type PreloadableConcreteRequest<+TQuery: OperationType> = {
|
|
|
59
59
|
+__phantom__?: ?TQuery,
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
export type EnvironmentProviderOptions = {+[string]:
|
|
62
|
+
export type EnvironmentProviderOptions = {+[string]: unknown, ...};
|
|
63
63
|
|
|
64
64
|
export type PreloadedQuery<
|
|
65
65
|
+TQuery: OperationType,
|
|
@@ -57,7 +57,7 @@ type EntryPointContainerProps<
|
|
|
57
57
|
}>,
|
|
58
58
|
>;
|
|
59
59
|
|
|
60
|
-
function stableStringify(value:
|
|
60
|
+
function stableStringify(value: unknown): string {
|
|
61
61
|
return JSON.stringify(stableCopy(value)) ?? 'null';
|
|
62
62
|
}
|
|
63
63
|
|
|
@@ -104,7 +104,7 @@ function prepareEntryPoint<
|
|
|
104
104
|
// $FlowFixMe[incompatible-type]
|
|
105
105
|
preloadedQueries[queryPropName] = preloadQuery_DEPRECATED<
|
|
106
106
|
OperationType,
|
|
107
|
-
|
|
107
|
+
unknown,
|
|
108
108
|
>(
|
|
109
109
|
environment,
|
|
110
110
|
parameters,
|
|
@@ -129,8 +129,8 @@ function prepareEntryPoint<
|
|
|
129
129
|
{},
|
|
130
130
|
{...},
|
|
131
131
|
{...},
|
|
132
|
-
|
|
133
|
-
EntryPointComponent<{}, {...}, {...},
|
|
132
|
+
unknown,
|
|
133
|
+
EntryPointComponent<{}, {...}, {...}, unknown>,
|
|
134
134
|
_,
|
|
135
135
|
>(environmentProvider, nestedEntryPoint, nestedParams);
|
|
136
136
|
});
|
|
@@ -88,14 +88,14 @@ const {useMemo} = React;
|
|
|
88
88
|
type TypenameOnlyPointer = {+__typename: string};
|
|
89
89
|
export type MatchPointer = {
|
|
90
90
|
+__fragmentPropName?: ?string,
|
|
91
|
-
+__module_component?:
|
|
92
|
-
+$fragmentSpreads:
|
|
91
|
+
+__module_component?: unknown,
|
|
92
|
+
+$fragmentSpreads: unknown,
|
|
93
93
|
...
|
|
94
94
|
};
|
|
95
95
|
|
|
96
96
|
export type MatchContainerProps<TProps: {...}, TFallback: React.Node> = {
|
|
97
97
|
+fallback?: ?TFallback,
|
|
98
|
-
+loader: (module:
|
|
98
|
+
+loader: (module: unknown) => component(...TProps),
|
|
99
99
|
+match: ?MatchPointer | ?TypenameOnlyPointer,
|
|
100
100
|
+props?: TProps,
|
|
101
101
|
};
|
|
@@ -58,12 +58,12 @@ type QueryResourceCacheEntry = {
|
|
|
58
58
|
};
|
|
59
59
|
export opaque type QueryResult: {
|
|
60
60
|
fragmentNode: ReaderFragment,
|
|
61
|
-
fragmentRef:
|
|
61
|
+
fragmentRef: unknown,
|
|
62
62
|
...
|
|
63
63
|
} = {
|
|
64
64
|
cacheIdentifier: string,
|
|
65
65
|
fragmentNode: ReaderFragment,
|
|
66
|
-
fragmentRef:
|
|
66
|
+
fragmentRef: unknown,
|
|
67
67
|
operation: OperationDescriptor,
|
|
68
68
|
};
|
|
69
69
|
|
|
@@ -206,7 +206,7 @@ class QueryResourceImpl {
|
|
|
206
206
|
maybeRenderPolicy: ?RenderPolicy,
|
|
207
207
|
observer: ?Observer<Snapshot>,
|
|
208
208
|
cacheBreaker: ?string | ?number,
|
|
209
|
-
profilerContext:
|
|
209
|
+
profilerContext: unknown,
|
|
210
210
|
): QueryResult {
|
|
211
211
|
const cacheIdentifier = getQueryCacheIdentifier(
|
|
212
212
|
this._environment,
|
|
@@ -238,7 +238,7 @@ class QueryResourceImpl {
|
|
|
238
238
|
maybeFetchPolicy: ?FetchPolicy,
|
|
239
239
|
maybeRenderPolicy: ?RenderPolicy,
|
|
240
240
|
observer: ?Observer<Snapshot>,
|
|
241
|
-
profilerContext:
|
|
241
|
+
profilerContext: unknown,
|
|
242
242
|
): QueryResult {
|
|
243
243
|
const environment = this._environment;
|
|
244
244
|
const fetchPolicy =
|
|
@@ -313,7 +313,7 @@ class QueryResourceImpl {
|
|
|
313
313
|
* (e.g. inside useEffect), in order to retain the operation in the Relay store
|
|
314
314
|
* and transfer ownership of the operation to the component lifecycle.
|
|
315
315
|
*/
|
|
316
|
-
retain(queryResult: QueryResult, profilerContext:
|
|
316
|
+
retain(queryResult: QueryResult, profilerContext: unknown): Disposable {
|
|
317
317
|
const environment = this._environment;
|
|
318
318
|
const {cacheIdentifier, operation} = queryResult;
|
|
319
319
|
const cacheEntry = this._getOrCreateCacheEntry(
|
|
@@ -393,7 +393,7 @@ class QueryResourceImpl {
|
|
|
393
393
|
fetchObservable: Observable<GraphQLResponse>,
|
|
394
394
|
fetchPolicy: FetchPolicy,
|
|
395
395
|
renderPolicy: RenderPolicy,
|
|
396
|
-
profilerContext:
|
|
396
|
+
profilerContext: unknown,
|
|
397
397
|
observer: Observer<Snapshot>,
|
|
398
398
|
): QueryResourceCacheEntry {
|
|
399
399
|
const environment = this._environment;
|
|
@@ -19,7 +19,7 @@ const {ConnectionInterface, getValueAtPath} = require('relay-runtime');
|
|
|
19
19
|
function getConnectionState(
|
|
20
20
|
direction: Direction,
|
|
21
21
|
fragmentNode: ReaderFragment,
|
|
22
|
-
fragmentData:
|
|
22
|
+
fragmentData: unknown,
|
|
23
23
|
connectionPathInFragmentData: $ReadOnlyArray<string | number>,
|
|
24
24
|
): {
|
|
25
25
|
cursor: ?string,
|
|
@@ -46,7 +46,7 @@ type FragmentResourceCache = Cache<
|
|
|
46
46
|
| {
|
|
47
47
|
kind: 'pending',
|
|
48
48
|
pendingOperations: $ReadOnlyArray<RequestDescriptor>,
|
|
49
|
-
promise: Promise<
|
|
49
|
+
promise: Promise<unknown>,
|
|
50
50
|
result: FragmentResult,
|
|
51
51
|
}
|
|
52
52
|
| {kind: 'done', result: FragmentResult}
|
|
@@ -65,9 +65,9 @@ interface IMap<K, V> {
|
|
|
65
65
|
|
|
66
66
|
type SingularOrPluralSnapshot = Snapshot | $ReadOnlyArray<Snapshot>;
|
|
67
67
|
|
|
68
|
-
opaque type FragmentResult: {data:
|
|
68
|
+
opaque type FragmentResult: {data: unknown, ...} = {
|
|
69
69
|
cacheKey: string,
|
|
70
|
-
data:
|
|
70
|
+
data: unknown,
|
|
71
71
|
isMissingData: boolean,
|
|
72
72
|
snapshot: SingularOrPluralSnapshot | null,
|
|
73
73
|
storeEpoch: number,
|
|
@@ -217,7 +217,7 @@ class FragmentResourceImpl {
|
|
|
217
217
|
*/
|
|
218
218
|
read(
|
|
219
219
|
fragmentNode: ReaderFragment,
|
|
220
|
-
fragmentRef:
|
|
220
|
+
fragmentRef: unknown,
|
|
221
221
|
componentDisplayName: string,
|
|
222
222
|
fragmentKey?: string,
|
|
223
223
|
): FragmentResult {
|
|
@@ -237,7 +237,7 @@ class FragmentResourceImpl {
|
|
|
237
237
|
*/
|
|
238
238
|
readWithIdentifier(
|
|
239
239
|
fragmentNode: ReaderFragment,
|
|
240
|
-
fragmentRef:
|
|
240
|
+
fragmentRef: unknown,
|
|
241
241
|
fragmentIdentifier: string,
|
|
242
242
|
componentDisplayName: string,
|
|
243
243
|
fragmentKey?: ?string,
|
|
@@ -527,7 +527,7 @@ class FragmentResourceImpl {
|
|
|
527
527
|
_performClientEdgeQuery(
|
|
528
528
|
queryResource: QueryResource,
|
|
529
529
|
fragmentNode: ReaderFragment,
|
|
530
|
-
fragmentRef:
|
|
530
|
+
fragmentRef: unknown,
|
|
531
531
|
request: ConcreteRequest,
|
|
532
532
|
clientEdgeDestinationID: DataID,
|
|
533
533
|
): {queryResult: QueryResult, requestDescriptor: RequestDescriptor} {
|
|
@@ -568,7 +568,7 @@ class FragmentResourceImpl {
|
|
|
568
568
|
|
|
569
569
|
readSpec(
|
|
570
570
|
fragmentNodes: {[string]: ReaderFragment, ...},
|
|
571
|
-
fragmentRefs: {[string]:
|
|
571
|
+
fragmentRefs: {[string]: unknown, ...},
|
|
572
572
|
componentDisplayName: string,
|
|
573
573
|
): {[string]: FragmentResult, ...} {
|
|
574
574
|
const result: {[string]: FragmentResult} = {};
|
|
@@ -31,7 +31,7 @@ type RefetchVariables<TVariables, TKey> =
|
|
|
31
31
|
// NOTE: This type ensures that the type of the variables is either:
|
|
32
32
|
// - nullable if the provided ref type is non-nullable
|
|
33
33
|
// - non-nullable if the provided ref type is nullable, and the caller need to provide the full set of variables
|
|
34
|
-
[+key: TKey] extends [+key: {+$fragmentSpreads:
|
|
34
|
+
[+key: TKey] extends [+key: {+$fragmentSpreads: unknown, ...}]
|
|
35
35
|
? Partial<TVariables>
|
|
36
36
|
: TVariables;
|
|
37
37
|
|
|
@@ -49,7 +49,7 @@ type ReturnType<TVariables, TData, TKey> = {
|
|
|
49
49
|
// NOTE: This rtpw ensures that the type of the returned data is either:
|
|
50
50
|
// - nullable if the provided ref type is nullable
|
|
51
51
|
// - non-nullable if the provided ref type is non-nullable
|
|
52
|
-
data: [+key: TKey] extends [+key: {+$fragmentSpreads:
|
|
52
|
+
data: [+key: TKey] extends [+key: {+$fragmentSpreads: unknown, ...}]
|
|
53
53
|
? TData
|
|
54
54
|
: ?TData,
|
|
55
55
|
loadNext: LoadMoreFn<TVariables>,
|
|
@@ -99,7 +99,7 @@ hook useBlockingPaginationFragment<
|
|
|
99
99
|
variables: TVariables,
|
|
100
100
|
},
|
|
101
101
|
{
|
|
102
|
-
+$data:
|
|
102
|
+
+$data: unknown,
|
|
103
103
|
...
|
|
104
104
|
},
|
|
105
105
|
>(fragmentNode, parentFragmentRef, componentDisplayName);
|
|
@@ -167,10 +167,10 @@ hook useLoadMore<TVariables: Variables>(args: {
|
|
|
167
167
|
...$Exact<Omit<UseLoadMoreFunctionArgs, 'observer' | 'onReset'>>,
|
|
168
168
|
}): [LoadMoreFn<TVariables>, boolean, () => void] {
|
|
169
169
|
const {disableStoreUpdates, enableStoreUpdates, ...loadMoreArgs} = args;
|
|
170
|
-
const [requestPromise, setRequestPromise] = useState<null | Promise<
|
|
170
|
+
const [requestPromise, setRequestPromise] = useState<null | Promise<unknown>>(
|
|
171
171
|
null,
|
|
172
172
|
);
|
|
173
|
-
const requestPromiseRef = useRef<null | Promise<
|
|
173
|
+
const requestPromiseRef = useRef<null | Promise<unknown>>(null);
|
|
174
174
|
const promiseResolveRef = useRef<null | (() => void)>(null);
|
|
175
175
|
|
|
176
176
|
const promiseResolve = () => {
|
|
@@ -20,15 +20,15 @@ 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: 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: unknown>(
|
|
30
30
|
fragmentNode: ReaderFragment,
|
|
31
|
-
fragmentRef:
|
|
31
|
+
fragmentRef: unknown,
|
|
32
32
|
componentDisplayName: string,
|
|
33
33
|
): ReturnType<TFragmentData> {
|
|
34
34
|
const environment = useRelayEnvironment();
|