react-relay 11.0.1 → 13.0.0-rc.1
Sign up to get free protection for your applications and to get access to all the features.
- package/ReactRelayContext.js +1 -1
- package/ReactRelayContext.js.flow +2 -3
- package/ReactRelayFragmentContainer.js.flow +24 -24
- package/ReactRelayFragmentMockRenderer.js.flow +1 -1
- package/ReactRelayLocalQueryRenderer.js.flow +6 -7
- package/ReactRelayPaginationContainer.js.flow +111 -58
- package/ReactRelayQueryFetcher.js.flow +9 -10
- package/ReactRelayQueryRenderer.js.flow +115 -81
- package/ReactRelayRefetchContainer.js.flow +41 -38
- package/ReactRelayTestMocker.js.flow +16 -14
- package/ReactRelayTypes.js.flow +10 -10
- package/RelayContext.js.flow +3 -3
- package/__flowtests__/ReactRelayFragmentContainer-flowtest.js.flow +1 -2
- package/__flowtests__/ReactRelayPaginationContainer-flowtest.js.flow +11 -7
- package/__flowtests__/ReactRelayRefetchContainer-flowtest.js.flow +10 -6
- package/__flowtests__/RelayModern-flowtest.js.flow +78 -46
- package/__flowtests__/RelayModernFlowtest_badref.graphql.js.flow +5 -4
- package/__flowtests__/RelayModernFlowtest_notref.graphql.js.flow +5 -4
- package/__flowtests__/RelayModernFlowtest_user.graphql.js.flow +4 -3
- package/__flowtests__/RelayModernFlowtest_users.graphql.js.flow +4 -3
- package/__flowtests__/__generated__/ReactRelayFragmentContainerFlowtest_viewer.graphql.js.flow +72 -0
- package/__flowtests__/__generated__/ReactRelayFragmentContainerFlowtest_viewer2.graphql.js.flow +72 -0
- package/__flowtests__/__generated__/ReactRelayPaginationContainerFlowtestQuery.graphql.js.flow +227 -0
- package/__flowtests__/__generated__/ReactRelayPaginationContainerFlowtest_viewer.graphql.js.flow +164 -0
- package/__flowtests__/__generated__/ReactRelayRefetchContainerFlowtestQuery.graphql.js.flow +227 -0
- package/__flowtests__/__generated__/ReactRelayRefetchContainerFlowtest_viewer.graphql.js.flow +164 -0
- package/__flowtests__/__generated__/RelayModernFlowtest_badref.graphql.js.flow +66 -0
- package/__flowtests__/__generated__/RelayModernFlowtest_notref.graphql.js.flow +66 -0
- package/__flowtests__/__generated__/RelayModernFlowtest_user.graphql.js.flow +59 -0
- package/__flowtests__/__generated__/RelayModernFlowtest_users.graphql.js.flow +61 -0
- package/assertFragmentMap.js.flow +2 -2
- package/buildReactRelayContainer.js.flow +15 -12
- package/getRootVariablesForFragments.js.flow +2 -4
- package/hooks.js +1 -1
- package/hooks.js.flow +5 -6
- package/index.js +1 -1
- package/index.js.flow +6 -7
- package/jest-react/enqueueTask.js.flow +56 -0
- package/jest-react/index.js.flow +12 -0
- package/jest-react/internalAct.js.flow +139 -0
- package/legacy.js +1 -1
- package/lib/ReactRelayFragmentContainer.js +21 -15
- package/lib/ReactRelayFragmentMockRenderer.js +2 -2
- package/lib/ReactRelayLocalQueryRenderer.js +7 -8
- package/lib/ReactRelayPaginationContainer.js +96 -38
- package/lib/ReactRelayQueryFetcher.js +3 -3
- package/lib/ReactRelayQueryRenderer.js +86 -53
- package/lib/ReactRelayRefetchContainer.js +38 -25
- package/lib/ReactRelayTestMocker.js +8 -9
- package/lib/RelayContext.js +3 -2
- package/lib/assertFragmentMap.js +3 -2
- package/lib/buildReactRelayContainer.js +14 -11
- package/lib/getRootVariablesForFragments.js +1 -2
- package/lib/hooks.js +5 -5
- package/lib/index.js +7 -7
- package/lib/jest-react/enqueueTask.js +53 -0
- package/lib/jest-react/index.js +13 -0
- package/lib/jest-react/internalAct.js +116 -0
- package/lib/multi-actor/ActorChange.js +30 -0
- package/lib/multi-actor/index.js +11 -0
- package/lib/multi-actor/useRelayActorEnvironment.js +29 -0
- package/lib/relay-hooks/EntryPointContainer.react.js +3 -3
- package/lib/relay-hooks/FragmentResource.js +347 -92
- package/lib/relay-hooks/LRUCache.js +1 -1
- package/lib/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js +4 -4
- package/lib/relay-hooks/MatchContainer.js +1 -1
- package/lib/relay-hooks/QueryResource.js +172 -29
- package/lib/relay-hooks/RelayEnvironmentProvider.js +5 -3
- package/lib/relay-hooks/SuspenseResource.js +130 -0
- package/lib/relay-hooks/loadQuery.js +42 -20
- package/lib/relay-hooks/preloadQuery_DEPRECATED.js +24 -15
- package/lib/relay-hooks/useBlockingPaginationFragment.js +4 -5
- package/lib/relay-hooks/useEntryPointLoader.js +2 -2
- package/lib/relay-hooks/useFetchTrackingRef.js +2 -1
- package/lib/relay-hooks/useFragment.js +8 -7
- package/lib/relay-hooks/useFragmentNode.js +4 -4
- package/lib/relay-hooks/useIsOperationNodeActive.js +3 -3
- package/lib/relay-hooks/useLazyLoadQuery.js +3 -3
- package/lib/relay-hooks/useLazyLoadQueryNode.js +10 -4
- package/lib/relay-hooks/useLoadMoreFunction.js +8 -12
- package/lib/relay-hooks/useMemoOperationDescriptor.js +2 -2
- package/lib/relay-hooks/useMemoVariables.js +2 -2
- package/lib/relay-hooks/useMutation.js +17 -6
- package/lib/relay-hooks/usePaginationFragment.js +2 -3
- package/lib/relay-hooks/usePreloadedQuery.js +8 -7
- package/lib/relay-hooks/useQueryLoader.js +30 -10
- package/lib/relay-hooks/useRefetchableFragmentNode.js +13 -17
- package/lib/relay-hooks/useRelayEnvironment.js +3 -3
- package/lib/relay-hooks/useStaticFragmentNodeWarning.js +2 -2
- package/lib/relay-hooks/useSubscribeToInvalidationState.js +2 -1
- package/lib/relay-hooks/useSubscription.js +10 -7
- package/multi-actor/ActorChange.js.flow +58 -0
- package/multi-actor/index.js.flow +14 -0
- package/multi-actor/useRelayActorEnvironment.js.flow +49 -0
- package/package.json +3 -2
- package/react-relay-hooks.js +2 -2
- package/react-relay-hooks.min.js +2 -2
- package/react-relay-legacy.js +2 -2
- package/react-relay-legacy.min.js +2 -2
- package/react-relay.js +2 -2
- package/react-relay.min.js +2 -2
- package/relay-hooks/EntryPointContainer.react.js.flow +8 -15
- package/relay-hooks/EntryPointTypes.flow.js.flow +24 -25
- package/relay-hooks/FragmentResource.js.flow +368 -94
- package/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js.flow +32 -46
- package/relay-hooks/MatchContainer.js.flow +3 -2
- package/relay-hooks/QueryResource.js.flow +216 -25
- package/relay-hooks/RelayEnvironmentProvider.js.flow +14 -4
- package/relay-hooks/SuspenseResource.js.flow +115 -0
- package/relay-hooks/__flowtests__/EntryPointTypes/EntryPointElementConfig-flowtest.js.flow +4 -3
- package/relay-hooks/__flowtests__/EntryPointTypes/NestedEntrypoints-flowtest.js.flow +1 -1
- package/relay-hooks/__flowtests__/useBlockingPaginationFragment-flowtest.js.flow +10 -9
- package/relay-hooks/__flowtests__/useFragment-flowtest.js.flow +8 -7
- package/relay-hooks/__flowtests__/usePaginationFragment-flowtest.js.flow +10 -9
- package/relay-hooks/__flowtests__/useRefetchableFragment-flowtest.js.flow +10 -9
- package/relay-hooks/__flowtests__/utils.js.flow +8 -12
- package/relay-hooks/loadEntryPoint.js.flow +6 -12
- package/relay-hooks/loadQuery.js.flow +49 -31
- package/relay-hooks/preloadQuery_DEPRECATED.js.flow +30 -21
- package/relay-hooks/prepareEntryPoint_DEPRECATED.js.flow +6 -12
- package/relay-hooks/useBlockingPaginationFragment.js.flow +13 -11
- package/relay-hooks/useEntryPointLoader.js.flow +7 -10
- package/relay-hooks/useFetchTrackingRef.js.flow +2 -2
- package/relay-hooks/useFragment.js.flow +26 -46
- package/relay-hooks/useFragmentNode.js.flow +5 -7
- package/relay-hooks/useIsOperationNodeActive.js.flow +3 -5
- package/relay-hooks/useIsParentQueryActive.js.flow +3 -4
- package/relay-hooks/useLazyLoadQuery.js.flow +9 -10
- package/relay-hooks/useLazyLoadQueryNode.js.flow +19 -13
- package/relay-hooks/useLoadMoreFunction.js.flow +20 -29
- package/relay-hooks/useMemoOperationDescriptor.js.flow +5 -7
- package/relay-hooks/useMemoVariables.js.flow +6 -6
- package/relay-hooks/useMutation.js.flow +26 -26
- package/relay-hooks/usePaginationFragment.js.flow +38 -44
- package/relay-hooks/usePreloadedQuery.js.flow +18 -14
- package/relay-hooks/useQueryLoader.js.flow +41 -22
- package/relay-hooks/useRefetchableFragment.js.flow +7 -8
- package/relay-hooks/useRefetchableFragmentNode.js.flow +24 -32
- package/relay-hooks/useRelayEnvironment.js.flow +2 -4
- package/relay-hooks/useStaticFragmentNodeWarning.js.flow +2 -3
- package/relay-hooks/useSubscribeToInvalidationState.js.flow +3 -6
- package/relay-hooks/useSubscription.js.flow +20 -10
- package/lib/relay-hooks/getPaginationMetadata.js +0 -41
- package/lib/relay-hooks/getPaginationVariables.js +0 -67
- package/lib/relay-hooks/getRefetchMetadata.js +0 -36
- package/lib/relay-hooks/getValueAtPath.js +0 -51
- package/relay-hooks/getPaginationMetadata.js.flow +0 -74
- package/relay-hooks/getPaginationVariables.js.flow +0 -110
- package/relay-hooks/getRefetchMetadata.js.flow +0 -80
- package/relay-hooks/getValueAtPath.js.flow +0 -46
@@ -0,0 +1,59 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
3
|
+
*
|
4
|
+
* This source code is licensed under the MIT license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*
|
7
|
+
* @generated SignedSource<<9c7b60dab9f7983c67f2c7e1138f0eee>>
|
8
|
+
* @flow
|
9
|
+
* @lightSyntaxTransform
|
10
|
+
* @nogrep
|
11
|
+
*/
|
12
|
+
|
13
|
+
/* eslint-disable */
|
14
|
+
|
15
|
+
'use strict';
|
16
|
+
|
17
|
+
/*::
|
18
|
+
import type { Fragment, ReaderFragment } from 'relay-runtime';
|
19
|
+
import type { FragmentType } from "relay-runtime";
|
20
|
+
declare export opaque type RelayModernFlowtest_user$fragmentType: FragmentType;
|
21
|
+
export type RelayModernFlowtest_user$ref = RelayModernFlowtest_user$fragmentType;
|
22
|
+
export type RelayModernFlowtest_user$data = {|
|
23
|
+
+name: ?string,
|
24
|
+
+$fragmentType: RelayModernFlowtest_user$fragmentType,
|
25
|
+
|};
|
26
|
+
export type RelayModernFlowtest_user = RelayModernFlowtest_user$data;
|
27
|
+
export type RelayModernFlowtest_user$key = {
|
28
|
+
+$data?: RelayModernFlowtest_user$data,
|
29
|
+
+$fragmentSpreads: RelayModernFlowtest_user$fragmentType,
|
30
|
+
...
|
31
|
+
};
|
32
|
+
*/
|
33
|
+
|
34
|
+
var node/*: ReaderFragment*/ = {
|
35
|
+
"argumentDefinitions": [],
|
36
|
+
"kind": "Fragment",
|
37
|
+
"metadata": null,
|
38
|
+
"name": "RelayModernFlowtest_user",
|
39
|
+
"selections": [
|
40
|
+
{
|
41
|
+
"alias": null,
|
42
|
+
"args": null,
|
43
|
+
"kind": "ScalarField",
|
44
|
+
"name": "name",
|
45
|
+
"storageKey": null
|
46
|
+
}
|
47
|
+
],
|
48
|
+
"type": "User",
|
49
|
+
"abstractKey": null
|
50
|
+
};
|
51
|
+
|
52
|
+
if (__DEV__) {
|
53
|
+
(node/*: any*/).hash = "18a730295ff54e88446f4f000f5fef7e";
|
54
|
+
}
|
55
|
+
|
56
|
+
module.exports = ((node/*: any*/)/*: Fragment<
|
57
|
+
RelayModernFlowtest_user$fragmentType,
|
58
|
+
RelayModernFlowtest_user$data,
|
59
|
+
>*/);
|
@@ -0,0 +1,61 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
3
|
+
*
|
4
|
+
* This source code is licensed under the MIT license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*
|
7
|
+
* @generated SignedSource<<d2e1d6f0352e992d909d6217160aab1e>>
|
8
|
+
* @flow
|
9
|
+
* @lightSyntaxTransform
|
10
|
+
* @nogrep
|
11
|
+
*/
|
12
|
+
|
13
|
+
/* eslint-disable */
|
14
|
+
|
15
|
+
'use strict';
|
16
|
+
|
17
|
+
/*::
|
18
|
+
import type { Fragment, ReaderFragment } from 'relay-runtime';
|
19
|
+
import type { FragmentType } from "relay-runtime";
|
20
|
+
declare export opaque type RelayModernFlowtest_users$fragmentType: FragmentType;
|
21
|
+
export type RelayModernFlowtest_users$ref = RelayModernFlowtest_users$fragmentType;
|
22
|
+
export type RelayModernFlowtest_users$data = $ReadOnlyArray<{|
|
23
|
+
+name: ?string,
|
24
|
+
+$fragmentType: RelayModernFlowtest_users$fragmentType,
|
25
|
+
|}>;
|
26
|
+
export type RelayModernFlowtest_users = RelayModernFlowtest_users$data;
|
27
|
+
export type RelayModernFlowtest_users$key = $ReadOnlyArray<{
|
28
|
+
+$data?: RelayModernFlowtest_users$data,
|
29
|
+
+$fragmentSpreads: RelayModernFlowtest_users$fragmentType,
|
30
|
+
...
|
31
|
+
}>;
|
32
|
+
*/
|
33
|
+
|
34
|
+
var node/*: ReaderFragment*/ = {
|
35
|
+
"argumentDefinitions": [],
|
36
|
+
"kind": "Fragment",
|
37
|
+
"metadata": {
|
38
|
+
"plural": true
|
39
|
+
},
|
40
|
+
"name": "RelayModernFlowtest_users",
|
41
|
+
"selections": [
|
42
|
+
{
|
43
|
+
"alias": null,
|
44
|
+
"args": null,
|
45
|
+
"kind": "ScalarField",
|
46
|
+
"name": "name",
|
47
|
+
"storageKey": null
|
48
|
+
}
|
49
|
+
],
|
50
|
+
"type": "User",
|
51
|
+
"abstractKey": null
|
52
|
+
};
|
53
|
+
|
54
|
+
if (__DEV__) {
|
55
|
+
(node/*: any*/).hash = "4e6f0e70d48ec58651c17e3150c63d05";
|
56
|
+
}
|
57
|
+
|
58
|
+
module.exports = ((node/*: any*/)/*: Fragment<
|
59
|
+
RelayModernFlowtest_users$fragmentType,
|
60
|
+
RelayModernFlowtest_users$data,
|
61
|
+
>*/);
|
@@ -12,10 +12,10 @@
|
|
12
12
|
|
13
13
|
'use strict';
|
14
14
|
|
15
|
-
const invariant = require('invariant');
|
16
|
-
|
17
15
|
import type {GeneratedNodeMap} from './ReactRelayTypes';
|
18
16
|
|
17
|
+
const invariant = require('invariant');
|
18
|
+
|
19
19
|
/**
|
20
20
|
* Fail fast if the user supplies invalid fragments as input.
|
21
21
|
*/
|
@@ -12,24 +12,21 @@
|
|
12
12
|
|
13
13
|
'use strict';
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
const ReactRelayQueryRendererContext = require('./ReactRelayQueryRendererContext');
|
15
|
+
import type {GeneratedNodeMap} from './ReactRelayTypes';
|
16
|
+
import type {FragmentMap} from 'relay-runtime';
|
18
17
|
|
19
18
|
const assertFragmentMap = require('./assertFragmentMap');
|
20
|
-
const invariant = require('invariant');
|
21
|
-
const mapObject = require('mapObject');
|
22
|
-
const readContext = require('./readContext');
|
23
|
-
|
24
19
|
const {
|
25
20
|
getComponentName,
|
26
21
|
getContainerName,
|
27
22
|
} = require('./ReactRelayContainerUtils');
|
23
|
+
const ReactRelayContext = require('./ReactRelayContext');
|
24
|
+
const ReactRelayQueryRendererContext = require('./ReactRelayQueryRendererContext');
|
25
|
+
const readContext = require('./readContext');
|
26
|
+
const invariant = require('invariant');
|
27
|
+
const React = require('react');
|
28
28
|
const {getFragment} = require('relay-runtime');
|
29
29
|
|
30
|
-
import type {GeneratedNodeMap} from './ReactRelayTypes';
|
31
|
-
import type {FragmentMap} from 'relay-runtime';
|
32
|
-
|
33
30
|
type ContainerCreator = (
|
34
31
|
Component: React$ComponentType<any>,
|
35
32
|
fragments: FragmentMap,
|
@@ -48,11 +45,17 @@ function buildReactRelayContainer<TBase: React$ComponentType<any>>(
|
|
48
45
|
const containerName = getContainerName(ComponentClass);
|
49
46
|
assertFragmentMap(getComponentName(ComponentClass), fragmentSpec);
|
50
47
|
|
51
|
-
const fragments =
|
48
|
+
const fragments = {};
|
49
|
+
for (const key in fragmentSpec) {
|
50
|
+
fragments[key] = getFragment(fragmentSpec[key]);
|
51
|
+
}
|
52
52
|
const Container = createContainerWithFragments(ComponentClass, fragments);
|
53
53
|
Container.displayName = containerName;
|
54
54
|
|
55
|
-
function forwardRef(
|
55
|
+
function forwardRef(
|
56
|
+
props: any,
|
57
|
+
ref: ((null | any) => mixed) | {current: null | any, ...},
|
58
|
+
) {
|
56
59
|
const context = readContext(ReactRelayContext);
|
57
60
|
invariant(
|
58
61
|
context != null,
|
@@ -12,10 +12,10 @@
|
|
12
12
|
|
13
13
|
'use strict';
|
14
14
|
|
15
|
-
const {getSelector} = require('relay-runtime');
|
16
|
-
|
17
15
|
import type {FragmentMap, Variables} from 'relay-runtime';
|
18
16
|
|
17
|
+
const {getSelector} = require('relay-runtime');
|
18
|
+
|
19
19
|
function getRootVariablesForFragments<TProps: {...}>(
|
20
20
|
fragments: FragmentMap,
|
21
21
|
props: TProps,
|
@@ -32,11 +32,9 @@ function getRootVariablesForFragments<TProps: {...}>(
|
|
32
32
|
selector != null && selector.kind === 'PluralReaderSelector'
|
33
33
|
? selector.selectors[0]?.owner.variables ?? {}
|
34
34
|
: selector?.owner.variables ?? {};
|
35
|
-
// $FlowFixMe[cannot-spread-interface]
|
36
35
|
rootVariables = {
|
37
36
|
// $FlowFixMe[exponential-spread]
|
38
37
|
...rootVariables,
|
39
|
-
// $FlowFixMe[exponential-spread]
|
40
38
|
...fragmentOwnerVariables,
|
41
39
|
};
|
42
40
|
});
|
package/hooks.js
CHANGED
package/hooks.js.flow
CHANGED
@@ -13,10 +13,9 @@
|
|
13
13
|
'use strict';
|
14
14
|
|
15
15
|
const EntryPointContainer = require('./relay-hooks/EntryPointContainer.react');
|
16
|
-
const RelayEnvironmentProvider = require('./relay-hooks/RelayEnvironmentProvider');
|
17
|
-
const RelayRuntime = require('relay-runtime');
|
18
|
-
|
19
16
|
const loadEntryPoint = require('./relay-hooks/loadEntryPoint');
|
17
|
+
const {loadQuery} = require('./relay-hooks/loadQuery');
|
18
|
+
const RelayEnvironmentProvider = require('./relay-hooks/RelayEnvironmentProvider');
|
20
19
|
const useEntryPointLoader = require('./relay-hooks/useEntryPointLoader');
|
21
20
|
const useFragment = require('./relay-hooks/useFragment');
|
22
21
|
const useLazyLoadQuery = require('./relay-hooks/useLazyLoadQuery');
|
@@ -28,8 +27,7 @@ const useRefetchableFragment = require('./relay-hooks/useRefetchableFragment');
|
|
28
27
|
const useRelayEnvironment = require('./relay-hooks/useRelayEnvironment');
|
29
28
|
const useSubscribeToInvalidationState = require('./relay-hooks/useSubscribeToInvalidationState');
|
30
29
|
const useSubscription = require('./relay-hooks/useSubscription');
|
31
|
-
|
32
|
-
const {loadQuery} = require('./relay-hooks/loadQuery');
|
30
|
+
const RelayRuntime = require('relay-runtime');
|
33
31
|
|
34
32
|
export type * from './relay-hooks/EntryPointTypes.flow';
|
35
33
|
export type {
|
@@ -37,7 +35,7 @@ export type {
|
|
37
35
|
MatchPointer,
|
38
36
|
} from './relay-hooks/MatchContainer';
|
39
37
|
export type {ProfilerContextType} from './relay-hooks/ProfilerContext';
|
40
|
-
export type {
|
38
|
+
export type {LoadMoreFn} from './relay-hooks/useLoadMoreFunction';
|
41
39
|
export type {UseMutationConfig} from './relay-hooks/useMutation';
|
42
40
|
export type {UseQueryLoaderLoadQueryOptions} from './relay-hooks/useQueryLoader';
|
43
41
|
export type {
|
@@ -48,6 +46,7 @@ export type {
|
|
48
46
|
export type {
|
49
47
|
DataID,
|
50
48
|
DeclarativeMutationConfig,
|
49
|
+
Direction,
|
51
50
|
Disposable,
|
52
51
|
// RelayRuntime has two environment exports: one interface, one concrete.
|
53
52
|
IEnvironment as Environment,
|
package/index.js
CHANGED
package/index.js.flow
CHANGED
@@ -12,17 +12,16 @@
|
|
12
12
|
|
13
13
|
'use strict';
|
14
14
|
|
15
|
-
const EntryPointContainer = require('./relay-hooks/EntryPointContainer.react');
|
16
15
|
const ReactRelayContext = require('./ReactRelayContext');
|
17
16
|
const ReactRelayFragmentContainer = require('./ReactRelayFragmentContainer');
|
18
17
|
const ReactRelayLocalQueryRenderer = require('./ReactRelayLocalQueryRenderer');
|
19
18
|
const ReactRelayPaginationContainer = require('./ReactRelayPaginationContainer');
|
20
19
|
const ReactRelayQueryRenderer = require('./ReactRelayQueryRenderer');
|
21
20
|
const ReactRelayRefetchContainer = require('./ReactRelayRefetchContainer');
|
22
|
-
const
|
23
|
-
const RelayRuntime = require('relay-runtime');
|
24
|
-
|
21
|
+
const EntryPointContainer = require('./relay-hooks/EntryPointContainer.react');
|
25
22
|
const loadEntryPoint = require('./relay-hooks/loadEntryPoint');
|
23
|
+
const {loadQuery} = require('./relay-hooks/loadQuery');
|
24
|
+
const RelayEnvironmentProvider = require('./relay-hooks/RelayEnvironmentProvider');
|
26
25
|
const useEntryPointLoader = require('./relay-hooks/useEntryPointLoader');
|
27
26
|
const useFragment = require('./relay-hooks/useFragment');
|
28
27
|
const useLazyLoadQuery = require('./relay-hooks/useLazyLoadQuery');
|
@@ -34,8 +33,7 @@ const useRefetchableFragment = require('./relay-hooks/useRefetchableFragment');
|
|
34
33
|
const useRelayEnvironment = require('./relay-hooks/useRelayEnvironment');
|
35
34
|
const useSubscribeToInvalidationState = require('./relay-hooks/useSubscribeToInvalidationState');
|
36
35
|
const useSubscription = require('./relay-hooks/useSubscription');
|
37
|
-
|
38
|
-
const {loadQuery} = require('./relay-hooks/loadQuery');
|
36
|
+
const RelayRuntime = require('relay-runtime');
|
39
37
|
|
40
38
|
export type {
|
41
39
|
$FragmentRef,
|
@@ -53,7 +51,7 @@ export type {
|
|
53
51
|
MatchPointer,
|
54
52
|
} from './relay-hooks/MatchContainer';
|
55
53
|
export type {ProfilerContextType} from './relay-hooks/ProfilerContext';
|
56
|
-
export type {
|
54
|
+
export type {LoadMoreFn} from './relay-hooks/useLoadMoreFunction';
|
57
55
|
export type {UseMutationConfig} from './relay-hooks/useMutation';
|
58
56
|
export type {UseQueryLoaderLoadQueryOptions} from './relay-hooks/useQueryLoader';
|
59
57
|
export type {
|
@@ -64,6 +62,7 @@ export type {
|
|
64
62
|
export type {
|
65
63
|
DataID,
|
66
64
|
DeclarativeMutationConfig,
|
65
|
+
Direction,
|
67
66
|
Disposable,
|
68
67
|
// RelayRuntime has two environment exports: one interface, one concrete.
|
69
68
|
IEnvironment as Environment,
|
@@ -0,0 +1,56 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
3
|
+
*
|
4
|
+
* This source code is licensed under the MIT license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*
|
7
|
+
* @emails oncall+relay
|
8
|
+
* @format
|
9
|
+
*/
|
10
|
+
|
11
|
+
// This file is sync'd from https://github.com/facebook/react/tree/main/packages/jest-react
|
12
|
+
|
13
|
+
'use strict';
|
14
|
+
|
15
|
+
let didWarnAboutMessageChannel = false;
|
16
|
+
let enqueueTaskImpl = null;
|
17
|
+
|
18
|
+
function enqueueTask(task: () => void) {
|
19
|
+
if (enqueueTaskImpl === null) {
|
20
|
+
try {
|
21
|
+
// read require off the module object to get around the bundlers.
|
22
|
+
// we don't want them to detect a require and bundle a Node polyfill.
|
23
|
+
const requireString = ('require' + Math.random()).slice(0, 7);
|
24
|
+
const nodeRequire = module && module[requireString];
|
25
|
+
// assuming we're in node, let's try to get node's
|
26
|
+
// version of setImmediate, bypassing fake timers if any.
|
27
|
+
enqueueTaskImpl = nodeRequire.call(module, 'timers').setImmediate;
|
28
|
+
} catch {
|
29
|
+
// we're in a browser
|
30
|
+
// we can't use regular timers because they may still be faked
|
31
|
+
// so we try MessageChannel+postMessage instead
|
32
|
+
enqueueTaskImpl = function (callback: () => void) {
|
33
|
+
if (__DEV__) {
|
34
|
+
if (didWarnAboutMessageChannel === false) {
|
35
|
+
didWarnAboutMessageChannel = true;
|
36
|
+
if (typeof MessageChannel === 'undefined') {
|
37
|
+
console.error(
|
38
|
+
'This browser does not have a MessageChannel implementation, ' +
|
39
|
+
'so enqueuing tasks via await act(async () => ...) will fail. ' +
|
40
|
+
'Please file an issue at https://github.com/facebook/react/issues ' +
|
41
|
+
'if you encounter this warning.',
|
42
|
+
);
|
43
|
+
}
|
44
|
+
}
|
45
|
+
}
|
46
|
+
/*global MessageChannel*/
|
47
|
+
const channel = new MessageChannel();
|
48
|
+
channel.port1.onmessage = callback;
|
49
|
+
channel.port2.postMessage(undefined);
|
50
|
+
};
|
51
|
+
}
|
52
|
+
}
|
53
|
+
return enqueueTaskImpl(task);
|
54
|
+
}
|
55
|
+
|
56
|
+
module.exports = enqueueTask;
|
@@ -0,0 +1,12 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
3
|
+
*
|
4
|
+
* This source code is licensed under the MIT license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*
|
7
|
+
* @emails oncall+relay
|
8
|
+
* @format
|
9
|
+
*/
|
10
|
+
|
11
|
+
// This file is sync'd from https://github.com/facebook/react/tree/main/packages/jest-react
|
12
|
+
export {act} from './internalAct';
|
@@ -0,0 +1,139 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
3
|
+
*
|
4
|
+
* This source code is licensed under the MIT license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*
|
7
|
+
* @emails oncall+relay
|
8
|
+
* @format
|
9
|
+
*
|
10
|
+
*/
|
11
|
+
|
12
|
+
/* global jest */
|
13
|
+
|
14
|
+
// This file is sync'd from https://github.com/facebook/react/tree/main/packages/jest-react
|
15
|
+
|
16
|
+
// This version of `act` is only used by our tests. Unlike the public version
|
17
|
+
// of `act`, it's designed to work identically in both production and
|
18
|
+
// development. It may have slightly different behavior from the public
|
19
|
+
// version, too, since our constraints in our test suite are not the same as
|
20
|
+
// those of developers using React — we're testing React itself, as opposed to
|
21
|
+
// building an app with React.
|
22
|
+
|
23
|
+
'use strict';
|
24
|
+
|
25
|
+
const enqueueTask = require('./enqueueTask');
|
26
|
+
const Scheduler = require('scheduler/unstable_mock');
|
27
|
+
|
28
|
+
// The subset of a Promise that React APIs rely on. This resolves a value.
|
29
|
+
// This doesn't require a return value neither from the handler nor the
|
30
|
+
// then function.
|
31
|
+
interface Thenable<+R> {
|
32
|
+
then<U>(
|
33
|
+
onFulfill: (value: R) => void | Thenable<U> | U,
|
34
|
+
onReject: (error: mixed) => void | Thenable<U> | U,
|
35
|
+
): void | Thenable<U>;
|
36
|
+
}
|
37
|
+
|
38
|
+
let actingUpdatesScopeDepth = 0;
|
39
|
+
|
40
|
+
function act(scope: () => Thenable<mixed> | void) {
|
41
|
+
if (Scheduler.unstable_flushAllWithoutAsserting === undefined) {
|
42
|
+
throw Error(
|
43
|
+
'This version of `act` requires a special mock build of Scheduler.',
|
44
|
+
);
|
45
|
+
}
|
46
|
+
if (setTimeout._isMockFunction !== true) {
|
47
|
+
throw Error(
|
48
|
+
"This version of `act` requires Jest's timer mocks " +
|
49
|
+
'(i.e. jest.useFakeTimers).',
|
50
|
+
);
|
51
|
+
}
|
52
|
+
|
53
|
+
const previousActingUpdatesScopeDepth = actingUpdatesScopeDepth;
|
54
|
+
actingUpdatesScopeDepth++;
|
55
|
+
|
56
|
+
const unwind = () => {
|
57
|
+
actingUpdatesScopeDepth--;
|
58
|
+
|
59
|
+
if (__DEV__) {
|
60
|
+
if (actingUpdatesScopeDepth > previousActingUpdatesScopeDepth) {
|
61
|
+
// if it's _less than_ previousActingUpdatesScopeDepth, then we can
|
62
|
+
// assume the 'other' one has warned
|
63
|
+
console.error(
|
64
|
+
'You seem to have overlapping act() calls, this is not supported. ' +
|
65
|
+
'Be sure to await previous act() calls before making a new one. ',
|
66
|
+
);
|
67
|
+
}
|
68
|
+
}
|
69
|
+
};
|
70
|
+
|
71
|
+
// TODO: This would be way simpler if 1) we required a promise to be
|
72
|
+
// returned and 2) we could use async/await. Since it's only our used in
|
73
|
+
// our test suite, we should be able to.
|
74
|
+
try {
|
75
|
+
const thenable = scope();
|
76
|
+
if (
|
77
|
+
typeof thenable === 'object' &&
|
78
|
+
thenable !== null &&
|
79
|
+
typeof thenable.then === 'function'
|
80
|
+
) {
|
81
|
+
return {
|
82
|
+
then(resolve: () => void, reject: (error: mixed) => void) {
|
83
|
+
thenable.then(
|
84
|
+
() => {
|
85
|
+
flushActWork(
|
86
|
+
() => {
|
87
|
+
unwind();
|
88
|
+
resolve();
|
89
|
+
},
|
90
|
+
error => {
|
91
|
+
unwind();
|
92
|
+
reject(error);
|
93
|
+
},
|
94
|
+
);
|
95
|
+
},
|
96
|
+
error => {
|
97
|
+
unwind();
|
98
|
+
reject(error);
|
99
|
+
},
|
100
|
+
);
|
101
|
+
},
|
102
|
+
};
|
103
|
+
} else {
|
104
|
+
try {
|
105
|
+
// TODO: Let's not support non-async scopes at all in our tests. Need to
|
106
|
+
// migrate existing tests.
|
107
|
+
let didFlushWork;
|
108
|
+
do {
|
109
|
+
didFlushWork = Scheduler.unstable_flushAllWithoutAsserting();
|
110
|
+
} while (didFlushWork);
|
111
|
+
} finally {
|
112
|
+
unwind();
|
113
|
+
}
|
114
|
+
}
|
115
|
+
} catch (error) {
|
116
|
+
unwind();
|
117
|
+
throw error;
|
118
|
+
}
|
119
|
+
}
|
120
|
+
|
121
|
+
function flushActWork(resolve, reject) {
|
122
|
+
// Flush suspended fallbacks
|
123
|
+
// $FlowFixMe: Flow doesn't know about global Jest object
|
124
|
+
jest.runOnlyPendingTimers();
|
125
|
+
enqueueTask(() => {
|
126
|
+
try {
|
127
|
+
const didFlushWork = Scheduler.unstable_flushAllWithoutAsserting();
|
128
|
+
if (didFlushWork) {
|
129
|
+
flushActWork(resolve, reject);
|
130
|
+
} else {
|
131
|
+
resolve();
|
132
|
+
}
|
133
|
+
} catch (error) {
|
134
|
+
reject(error);
|
135
|
+
}
|
136
|
+
});
|
137
|
+
}
|
138
|
+
|
139
|
+
exports.act = act;
|
package/legacy.js
CHANGED
@@ -22,20 +22,18 @@ var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inh
|
|
22
22
|
|
23
23
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
24
24
|
|
25
|
-
var React = require('react');
|
26
|
-
|
27
|
-
var areEqual = require("fbjs/lib/areEqual");
|
28
|
-
|
29
25
|
var buildReactRelayContainer = require('./buildReactRelayContainer');
|
30
26
|
|
31
|
-
var getRootVariablesForFragments = require('./getRootVariablesForFragments');
|
32
|
-
|
33
27
|
var _require = require('./ReactRelayContainerUtils'),
|
34
28
|
getContainerName = _require.getContainerName;
|
35
29
|
|
36
30
|
var _require2 = require('./RelayContext'),
|
37
31
|
assertRelayContext = _require2.assertRelayContext;
|
38
32
|
|
33
|
+
var areEqual = require("fbjs/lib/areEqual");
|
34
|
+
|
35
|
+
var React = require('react');
|
36
|
+
|
39
37
|
var _require3 = require('relay-runtime'),
|
40
38
|
createFragmentSpecResolver = _require3.createFragmentSpecResolver,
|
41
39
|
getDataIDsFromObject = _require3.getDataIDsFromObject,
|
@@ -142,19 +140,17 @@ function createContainerWithFragments(Component, fragments) {
|
|
142
140
|
var _proto = _class.prototype;
|
143
141
|
|
144
142
|
_proto.componentDidMount = function componentDidMount() {
|
145
|
-
this.
|
146
|
-
|
147
|
-
this._rerenderIfStoreHasChanged();
|
143
|
+
this._subscribeToNewResolverAndRerenderIfStoreHasChanged();
|
148
144
|
};
|
149
145
|
|
150
146
|
_proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
|
151
147
|
if (this.state.resolver !== prevState.resolver) {
|
152
148
|
prevState.resolver.dispose();
|
153
149
|
|
154
|
-
this.
|
150
|
+
this._subscribeToNewResolverAndRerenderIfStoreHasChanged();
|
151
|
+
} else {
|
152
|
+
this._rerenderIfStoreHasChanged();
|
155
153
|
}
|
156
|
-
|
157
|
-
this._rerenderIfStoreHasChanged();
|
158
154
|
};
|
159
155
|
|
160
156
|
_proto.componentWillUnmount = function componentWillUnmount() {
|
@@ -207,11 +203,21 @@ function createContainerWithFragments(Component, fragments) {
|
|
207
203
|
}
|
208
204
|
};
|
209
205
|
|
210
|
-
_proto.
|
211
|
-
var
|
206
|
+
_proto._subscribeToNewResolverAndRerenderIfStoreHasChanged = function _subscribeToNewResolverAndRerenderIfStoreHasChanged() {
|
207
|
+
var _this$state2 = this.state,
|
208
|
+
data = _this$state2.data,
|
209
|
+
resolver = _this$state2.resolver;
|
210
|
+
var maybeNewData = resolver.resolve(); // Event listeners are only safe to add during the commit phase,
|
212
211
|
// So they won't leak if render is interrupted or errors.
|
213
212
|
|
214
|
-
resolver.setCallback(this._handleFragmentDataUpdate);
|
213
|
+
resolver.setCallback(this.props, this._handleFragmentDataUpdate); // External values could change between render and commit.
|
214
|
+
// Check for this case, even though it requires an extra store read.
|
215
|
+
|
216
|
+
if (data !== maybeNewData) {
|
217
|
+
this.setState({
|
218
|
+
data: maybeNewData
|
219
|
+
});
|
220
|
+
}
|
215
221
|
};
|
216
222
|
|
217
223
|
_proto.render = function render() {
|
@@ -10,10 +10,10 @@
|
|
10
10
|
// flowlint ambiguous-object-type:error
|
11
11
|
'use strict';
|
12
12
|
|
13
|
-
var React = require('react');
|
14
|
-
|
15
13
|
var ReactRelayContext = require('./ReactRelayContext');
|
16
14
|
|
15
|
+
var React = require('react');
|
16
|
+
|
17
17
|
function ReactRelayFragmentMockRenderer(props) {
|
18
18
|
return /*#__PURE__*/React.createElement(ReactRelayContext.Provider, {
|
19
19
|
value: {
|
@@ -10,24 +10,23 @@
|
|
10
10
|
// flowlint ambiguous-object-type:error
|
11
11
|
'use strict';
|
12
12
|
|
13
|
-
var React = require('react');
|
14
|
-
|
15
13
|
var ReactRelayContext = require('./ReactRelayContext');
|
16
14
|
|
17
15
|
var ReactRelayQueryRendererContext = require('./ReactRelayQueryRendererContext');
|
18
16
|
|
19
|
-
var
|
20
|
-
|
21
|
-
|
22
|
-
useMemo = React.useMemo;
|
17
|
+
var areEqual = require("fbjs/lib/areEqual");
|
18
|
+
|
19
|
+
var React = require('react');
|
23
20
|
|
24
21
|
var _require = require('relay-runtime'),
|
25
22
|
createOperationDescriptor = _require.createOperationDescriptor,
|
26
23
|
deepFreeze = _require.deepFreeze,
|
27
24
|
getRequest = _require.getRequest;
|
28
25
|
|
29
|
-
var
|
30
|
-
|
26
|
+
var useLayoutEffect = React.useLayoutEffect,
|
27
|
+
useState = React.useState,
|
28
|
+
useRef = React.useRef,
|
29
|
+
useMemo = React.useMemo;
|
31
30
|
var queryRendererContext = {
|
32
31
|
rootIsQueryRenderer: true
|
33
32
|
};
|