react-relay 14.1.0 → 15.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/ReactRelayContainerUtils.js.flow +1 -0
- package/ReactRelayContext.js +1 -1
- package/ReactRelayContext.js.flow +1 -0
- package/ReactRelayFragmentContainer.js.flow +6 -2
- package/ReactRelayFragmentMockRenderer.js.flow +1 -0
- package/ReactRelayLocalQueryRenderer.js.flow +5 -3
- package/ReactRelayPaginationContainer.js.flow +21 -12
- package/ReactRelayQueryFetcher.js.flow +19 -5
- package/ReactRelayQueryRenderer.js.flow +32 -1
- package/ReactRelayQueryRendererContext.js.flow +1 -0
- package/ReactRelayRefetchContainer.js.flow +9 -5
- package/ReactRelayTestMocker.js.flow +3 -1
- package/ReactRelayTypes.js.flow +1 -0
- package/RelayContext.js.flow +1 -0
- package/__flowtests__/ReactRelayFragmentContainer-flowtest.js.flow +2 -1
- package/__flowtests__/ReactRelayPaginationContainer-flowtest.js.flow +1 -0
- package/__flowtests__/ReactRelayRefetchContainer-flowtest.js.flow +1 -0
- package/__flowtests__/RelayModern-flowtest.js.flow +1 -0
- package/__flowtests__/RelayModernFlowtest_badref.graphql.js.flow +1 -0
- package/__flowtests__/RelayModernFlowtest_notref.graphql.js.flow +1 -0
- package/__flowtests__/RelayModernFlowtest_user.graphql.js.flow +1 -0
- package/__flowtests__/RelayModernFlowtest_users.graphql.js.flow +1 -0
- package/__flowtests__/__generated__/ReactRelayFragmentContainerFlowtest_viewer.graphql.js.flow +3 -1
- package/__flowtests__/__generated__/ReactRelayFragmentContainerFlowtest_viewer2.graphql.js.flow +3 -1
- package/__flowtests__/__generated__/ReactRelayPaginationContainerFlowtestQuery.graphql.js.flow +4 -2
- package/__flowtests__/__generated__/ReactRelayPaginationContainerFlowtest_viewer.graphql.js.flow +3 -1
- package/__flowtests__/__generated__/ReactRelayRefetchContainerFlowtestQuery.graphql.js.flow +4 -2
- package/__flowtests__/__generated__/ReactRelayRefetchContainerFlowtest_viewer.graphql.js.flow +3 -1
- package/__flowtests__/__generated__/RelayModernFlowtest_badref.graphql.js.flow +4 -2
- package/__flowtests__/__generated__/RelayModernFlowtest_notref.graphql.js.flow +4 -2
- package/__flowtests__/__generated__/RelayModernFlowtest_user.graphql.js.flow +3 -1
- package/__flowtests__/__generated__/RelayModernFlowtest_users.graphql.js.flow +3 -1
- package/assertFragmentMap.js.flow +1 -0
- package/buildReactRelayContainer.js.flow +7 -5
- package/getRootVariablesForFragments.js.flow +1 -1
- package/hooks.js +1 -1
- package/hooks.js.flow +4 -0
- package/index.js +1 -1
- package/index.js.flow +4 -0
- package/isRelayEnvironment.js.flow +1 -0
- package/jest-react/enqueueTask.js.flow +1 -1
- package/jest-react/index.js.flow +1 -1
- package/jest-react/internalAct.js.flow +1 -1
- package/legacy.js +1 -1
- package/legacy.js.flow +1 -0
- package/lib/ReactRelayContainerUtils.js +2 -2
- package/lib/ReactRelayContext.js +3 -3
- package/lib/ReactRelayFragmentContainer.js +39 -66
- package/lib/ReactRelayFragmentMockRenderer.js +2 -3
- package/lib/ReactRelayLocalQueryRenderer.js +18 -30
- package/lib/ReactRelayPaginationContainer.js +66 -159
- package/lib/ReactRelayQueryFetcher.js +48 -74
- package/lib/ReactRelayQueryRenderer.js +62 -82
- package/lib/ReactRelayQueryRendererContext.js +2 -1
- package/lib/ReactRelayRefetchContainer.js +52 -99
- package/lib/ReactRelayTestMocker.js +32 -66
- package/lib/ReactRelayTypes.js +2 -0
- package/lib/RelayContext.js +4 -6
- package/lib/assertFragmentMap.js +3 -4
- package/lib/buildReactRelayContainer.js +10 -25
- package/lib/getRootVariablesForFragments.js +5 -8
- package/lib/hooks.js +5 -17
- package/lib/index.js +5 -24
- package/lib/isRelayEnvironment.js +5 -3
- package/lib/jest-react/enqueueTask.js +5 -9
- package/lib/jest-react/index.js +0 -1
- package/lib/jest-react/internalAct.js +9 -20
- package/lib/legacy.js +2 -7
- package/lib/multi-actor/ActorChange.js +2 -5
- package/lib/multi-actor/index.js +2 -1
- package/lib/multi-actor/useRelayActorEnvironment.js +4 -7
- package/lib/relay-hooks/EntryPointContainer.react.js +9 -14
- package/lib/relay-hooks/EntryPointTypes.flow.js +5 -2
- package/lib/relay-hooks/FragmentResource.js +102 -196
- package/lib/relay-hooks/HooksImplementation.js +2 -5
- package/lib/relay-hooks/InternalLogger.js +2 -2
- package/lib/relay-hooks/LRUCache.js +2 -19
- package/lib/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js +33 -53
- package/lib/relay-hooks/MatchContainer.js +14 -22
- package/lib/relay-hooks/ProfilerContext.js +3 -2
- package/lib/relay-hooks/QueryResource.js +30 -99
- package/lib/relay-hooks/RelayEnvironmentProvider.js +5 -8
- package/lib/relay-hooks/SuspenseResource.js +8 -31
- package/lib/relay-hooks/loadEntryPoint.js +19 -31
- package/lib/relay-hooks/loadQuery.js +41 -77
- package/lib/relay-hooks/preloadQuery_DEPRECATED.js +10 -35
- package/lib/relay-hooks/prepareEntryPoint_DEPRECATED.js +9 -14
- package/lib/relay-hooks/react-cache/RelayReactCache.js +7 -11
- package/lib/relay-hooks/react-cache/getQueryResultOrFetchQuery_REACT_CACHE.js +24 -78
- package/lib/relay-hooks/react-cache/readFragmentInternal_REACT_CACHE.js +23 -56
- package/lib/relay-hooks/react-cache/useFragmentInternal_REACT_CACHE.js +65 -143
- package/lib/relay-hooks/react-cache/useFragment_REACT_CACHE.js +5 -14
- package/lib/relay-hooks/react-cache/useLazyLoadQuery_REACT_CACHE.js +17 -23
- package/lib/relay-hooks/react-cache/usePaginationFragment_REACT_CACHE.js +73 -74
- package/lib/relay-hooks/react-cache/usePreloadedQuery_REACT_CACHE.js +24 -38
- package/lib/relay-hooks/react-cache/useRefetchableFragmentInternal_REACT_CACHE.js +60 -102
- package/lib/relay-hooks/react-cache/useRefetchableFragment_REACT_CACHE.js +7 -15
- package/lib/relay-hooks/useBlockingPaginationFragment.js +71 -92
- package/lib/relay-hooks/useClientQuery.js +3 -6
- package/lib/relay-hooks/useEntryPointLoader.js +17 -36
- package/lib/relay-hooks/useFetchTrackingRef.js +10 -11
- package/lib/relay-hooks/useFragment.js +8 -18
- package/lib/relay-hooks/useFragmentNode.js +20 -31
- package/lib/relay-hooks/useIsMountedRef.js +4 -5
- package/lib/relay-hooks/useIsOperationNodeActive.js +8 -20
- package/lib/relay-hooks/useIsParentQueryActive.js +3 -6
- package/lib/relay-hooks/useLazyLoadQuery.js +6 -9
- package/lib/relay-hooks/useLazyLoadQueryNode.js +23 -33
- package/lib/relay-hooks/useLoadMoreFunction.js +45 -76
- package/lib/relay-hooks/useMemoOperationDescriptor.js +6 -14
- package/lib/relay-hooks/useMemoVariables.js +15 -33
- package/lib/relay-hooks/useMutation.js +8 -25
- package/lib/relay-hooks/usePaginationFragment.js +61 -76
- package/lib/relay-hooks/usePreloadedQuery.js +12 -29
- package/lib/relay-hooks/useQueryLoader.js +23 -47
- package/lib/relay-hooks/useRefetchableFragment.js +8 -18
- package/lib/relay-hooks/useRefetchableFragmentNode.js +64 -107
- package/lib/relay-hooks/useRelayEnvironment.js +4 -7
- package/lib/relay-hooks/useStaticFragmentNodeWarning.js +4 -7
- package/lib/relay-hooks/useSubscribeToInvalidationState.js +8 -8
- package/lib/relay-hooks/useSubscription.js +5 -9
- package/lib/relay-hooks/useUnsafeRef_DEPRECATED.js +29 -0
- package/multi-actor/ActorChange.js.flow +1 -1
- package/multi-actor/index.js.flow +1 -1
- package/multi-actor/useRelayActorEnvironment.js.flow +2 -2
- package/package.json +2 -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 +1 -1
- package/relay-hooks/EntryPointTypes.flow.js.flow +7 -5
- package/relay-hooks/FragmentResource.js.flow +34 -8
- package/relay-hooks/HooksImplementation.js.flow +1 -1
- package/relay-hooks/InternalLogger.js.flow +1 -1
- package/relay-hooks/LRUCache.js.flow +1 -1
- package/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js.flow +15 -8
- package/relay-hooks/MatchContainer.js.flow +1 -1
- package/relay-hooks/ProfilerContext.js.flow +1 -1
- package/relay-hooks/QueryResource.js.flow +25 -5
- package/relay-hooks/RelayEnvironmentProvider.js.flow +2 -2
- package/relay-hooks/SuspenseResource.js.flow +1 -1
- package/relay-hooks/__flowtests__/EntryPointTypes/EntryPointElementConfig-flowtest.js.flow +3 -1
- package/relay-hooks/__flowtests__/EntryPointTypes/NestedEntrypoints-flowtest.js.flow +2 -2
- package/relay-hooks/__flowtests__/__generated__/useFragmentFlowtest_user.graphql.js.flow +3 -1
- package/relay-hooks/__flowtests__/__generated__/useFragmentFlowtest_users.graphql.js.flow +3 -1
- package/relay-hooks/__flowtests__/useBlockingPaginationFragment-flowtest.js.flow +35 -33
- package/relay-hooks/__flowtests__/useFragment-flowtest.js.flow +1 -1
- package/relay-hooks/__flowtests__/usePaginationFragment-flowtest.js.flow +33 -32
- package/relay-hooks/__flowtests__/useRefetchableFragment-flowtest.js.flow +18 -18
- package/relay-hooks/__flowtests__/utils.js.flow +13 -2
- package/relay-hooks/loadEntryPoint.js.flow +11 -6
- package/relay-hooks/loadQuery.js.flow +11 -7
- package/relay-hooks/preloadQuery_DEPRECATED.js.flow +5 -6
- package/relay-hooks/prepareEntryPoint_DEPRECATED.js.flow +13 -8
- package/relay-hooks/react-cache/RelayReactCache.js.flow +1 -1
- package/relay-hooks/react-cache/getQueryResultOrFetchQuery_REACT_CACHE.js.flow +4 -4
- package/relay-hooks/react-cache/readFragmentInternal_REACT_CACHE.js.flow +3 -3
- package/relay-hooks/react-cache/useFragmentInternal_REACT_CACHE.js.flow +4 -4
- package/relay-hooks/react-cache/useFragment_REACT_CACHE.js.flow +1 -1
- package/relay-hooks/react-cache/useLazyLoadQuery_REACT_CACHE.js.flow +1 -1
- package/relay-hooks/react-cache/usePaginationFragment_REACT_CACHE.js.flow +41 -22
- package/relay-hooks/react-cache/usePreloadedQuery_REACT_CACHE.js.flow +1 -2
- package/relay-hooks/react-cache/useRefetchableFragmentInternal_REACT_CACHE.js.flow +11 -5
- package/relay-hooks/react-cache/useRefetchableFragment_REACT_CACHE.js.flow +2 -2
- package/relay-hooks/useBlockingPaginationFragment.js.flow +85 -56
- package/relay-hooks/useClientQuery.js.flow +1 -1
- package/relay-hooks/useEntryPointLoader.js.flow +10 -6
- package/relay-hooks/useFetchTrackingRef.js.flow +5 -4
- package/relay-hooks/useFragment.js.flow +2 -2
- package/relay-hooks/useFragmentNode.js.flow +5 -4
- package/relay-hooks/useIsMountedRef.js.flow +1 -1
- package/relay-hooks/useIsOperationNodeActive.js.flow +1 -1
- package/relay-hooks/useIsParentQueryActive.js.flow +1 -1
- package/relay-hooks/useLazyLoadQuery.js.flow +2 -2
- package/relay-hooks/useLazyLoadQueryNode.js.flow +2 -2
- package/relay-hooks/useLoadMoreFunction.js.flow +14 -9
- package/relay-hooks/useMemoOperationDescriptor.js.flow +3 -3
- package/relay-hooks/useMemoVariables.js.flow +13 -29
- package/relay-hooks/useMutation.js.flow +4 -4
- package/relay-hooks/usePaginationFragment.js.flow +53 -46
- package/relay-hooks/usePreloadedQuery.js.flow +47 -22
- package/relay-hooks/useQueryLoader.js.flow +85 -22
- package/relay-hooks/useRefetchableFragment.js.flow +64 -33
- package/relay-hooks/useRefetchableFragmentNode.js.flow +10 -4
- package/relay-hooks/useRelayEnvironment.js.flow +2 -2
- package/relay-hooks/useStaticFragmentNodeWarning.js.flow +3 -3
- package/relay-hooks/useSubscribeToInvalidationState.js.flow +2 -2
- package/relay-hooks/useSubscription.js.flow +1 -1
- package/relay-hooks/useUnsafeRef_DEPRECATED.js.flow +25 -0
- package/lib/readContext.js +0 -27
- package/readContext.js.flow +0 -29
package/lib/ReactRelayTypes.js
CHANGED
package/lib/RelayContext.js
CHANGED
@@ -6,32 +6,30 @@
|
|
6
6
|
*
|
7
7
|
*
|
8
8
|
* @format
|
9
|
+
* @oncall relay
|
9
10
|
*/
|
11
|
+
|
10
12
|
'use strict';
|
11
13
|
|
12
14
|
var isRelayEnvironment = require('./isRelayEnvironment');
|
13
|
-
|
14
15
|
var invariant = require('invariant');
|
16
|
+
|
15
17
|
/**
|
16
18
|
* Asserts that the input is a matches the `RelayContext` type defined in
|
17
19
|
* `RelayEnvironmentTypes` and returns it as that type.
|
18
20
|
*/
|
19
|
-
|
20
|
-
|
21
21
|
function assertRelayContext(relay) {
|
22
22
|
!isRelayContext(relay) ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayContext: Expected `context.relay` to be an object conforming to ' + 'the `RelayContext` interface, got `%s`.', relay) : invariant(false) : void 0;
|
23
23
|
return relay;
|
24
24
|
}
|
25
|
+
|
25
26
|
/**
|
26
27
|
* Determine if the input is a plain object that matches the `RelayContext`
|
27
28
|
* type defined in `RelayEnvironmentTypes`.
|
28
29
|
*/
|
29
|
-
|
30
|
-
|
31
30
|
function isRelayContext(context) {
|
32
31
|
return typeof context === 'object' && context !== null && !Array.isArray(context) && isRelayEnvironment(context.environment);
|
33
32
|
}
|
34
|
-
|
35
33
|
module.exports = {
|
36
34
|
assertRelayContext: assertRelayContext,
|
37
35
|
isRelayContext: isRelayContext
|
package/lib/assertFragmentMap.js
CHANGED
@@ -6,18 +6,18 @@
|
|
6
6
|
*
|
7
7
|
*
|
8
8
|
* @format
|
9
|
+
* @oncall relay
|
9
10
|
*/
|
11
|
+
|
10
12
|
'use strict';
|
11
13
|
|
12
14
|
var invariant = require('invariant');
|
15
|
+
|
13
16
|
/**
|
14
17
|
* Fail fast if the user supplies invalid fragments as input.
|
15
18
|
*/
|
16
|
-
|
17
|
-
|
18
19
|
function assertFragmentMap(componentName, fragmentSpec) {
|
19
20
|
!(fragmentSpec && typeof fragmentSpec === 'object') ? process.env.NODE_ENV !== "production" ? invariant(false, 'Could not create Relay Container for `%s`. ' + 'Expected a set of GraphQL fragments, got `%s` instead.', componentName, fragmentSpec) : invariant(false) : void 0;
|
20
|
-
|
21
21
|
for (var key in fragmentSpec) {
|
22
22
|
if (fragmentSpec.hasOwnProperty(key)) {
|
23
23
|
var fragment = fragmentSpec[key];
|
@@ -25,5 +25,4 @@ function assertFragmentMap(componentName, fragmentSpec) {
|
|
25
25
|
}
|
26
26
|
}
|
27
27
|
}
|
28
|
-
|
29
28
|
module.exports = assertFragmentMap;
|
@@ -6,32 +6,24 @@
|
|
6
6
|
*
|
7
7
|
*
|
8
8
|
* @format
|
9
|
+
* @oncall relay
|
9
10
|
*/
|
11
|
+
|
10
12
|
'use strict';
|
11
13
|
|
12
14
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
13
|
-
|
14
15
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
15
|
-
|
16
16
|
var assertFragmentMap = require('./assertFragmentMap');
|
17
|
-
|
18
17
|
var _require = require('./ReactRelayContainerUtils'),
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
getComponentName = _require.getComponentName,
|
19
|
+
getContainerName = _require.getContainerName;
|
22
20
|
var ReactRelayContext = require('./ReactRelayContext');
|
23
|
-
|
24
21
|
var ReactRelayQueryRendererContext = require('./ReactRelayQueryRendererContext');
|
25
|
-
|
26
|
-
var readContext = require('./readContext');
|
27
|
-
|
28
22
|
var invariant = require('invariant');
|
29
|
-
|
30
23
|
var React = require('react');
|
31
|
-
|
32
24
|
var _require2 = require('relay-runtime'),
|
33
|
-
|
34
|
-
|
25
|
+
getFragment = _require2.getFragment;
|
26
|
+
var useContext = React.useContext;
|
35
27
|
/**
|
36
28
|
* Helper to create the Relay HOCs with ref forwarding, setting the displayName
|
37
29
|
* and reading the React context.
|
@@ -41,38 +33,31 @@ function buildReactRelayContainer(ComponentClass, fragmentSpec, createContainerW
|
|
41
33
|
var containerName = getContainerName(ComponentClass);
|
42
34
|
assertFragmentMap(getComponentName(ComponentClass), fragmentSpec);
|
43
35
|
var fragments = {};
|
44
|
-
|
45
36
|
for (var key in fragmentSpec) {
|
46
37
|
fragments[key] = getFragment(fragmentSpec[key]);
|
47
38
|
}
|
48
|
-
|
49
39
|
var Container = createContainerWithFragments(ComponentClass, fragments);
|
50
40
|
Container.displayName = containerName;
|
51
|
-
|
52
41
|
function forwardRef(props, ref) {
|
53
42
|
var _queryRendererContext;
|
54
|
-
|
55
|
-
var context = readContext(ReactRelayContext);
|
43
|
+
var context = useContext(ReactRelayContext);
|
56
44
|
!(context != null) ? process.env.NODE_ENV !== "production" ? invariant(false, '`%s` tried to render a context that was not valid this means that ' + '`%s` was rendered outside of a query renderer.', containerName, containerName) : invariant(false) : void 0;
|
57
|
-
var queryRendererContext =
|
45
|
+
var queryRendererContext = useContext(ReactRelayQueryRendererContext);
|
58
46
|
return /*#__PURE__*/React.createElement(Container, (0, _extends2["default"])({}, props, {
|
59
47
|
__relayContext: context,
|
60
48
|
__rootIsQueryRenderer: (_queryRendererContext = queryRendererContext === null || queryRendererContext === void 0 ? void 0 : queryRendererContext.rootIsQueryRenderer) !== null && _queryRendererContext !== void 0 ? _queryRendererContext : false,
|
61
49
|
componentRef: props.componentRef || ref
|
62
50
|
}));
|
63
51
|
}
|
64
|
-
|
65
52
|
forwardRef.displayName = containerName;
|
66
53
|
var ForwardContainer = React.forwardRef(forwardRef);
|
67
|
-
|
68
54
|
if (process.env.NODE_ENV !== "production") {
|
69
55
|
// Used by RelayModernTestUtils
|
70
56
|
ForwardContainer.__ComponentClass = ComponentClass;
|
71
57
|
ForwardContainer.displayName = containerName;
|
72
|
-
}
|
73
|
-
|
58
|
+
}
|
74
59
|
|
60
|
+
// $FlowFixMe[incompatible-return]
|
75
61
|
return ForwardContainer;
|
76
62
|
}
|
77
|
-
|
78
63
|
module.exports = buildReactRelayContainer;
|
@@ -6,24 +6,22 @@
|
|
6
6
|
*
|
7
7
|
*
|
8
8
|
* @format
|
9
|
+
* @oncall relay
|
9
10
|
*/
|
11
|
+
|
10
12
|
'use strict';
|
11
13
|
|
12
14
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
13
|
-
|
14
15
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
15
|
-
|
16
16
|
var _require = require('relay-runtime'),
|
17
|
-
|
18
|
-
|
17
|
+
getSelector = _require.getSelector;
|
19
18
|
function getRootVariablesForFragments(fragments, props) {
|
20
|
-
var rootVariables = {};
|
19
|
+
var rootVariables = {};
|
20
|
+
// NOTE: For extra safety, we make sure the rootVariables include the
|
21
21
|
// variables from all owners in this fragmentSpec, even though they
|
22
22
|
// should all point to the same owner
|
23
|
-
|
24
23
|
Object.keys(fragments).forEach(function (key) {
|
25
24
|
var _selector$selectors$, _selector$selectors$2, _selector$owner$varia;
|
26
|
-
|
27
25
|
var fragmentNode = fragments[key];
|
28
26
|
var fragmentRef = props[key];
|
29
27
|
var selector = getSelector(fragmentNode, fragmentRef);
|
@@ -32,5 +30,4 @@ function getRootVariablesForFragments(fragments, props) {
|
|
32
30
|
});
|
33
31
|
return rootVariables;
|
34
32
|
}
|
35
|
-
|
36
33
|
module.exports = getRootVariablesForFragments;
|
package/lib/hooks.js
CHANGED
@@ -6,42 +6,29 @@
|
|
6
6
|
*
|
7
7
|
*
|
8
8
|
* @format
|
9
|
+
* @oncall relay
|
9
10
|
*/
|
11
|
+
|
10
12
|
'use strict';
|
11
13
|
|
12
14
|
var EntryPointContainer = require('./relay-hooks/EntryPointContainer.react');
|
13
|
-
|
14
15
|
var loadEntryPoint = require('./relay-hooks/loadEntryPoint');
|
15
|
-
|
16
16
|
var _require = require('./relay-hooks/loadQuery'),
|
17
|
-
|
18
|
-
|
17
|
+
loadQuery = _require.loadQuery;
|
18
|
+
var ProfilerContext = require('./relay-hooks/ProfilerContext');
|
19
19
|
var RelayEnvironmentProvider = require('./relay-hooks/RelayEnvironmentProvider');
|
20
|
-
|
21
20
|
var useEntryPointLoader = require('./relay-hooks/useEntryPointLoader');
|
22
|
-
|
23
21
|
var useFragment = require('./relay-hooks/useFragment');
|
24
|
-
|
25
22
|
var useLazyLoadQuery = require('./relay-hooks/useLazyLoadQuery');
|
26
|
-
|
27
23
|
var useMutation = require('./relay-hooks/useMutation');
|
28
|
-
|
29
24
|
var usePaginationFragment = require('./relay-hooks/usePaginationFragment');
|
30
|
-
|
31
25
|
var usePreloadedQuery = require('./relay-hooks/usePreloadedQuery');
|
32
|
-
|
33
26
|
var useQueryLoader = require('./relay-hooks/useQueryLoader');
|
34
|
-
|
35
27
|
var useRefetchableFragment = require('./relay-hooks/useRefetchableFragment');
|
36
|
-
|
37
28
|
var useRelayEnvironment = require('./relay-hooks/useRelayEnvironment');
|
38
|
-
|
39
29
|
var useSubscribeToInvalidationState = require('./relay-hooks/useSubscribeToInvalidationState');
|
40
|
-
|
41
30
|
var useSubscription = require('./relay-hooks/useSubscription');
|
42
|
-
|
43
31
|
var RelayRuntime = require('relay-runtime');
|
44
|
-
|
45
32
|
/**
|
46
33
|
* The public interface for Relay Hooks.
|
47
34
|
* This will eventually become the main public interface for react-relay.
|
@@ -56,6 +43,7 @@ module.exports = {
|
|
56
43
|
requestSubscription: RelayRuntime.requestSubscription,
|
57
44
|
EntryPointContainer: EntryPointContainer,
|
58
45
|
RelayEnvironmentProvider: RelayEnvironmentProvider,
|
46
|
+
ProfilerContext: ProfilerContext,
|
59
47
|
fetchQuery: RelayRuntime.fetchQuery,
|
60
48
|
loadQuery: loadQuery,
|
61
49
|
loadEntryPoint: loadEntryPoint,
|
package/lib/index.js
CHANGED
@@ -6,56 +6,36 @@
|
|
6
6
|
*
|
7
7
|
*
|
8
8
|
* @format
|
9
|
+
* @oncall relay
|
9
10
|
*/
|
11
|
+
|
10
12
|
'use strict';
|
11
13
|
|
12
14
|
var ReactRelayContext = require('./ReactRelayContext');
|
13
|
-
|
14
15
|
var ReactRelayFragmentContainer = require('./ReactRelayFragmentContainer');
|
15
|
-
|
16
16
|
var ReactRelayLocalQueryRenderer = require('./ReactRelayLocalQueryRenderer');
|
17
|
-
|
18
17
|
var ReactRelayPaginationContainer = require('./ReactRelayPaginationContainer');
|
19
|
-
|
20
18
|
var ReactRelayQueryRenderer = require('./ReactRelayQueryRenderer');
|
21
|
-
|
22
19
|
var ReactRelayRefetchContainer = require('./ReactRelayRefetchContainer');
|
23
|
-
|
24
20
|
var EntryPointContainer = require('./relay-hooks/EntryPointContainer.react');
|
25
|
-
|
26
21
|
var loadEntryPoint = require('./relay-hooks/loadEntryPoint');
|
27
|
-
|
28
22
|
var _require = require('./relay-hooks/loadQuery'),
|
29
|
-
|
30
|
-
|
23
|
+
loadQuery = _require.loadQuery;
|
24
|
+
var ProfilerContext = require('./relay-hooks/ProfilerContext');
|
31
25
|
var RelayEnvironmentProvider = require('./relay-hooks/RelayEnvironmentProvider');
|
32
|
-
|
33
26
|
var useClientQuery = require('./relay-hooks/useClientQuery');
|
34
|
-
|
35
27
|
var useEntryPointLoader = require('./relay-hooks/useEntryPointLoader');
|
36
|
-
|
37
28
|
var useFragment = require('./relay-hooks/useFragment');
|
38
|
-
|
39
29
|
var useLazyLoadQuery = require('./relay-hooks/useLazyLoadQuery');
|
40
|
-
|
41
30
|
var useMutation = require('./relay-hooks/useMutation');
|
42
|
-
|
43
31
|
var usePaginationFragment = require('./relay-hooks/usePaginationFragment');
|
44
|
-
|
45
32
|
var usePreloadedQuery = require('./relay-hooks/usePreloadedQuery');
|
46
|
-
|
47
33
|
var useQueryLoader = require('./relay-hooks/useQueryLoader');
|
48
|
-
|
49
34
|
var useRefetchableFragment = require('./relay-hooks/useRefetchableFragment');
|
50
|
-
|
51
35
|
var useRelayEnvironment = require('./relay-hooks/useRelayEnvironment');
|
52
|
-
|
53
36
|
var useSubscribeToInvalidationState = require('./relay-hooks/useSubscribeToInvalidationState');
|
54
|
-
|
55
37
|
var useSubscription = require('./relay-hooks/useSubscription');
|
56
|
-
|
57
38
|
var RelayRuntime = require('relay-runtime');
|
58
|
-
|
59
39
|
/**
|
60
40
|
* The public interface to react-relay.
|
61
41
|
* Currently contains both Relay Hooks and legacy Container APIs.
|
@@ -81,6 +61,7 @@ module.exports = {
|
|
81
61
|
// Relay Hooks
|
82
62
|
EntryPointContainer: EntryPointContainer,
|
83
63
|
RelayEnvironmentProvider: RelayEnvironmentProvider,
|
64
|
+
ProfilerContext: ProfilerContext,
|
84
65
|
fetchQuery: RelayRuntime.fetchQuery,
|
85
66
|
loadQuery: loadQuery,
|
86
67
|
loadEntryPoint: loadEntryPoint,
|
@@ -6,16 +6,18 @@
|
|
6
6
|
*
|
7
7
|
*
|
8
8
|
* @format
|
9
|
+
* @oncall relay
|
9
10
|
*/
|
11
|
+
|
10
12
|
'use strict';
|
13
|
+
|
11
14
|
/**
|
12
15
|
* Determine if a given value is an object that implements the `Environment`
|
13
16
|
* interface defined in `RelayEnvironmentTypes`.
|
14
17
|
*/
|
15
|
-
|
16
18
|
function isRelayEnvironment(environment) {
|
17
|
-
return typeof environment === 'object' && environment !== null &&
|
19
|
+
return typeof environment === 'object' && environment !== null &&
|
20
|
+
// TODO: add applyMutation/sendMutation once ready in both cores
|
18
21
|
typeof environment.check === 'function' && typeof environment.lookup === 'function' && typeof environment.retain === 'function' && typeof environment.execute === 'function' && typeof environment.subscribe === 'function';
|
19
22
|
}
|
20
|
-
|
21
23
|
module.exports = isRelayEnvironment;
|
@@ -4,24 +4,25 @@
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
6
6
|
*
|
7
|
-
* @emails oncall+relay
|
8
7
|
* @format
|
8
|
+
* @oncall relay
|
9
9
|
*/
|
10
|
+
|
10
11
|
// This file is sync'd from https://github.com/facebook/react/tree/main/packages/jest-react
|
12
|
+
|
11
13
|
'use strict';
|
12
14
|
|
13
15
|
var didWarnAboutMessageChannel = false;
|
14
16
|
var enqueueTaskImpl = null;
|
15
|
-
|
16
17
|
function enqueueTask(task) {
|
17
18
|
if (enqueueTaskImpl === null) {
|
18
19
|
try {
|
19
20
|
// read require off the module object to get around the bundlers.
|
20
21
|
// we don't want them to detect a require and bundle a Node polyfill.
|
21
22
|
var requireString = ('require' + Math.random()).slice(0, 7);
|
22
|
-
var nodeRequire = module && module[requireString];
|
23
|
+
var nodeRequire = module && module[requireString];
|
24
|
+
// assuming we're in node, let's try to get node's
|
23
25
|
// version of setImmediate, bypassing fake timers if any.
|
24
|
-
|
25
26
|
enqueueTaskImpl = nodeRequire.call(module, 'timers').setImmediate;
|
26
27
|
} catch (_unused) {
|
27
28
|
// we're in a browser
|
@@ -31,23 +32,18 @@ function enqueueTask(task) {
|
|
31
32
|
if (process.env.NODE_ENV !== "production") {
|
32
33
|
if (didWarnAboutMessageChannel === false) {
|
33
34
|
didWarnAboutMessageChannel = true;
|
34
|
-
|
35
35
|
if (typeof MessageChannel === 'undefined') {
|
36
36
|
console.error('This browser does not have a MessageChannel implementation, ' + 'so enqueuing tasks via await act(async () => ...) will fail. ' + 'Please file an issue at https://github.com/facebook/react/issues ' + 'if you encounter this warning.');
|
37
37
|
}
|
38
38
|
}
|
39
39
|
}
|
40
40
|
/*global MessageChannel*/
|
41
|
-
|
42
|
-
|
43
41
|
var channel = new MessageChannel();
|
44
42
|
channel.port1.onmessage = callback;
|
45
43
|
channel.port2.postMessage(undefined);
|
46
44
|
};
|
47
45
|
}
|
48
46
|
}
|
49
|
-
|
50
47
|
return enqueueTaskImpl(task);
|
51
48
|
}
|
52
|
-
|
53
49
|
module.exports = enqueueTask;
|
package/lib/jest-react/index.js
CHANGED
@@ -4,55 +4,51 @@
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
6
6
|
*
|
7
|
-
* @emails oncall+relay
|
8
7
|
* @format
|
8
|
+
* @oncall relay
|
9
9
|
*/
|
10
10
|
|
11
11
|
/* global jest */
|
12
|
+
|
12
13
|
// This file is sync'd from https://github.com/facebook/react/tree/main/packages/jest-react
|
14
|
+
|
13
15
|
// This version of `act` is only used by our tests. Unlike the public version
|
14
16
|
// of `act`, it's designed to work identically in both production and
|
15
17
|
// development. It may have slightly different behavior from the public
|
16
18
|
// version, too, since our constraints in our test suite are not the same as
|
17
19
|
// those of developers using React — we're testing React itself, as opposed to
|
18
20
|
// building an app with React.
|
21
|
+
|
19
22
|
'use strict';
|
20
23
|
|
21
24
|
var enqueueTask = require('./enqueueTask');
|
25
|
+
var Scheduler = require('scheduler/unstable_mock');
|
22
26
|
|
23
|
-
|
27
|
+
// The subset of a Promise that React APIs rely on. This resolves a value.
|
24
28
|
// This doesn't require a return value neither from the handler nor the
|
25
29
|
// then function.
|
26
30
|
|
27
|
-
|
28
31
|
var actingUpdatesScopeDepth = 0;
|
29
|
-
|
30
32
|
function act(scope) {
|
31
33
|
if (Scheduler.unstable_flushAllWithoutAsserting === undefined) {
|
32
34
|
throw Error('This version of `act` requires a special mock build of Scheduler.');
|
33
35
|
}
|
34
|
-
|
35
36
|
if (setTimeout._isMockFunction !== true) {
|
36
37
|
throw Error("This version of `act` requires Jest's timer mocks " + '(i.e. jest.useFakeTimers).');
|
37
38
|
}
|
38
|
-
|
39
39
|
var previousIsActEnvironment = global.IS_REACT_ACT_ENVIRONMENT;
|
40
40
|
var previousActingUpdatesScopeDepth = actingUpdatesScopeDepth;
|
41
41
|
actingUpdatesScopeDepth++;
|
42
|
-
|
43
42
|
if (process.env.NODE_ENV !== "production" && actingUpdatesScopeDepth === 1) {
|
44
43
|
// Because this is not the "real" `act`, we set this to `false` so React
|
45
44
|
// knows not to fire `act` warnings.
|
46
45
|
global.IS_REACT_ACT_ENVIRONMENT = false;
|
47
46
|
}
|
48
|
-
|
49
47
|
var unwind = function unwind() {
|
50
48
|
if (process.env.NODE_ENV !== "production" && actingUpdatesScopeDepth === 1) {
|
51
49
|
global.IS_REACT_ACT_ENVIRONMENT = previousIsActEnvironment;
|
52
50
|
}
|
53
|
-
|
54
51
|
actingUpdatesScopeDepth--;
|
55
|
-
|
56
52
|
if (process.env.NODE_ENV !== "production") {
|
57
53
|
if (actingUpdatesScopeDepth > previousActingUpdatesScopeDepth) {
|
58
54
|
// if it's _less than_ previousActingUpdatesScopeDepth, then we can
|
@@ -60,14 +56,13 @@ function act(scope) {
|
|
60
56
|
console.error('You seem to have overlapping act() calls, this is not supported. ' + 'Be sure to await previous act() calls before making a new one. ');
|
61
57
|
}
|
62
58
|
}
|
63
|
-
};
|
59
|
+
};
|
60
|
+
|
61
|
+
// TODO: This would be way simpler if 1) we required a promise to be
|
64
62
|
// returned and 2) we could use async/await. Since it's only our used in
|
65
63
|
// our test suite, we should be able to.
|
66
|
-
|
67
|
-
|
68
64
|
try {
|
69
65
|
var result = scope();
|
70
|
-
|
71
66
|
if (typeof result === 'object' && result !== null && typeof result.then === 'function') {
|
72
67
|
var thenableResult = result;
|
73
68
|
return {
|
@@ -88,16 +83,13 @@ function act(scope) {
|
|
88
83
|
};
|
89
84
|
} else {
|
90
85
|
var returnValue = result;
|
91
|
-
|
92
86
|
try {
|
93
87
|
// TODO: Let's not support non-async scopes at all in our tests. Need to
|
94
88
|
// migrate existing tests.
|
95
89
|
var didFlushWork;
|
96
|
-
|
97
90
|
do {
|
98
91
|
didFlushWork = Scheduler.unstable_flushAllWithoutAsserting();
|
99
92
|
} while (didFlushWork);
|
100
|
-
|
101
93
|
return {
|
102
94
|
then: function then(resolve, reject) {
|
103
95
|
resolve(returnValue);
|
@@ -112,7 +104,6 @@ function act(scope) {
|
|
112
104
|
throw error;
|
113
105
|
}
|
114
106
|
}
|
115
|
-
|
116
107
|
function flushActWork(resolve, reject) {
|
117
108
|
// Flush suspended fallbacks
|
118
109
|
// $FlowFixMe: Flow doesn't know about global Jest object
|
@@ -120,7 +111,6 @@ function flushActWork(resolve, reject) {
|
|
120
111
|
enqueueTask(function () {
|
121
112
|
try {
|
122
113
|
var didFlushWork = Scheduler.unstable_flushAllWithoutAsserting();
|
123
|
-
|
124
114
|
if (didFlushWork) {
|
125
115
|
flushActWork(resolve, reject);
|
126
116
|
} else {
|
@@ -131,5 +121,4 @@ function flushActWork(resolve, reject) {
|
|
131
121
|
}
|
132
122
|
});
|
133
123
|
}
|
134
|
-
|
135
124
|
exports.act = act;
|
package/lib/legacy.js
CHANGED
@@ -6,23 +6,18 @@
|
|
6
6
|
*
|
7
7
|
*
|
8
8
|
* @format
|
9
|
+
* @oncall relay
|
9
10
|
*/
|
11
|
+
|
10
12
|
'use strict';
|
11
13
|
|
12
14
|
var ReactRelayContext = require('./ReactRelayContext');
|
13
|
-
|
14
15
|
var ReactRelayFragmentContainer = require('./ReactRelayFragmentContainer');
|
15
|
-
|
16
16
|
var ReactRelayLocalQueryRenderer = require('./ReactRelayLocalQueryRenderer');
|
17
|
-
|
18
17
|
var ReactRelayPaginationContainer = require('./ReactRelayPaginationContainer');
|
19
|
-
|
20
18
|
var ReactRelayQueryRenderer = require('./ReactRelayQueryRenderer');
|
21
|
-
|
22
19
|
var ReactRelayRefetchContainer = require('./ReactRelayRefetchContainer');
|
23
|
-
|
24
20
|
var RelayRuntime = require('relay-runtime');
|
25
|
-
|
26
21
|
/**
|
27
22
|
* Legacy react-relay exports.
|
28
23
|
* Should prefer using interface defined in ./hooks.js
|
@@ -5,17 +5,15 @@
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
6
6
|
*
|
7
7
|
*
|
8
|
-
* @emails oncall+relay
|
9
8
|
* @format
|
9
|
+
* @oncall relay
|
10
10
|
*/
|
11
|
+
|
11
12
|
'use strict';
|
12
13
|
|
13
14
|
var RelayEnvironmentProvider = require('../relay-hooks/RelayEnvironmentProvider');
|
14
|
-
|
15
15
|
var useRelayActorEnvironment = require('./useRelayActorEnvironment');
|
16
|
-
|
17
16
|
var React = require('react');
|
18
|
-
|
19
17
|
function ActorChange(props) {
|
20
18
|
var actorEnvironment = useRelayActorEnvironment(props.actorChangePoint.__viewer);
|
21
19
|
var getEnvironmentForActor = React.useCallback(function (actorIdentifier) {
|
@@ -26,5 +24,4 @@ function ActorChange(props) {
|
|
26
24
|
getEnvironmentForActor: getEnvironmentForActor
|
27
25
|
}, props.children(props.actorChangePoint.__fragmentRef, props.actorChangePoint.__viewer));
|
28
26
|
}
|
29
|
-
|
30
27
|
module.exports = ActorChange;
|
package/lib/multi-actor/index.js
CHANGED
@@ -4,19 +4,17 @@
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
6
6
|
*
|
7
|
-
* @emails oncall+relay
|
8
7
|
*
|
9
8
|
* @format
|
9
|
+
* @oncall relay
|
10
10
|
*/
|
11
|
+
|
11
12
|
'use strict';
|
12
13
|
|
14
|
+
var ReactRelayContext = require('./../ReactRelayContext');
|
13
15
|
var invariant = require('invariant');
|
14
|
-
|
15
16
|
var _require = require('react'),
|
16
|
-
|
17
|
-
|
18
|
-
var ReactRelayContext = require('react-relay/ReactRelayContext');
|
19
|
-
|
17
|
+
useContext = _require.useContext;
|
20
18
|
function useRelayActorEnvironment(actorIdentifier) {
|
21
19
|
var context = useContext(ReactRelayContext);
|
22
20
|
!(context != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'useRelayActorEnvironment: Expected to have found a Relay environment provided by ' + 'a `RelayEnvironmentProvider` component. ' + 'This usually means that useRelayActorEnvironment was used in a ' + 'component that is not a descendant of a `RelayEnvironmentProvider`. ' + 'Please make sure a `RelayEnvironmentProvider` has been rendered somewhere ' + 'as a parent or ancestor of your component.') : invariant(false) : void 0;
|
@@ -24,5 +22,4 @@ function useRelayActorEnvironment(actorIdentifier) {
|
|
24
22
|
!(getEnvironmentForActor != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'useRelayActorEnvironment: Expected to have a function `getEnvironmentForActor`.' + 'This usually means that `RelayEnvironmentProvider`. was not properly set up for use in the ' + 'multi actor application. Please make sure the provider has defined a `getEnvironmentForActor`.') : invariant(false) : void 0;
|
25
23
|
return getEnvironmentForActor(actorIdentifier);
|
26
24
|
}
|
27
|
-
|
28
25
|
module.exports = useRelayActorEnvironment;
|
@@ -4,33 +4,29 @@
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
6
6
|
*
|
7
|
-
* @emails oncall+relay
|
8
7
|
*
|
9
8
|
* @format
|
9
|
+
* @oncall relay
|
10
10
|
*/
|
11
|
+
|
11
12
|
'use strict';
|
12
13
|
|
13
14
|
var ProfilerContext = require('./ProfilerContext');
|
14
|
-
|
15
15
|
var useRelayEnvironment = require('./useRelayEnvironment');
|
16
|
-
|
17
16
|
var React = require('react');
|
18
|
-
|
19
17
|
var _require = require('react'),
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
useContext = _require.useContext,
|
19
|
+
useEffect = _require.useEffect;
|
23
20
|
var warning = require("fbjs/lib/warning");
|
24
|
-
|
25
21
|
function EntryPointContainer(_ref) {
|
26
22
|
var entryPointReference = _ref.entryPointReference,
|
27
|
-
|
23
|
+
props = _ref.props;
|
28
24
|
process.env.NODE_ENV !== "production" ? warning(entryPointReference.isDisposed === false, '<EntryPointContainer>: Expected entryPointReference to not be disposed ' + 'yet. This is because disposing the entrypoint marks it for future garbage ' + 'collection, and as such may no longer be present in the Relay store. ' + 'In the future, this will become a hard error.') : void 0;
|
29
25
|
var getComponent = entryPointReference.getComponent,
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
26
|
+
queries = entryPointReference.queries,
|
27
|
+
entryPoints = entryPointReference.entryPoints,
|
28
|
+
extraProps = entryPointReference.extraProps,
|
29
|
+
rootModuleID = entryPointReference.rootModuleID;
|
34
30
|
var Component = getComponent();
|
35
31
|
var profilerContext = useContext(ProfilerContext);
|
36
32
|
var environment = useRelayEnvironment();
|
@@ -48,5 +44,4 @@ function EntryPointContainer(_ref) {
|
|
48
44
|
queries: queries
|
49
45
|
});
|
50
46
|
}
|
51
|
-
|
52
47
|
module.exports = EntryPointContainer;
|
@@ -4,8 +4,11 @@
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
6
6
|
*
|
7
|
-
* @emails oncall+relay
|
8
7
|
*
|
9
8
|
* @format
|
9
|
+
* @oncall relay
|
10
10
|
*/
|
11
|
-
|
11
|
+
|
12
|
+
'use strict';
|
13
|
+
|
14
|
+
/* eslint-disable no-unused-vars */
|