react-relay 11.0.0 → 13.0.0-rc.0
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 +7 -8
- package/ReactRelayPaginationContainer.js.flow +111 -54
- package/ReactRelayQueryFetcher.js.flow +9 -10
- package/ReactRelayQueryRenderer.js.flow +115 -81
- package/ReactRelayRefetchContainer.js.flow +40 -35
- package/ReactRelayTestMocker.js.flow +16 -12
- 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 +12 -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 -3
- 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 +92 -30
- package/lib/ReactRelayQueryFetcher.js +3 -3
- package/lib/ReactRelayQueryRenderer.js +86 -53
- package/lib/ReactRelayRefetchContainer.js +36 -21
- package/lib/ReactRelayTestMocker.js +7 -6
- package/lib/RelayContext.js +3 -2
- package/lib/assertFragmentMap.js +3 -2
- package/lib/buildReactRelayContainer.js +14 -11
- 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 +351 -94
- 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 +6 -8
- 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 +12 -14
- 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 +376 -95
- 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 -27
- 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 -30
- 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 -66
- 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 -108
- package/relay-hooks/getRefetchMetadata.js.flow +0 -80
- package/relay-hooks/getValueAtPath.js.flow +0 -46
@@ -14,23 +14,21 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
14
14
|
|
15
15
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
16
16
|
|
17
|
-
var
|
17
|
+
var assertFragmentMap = require('./assertFragmentMap');
|
18
|
+
|
19
|
+
var _require = require('./ReactRelayContainerUtils'),
|
20
|
+
getComponentName = _require.getComponentName,
|
21
|
+
getContainerName = _require.getContainerName;
|
18
22
|
|
19
23
|
var ReactRelayContext = require('./ReactRelayContext');
|
20
24
|
|
21
25
|
var ReactRelayQueryRendererContext = require('./ReactRelayQueryRendererContext');
|
22
26
|
|
23
|
-
var assertFragmentMap = require('./assertFragmentMap');
|
24
|
-
|
25
|
-
var invariant = require("fbjs/lib/invariant");
|
26
|
-
|
27
|
-
var mapObject = require("fbjs/lib/mapObject");
|
28
|
-
|
29
27
|
var readContext = require('./readContext');
|
30
28
|
|
31
|
-
var
|
32
|
-
|
33
|
-
|
29
|
+
var invariant = require('invariant');
|
30
|
+
|
31
|
+
var React = require('react');
|
34
32
|
|
35
33
|
var _require2 = require('relay-runtime'),
|
36
34
|
getFragment = _require2.getFragment;
|
@@ -43,7 +41,12 @@ function buildReactRelayContainer(ComponentClass, fragmentSpec, createContainerW
|
|
43
41
|
// Sanity-check user-defined fragment input
|
44
42
|
var containerName = getContainerName(ComponentClass);
|
45
43
|
assertFragmentMap(getComponentName(ComponentClass), fragmentSpec);
|
46
|
-
var fragments =
|
44
|
+
var fragments = {};
|
45
|
+
|
46
|
+
for (var key in fragmentSpec) {
|
47
|
+
fragments[key] = getFragment(fragmentSpec[key]);
|
48
|
+
}
|
49
|
+
|
47
50
|
var Container = createContainerWithFragments(ComponentClass, fragments);
|
48
51
|
Container.displayName = containerName;
|
49
52
|
|
package/lib/hooks.js
CHANGED
@@ -12,11 +12,12 @@
|
|
12
12
|
|
13
13
|
var EntryPointContainer = require('./relay-hooks/EntryPointContainer.react');
|
14
14
|
|
15
|
-
var
|
15
|
+
var loadEntryPoint = require('./relay-hooks/loadEntryPoint');
|
16
16
|
|
17
|
-
var
|
17
|
+
var _require = require('./relay-hooks/loadQuery'),
|
18
|
+
loadQuery = _require.loadQuery;
|
18
19
|
|
19
|
-
var
|
20
|
+
var RelayEnvironmentProvider = require('./relay-hooks/RelayEnvironmentProvider');
|
20
21
|
|
21
22
|
var useEntryPointLoader = require('./relay-hooks/useEntryPointLoader');
|
22
23
|
|
@@ -40,8 +41,7 @@ var useSubscribeToInvalidationState = require('./relay-hooks/useSubscribeToInval
|
|
40
41
|
|
41
42
|
var useSubscription = require('./relay-hooks/useSubscription');
|
42
43
|
|
43
|
-
var
|
44
|
-
loadQuery = _require.loadQuery;
|
44
|
+
var RelayRuntime = require('relay-runtime');
|
45
45
|
|
46
46
|
/**
|
47
47
|
* The public interface for Relay Hooks.
|
package/lib/index.js
CHANGED
@@ -10,8 +10,6 @@
|
|
10
10
|
// flowlint ambiguous-object-type:error
|
11
11
|
'use strict';
|
12
12
|
|
13
|
-
var EntryPointContainer = require('./relay-hooks/EntryPointContainer.react');
|
14
|
-
|
15
13
|
var ReactRelayContext = require('./ReactRelayContext');
|
16
14
|
|
17
15
|
var ReactRelayFragmentContainer = require('./ReactRelayFragmentContainer');
|
@@ -24,12 +22,15 @@ var ReactRelayQueryRenderer = require('./ReactRelayQueryRenderer');
|
|
24
22
|
|
25
23
|
var ReactRelayRefetchContainer = require('./ReactRelayRefetchContainer');
|
26
24
|
|
27
|
-
var
|
28
|
-
|
29
|
-
var RelayRuntime = require('relay-runtime');
|
25
|
+
var EntryPointContainer = require('./relay-hooks/EntryPointContainer.react');
|
30
26
|
|
31
27
|
var loadEntryPoint = require('./relay-hooks/loadEntryPoint');
|
32
28
|
|
29
|
+
var _require = require('./relay-hooks/loadQuery'),
|
30
|
+
loadQuery = _require.loadQuery;
|
31
|
+
|
32
|
+
var RelayEnvironmentProvider = require('./relay-hooks/RelayEnvironmentProvider');
|
33
|
+
|
33
34
|
var useEntryPointLoader = require('./relay-hooks/useEntryPointLoader');
|
34
35
|
|
35
36
|
var useFragment = require('./relay-hooks/useFragment');
|
@@ -52,8 +53,7 @@ var useSubscribeToInvalidationState = require('./relay-hooks/useSubscribeToInval
|
|
52
53
|
|
53
54
|
var useSubscription = require('./relay-hooks/useSubscription');
|
54
55
|
|
55
|
-
var
|
56
|
-
loadQuery = _require.loadQuery;
|
56
|
+
var RelayRuntime = require('relay-runtime');
|
57
57
|
|
58
58
|
/**
|
59
59
|
* The public interface to react-relay.
|
@@ -0,0 +1,53 @@
|
|
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
|
+
// This file is sync'd from https://github.com/facebook/react/tree/main/packages/jest-react
|
11
|
+
'use strict';
|
12
|
+
|
13
|
+
var didWarnAboutMessageChannel = false;
|
14
|
+
var enqueueTaskImpl = null;
|
15
|
+
|
16
|
+
function enqueueTask(task) {
|
17
|
+
if (enqueueTaskImpl === null) {
|
18
|
+
try {
|
19
|
+
// read require off the module object to get around the bundlers.
|
20
|
+
// we don't want them to detect a require and bundle a Node polyfill.
|
21
|
+
var requireString = ('require' + Math.random()).slice(0, 7);
|
22
|
+
var nodeRequire = module && module[requireString]; // assuming we're in node, let's try to get node's
|
23
|
+
// version of setImmediate, bypassing fake timers if any.
|
24
|
+
|
25
|
+
enqueueTaskImpl = nodeRequire.call(module, 'timers').setImmediate;
|
26
|
+
} catch (_unused) {
|
27
|
+
// we're in a browser
|
28
|
+
// we can't use regular timers because they may still be faked
|
29
|
+
// so we try MessageChannel+postMessage instead
|
30
|
+
enqueueTaskImpl = function enqueueTaskImpl(callback) {
|
31
|
+
if (process.env.NODE_ENV !== "production") {
|
32
|
+
if (didWarnAboutMessageChannel === false) {
|
33
|
+
didWarnAboutMessageChannel = true;
|
34
|
+
|
35
|
+
if (typeof MessageChannel === 'undefined') {
|
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
|
+
}
|
38
|
+
}
|
39
|
+
}
|
40
|
+
/*global MessageChannel*/
|
41
|
+
|
42
|
+
|
43
|
+
var channel = new MessageChannel();
|
44
|
+
channel.port1.onmessage = callback;
|
45
|
+
channel.port2.postMessage(undefined);
|
46
|
+
};
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
return enqueueTaskImpl(task);
|
51
|
+
}
|
52
|
+
|
53
|
+
module.exports = enqueueTask;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
Object.defineProperty(exports, "act", {
|
7
|
+
enumerable: true,
|
8
|
+
get: function get() {
|
9
|
+
return _internalAct.act;
|
10
|
+
}
|
11
|
+
});
|
12
|
+
|
13
|
+
var _internalAct = require("./internalAct");
|
@@ -0,0 +1,116 @@
|
|
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
|
+
// This file is sync'd from https://github.com/facebook/react/tree/main/packages/jest-react
|
14
|
+
// This version of `act` is only used by our tests. Unlike the public version
|
15
|
+
// of `act`, it's designed to work identically in both production and
|
16
|
+
// development. It may have slightly different behavior from the public
|
17
|
+
// version, too, since our constraints in our test suite are not the same as
|
18
|
+
// those of developers using React — we're testing React itself, as opposed to
|
19
|
+
// building an app with React.
|
20
|
+
'use strict';
|
21
|
+
|
22
|
+
var enqueueTask = require('./enqueueTask');
|
23
|
+
|
24
|
+
var Scheduler = require('scheduler/unstable_mock'); // The subset of a Promise that React APIs rely on. This resolves a value.
|
25
|
+
// This doesn't require a return value neither from the handler nor the
|
26
|
+
// then function.
|
27
|
+
|
28
|
+
|
29
|
+
var actingUpdatesScopeDepth = 0;
|
30
|
+
|
31
|
+
function act(scope) {
|
32
|
+
if (Scheduler.unstable_flushAllWithoutAsserting === undefined) {
|
33
|
+
throw Error('This version of `act` requires a special mock build of Scheduler.');
|
34
|
+
}
|
35
|
+
|
36
|
+
if (setTimeout._isMockFunction !== true) {
|
37
|
+
throw Error("This version of `act` requires Jest's timer mocks " + '(i.e. jest.useFakeTimers).');
|
38
|
+
}
|
39
|
+
|
40
|
+
var previousActingUpdatesScopeDepth = actingUpdatesScopeDepth;
|
41
|
+
actingUpdatesScopeDepth++;
|
42
|
+
|
43
|
+
var unwind = function unwind() {
|
44
|
+
actingUpdatesScopeDepth--;
|
45
|
+
|
46
|
+
if (process.env.NODE_ENV !== "production") {
|
47
|
+
if (actingUpdatesScopeDepth > previousActingUpdatesScopeDepth) {
|
48
|
+
// if it's _less than_ previousActingUpdatesScopeDepth, then we can
|
49
|
+
// assume the 'other' one has warned
|
50
|
+
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. ');
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}; // TODO: This would be way simpler if 1) we required a promise to be
|
54
|
+
// returned and 2) we could use async/await. Since it's only our used in
|
55
|
+
// our test suite, we should be able to.
|
56
|
+
|
57
|
+
|
58
|
+
try {
|
59
|
+
var thenable = scope();
|
60
|
+
|
61
|
+
if (typeof thenable === 'object' && thenable !== null && typeof thenable.then === 'function') {
|
62
|
+
return {
|
63
|
+
then: function then(resolve, reject) {
|
64
|
+
thenable.then(function () {
|
65
|
+
flushActWork(function () {
|
66
|
+
unwind();
|
67
|
+
resolve();
|
68
|
+
}, function (error) {
|
69
|
+
unwind();
|
70
|
+
reject(error);
|
71
|
+
});
|
72
|
+
}, function (error) {
|
73
|
+
unwind();
|
74
|
+
reject(error);
|
75
|
+
});
|
76
|
+
}
|
77
|
+
};
|
78
|
+
} else {
|
79
|
+
try {
|
80
|
+
// TODO: Let's not support non-async scopes at all in our tests. Need to
|
81
|
+
// migrate existing tests.
|
82
|
+
var didFlushWork;
|
83
|
+
|
84
|
+
do {
|
85
|
+
didFlushWork = Scheduler.unstable_flushAllWithoutAsserting();
|
86
|
+
} while (didFlushWork);
|
87
|
+
} finally {
|
88
|
+
unwind();
|
89
|
+
}
|
90
|
+
}
|
91
|
+
} catch (error) {
|
92
|
+
unwind();
|
93
|
+
throw error;
|
94
|
+
}
|
95
|
+
}
|
96
|
+
|
97
|
+
function flushActWork(resolve, reject) {
|
98
|
+
// Flush suspended fallbacks
|
99
|
+
// $FlowFixMe: Flow doesn't know about global Jest object
|
100
|
+
jest.runOnlyPendingTimers();
|
101
|
+
enqueueTask(function () {
|
102
|
+
try {
|
103
|
+
var didFlushWork = Scheduler.unstable_flushAllWithoutAsserting();
|
104
|
+
|
105
|
+
if (didFlushWork) {
|
106
|
+
flushActWork(resolve, reject);
|
107
|
+
} else {
|
108
|
+
resolve();
|
109
|
+
}
|
110
|
+
} catch (error) {
|
111
|
+
reject(error);
|
112
|
+
}
|
113
|
+
});
|
114
|
+
}
|
115
|
+
|
116
|
+
exports.act = act;
|
@@ -0,0 +1,30 @@
|
|
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
|
+
*
|
8
|
+
* @emails oncall+relay
|
9
|
+
* @format
|
10
|
+
*/
|
11
|
+
'use strict';
|
12
|
+
|
13
|
+
var RelayEnvironmentProvider = require('../relay-hooks/RelayEnvironmentProvider');
|
14
|
+
|
15
|
+
var useRelayActorEnvironment = require('./useRelayActorEnvironment');
|
16
|
+
|
17
|
+
var React = require('react');
|
18
|
+
|
19
|
+
function ActorChange(props) {
|
20
|
+
var actorEnvironment = useRelayActorEnvironment(props.actorChangePoint.__viewer);
|
21
|
+
var getEnvironmentForActor = React.useCallback(function (actorIdentifier) {
|
22
|
+
return actorEnvironment.multiActorEnvironment.forActor(actorIdentifier);
|
23
|
+
}, [actorEnvironment]);
|
24
|
+
return /*#__PURE__*/React.createElement(RelayEnvironmentProvider, {
|
25
|
+
environment: actorEnvironment,
|
26
|
+
getEnvironmentForActor: getEnvironmentForActor
|
27
|
+
}, props.children(props.actorChangePoint.__fragmentRef, props.actorChangePoint.__viewer));
|
28
|
+
}
|
29
|
+
|
30
|
+
module.exports = ActorChange;
|
@@ -0,0 +1,29 @@
|
|
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
|
+
*
|
9
|
+
* @format
|
10
|
+
*/
|
11
|
+
// flowlint ambiguous-object-type:error
|
12
|
+
'use strict';
|
13
|
+
|
14
|
+
var invariant = require('invariant');
|
15
|
+
|
16
|
+
var _require = require('react'),
|
17
|
+
useContext = _require.useContext;
|
18
|
+
|
19
|
+
var ReactRelayContext = require('react-relay/ReactRelayContext');
|
20
|
+
|
21
|
+
function useRelayActorEnvironment(actorIdentifier) {
|
22
|
+
var context = useContext(ReactRelayContext);
|
23
|
+
!(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
|
+
var getEnvironmentForActor = context.getEnvironmentForActor;
|
25
|
+
!(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;
|
26
|
+
return getEnvironmentForActor(actorIdentifier);
|
27
|
+
}
|
28
|
+
|
29
|
+
module.exports = useRelayActorEnvironment;
|
@@ -13,16 +13,16 @@
|
|
13
13
|
|
14
14
|
var ProfilerContext = require('./ProfilerContext');
|
15
15
|
|
16
|
-
var React = require('react');
|
17
|
-
|
18
16
|
var useRelayEnvironment = require('./useRelayEnvironment');
|
19
17
|
|
20
|
-
var
|
18
|
+
var React = require('react');
|
21
19
|
|
22
20
|
var _require = require('react'),
|
23
21
|
useContext = _require.useContext,
|
24
22
|
useEffect = _require.useEffect;
|
25
23
|
|
24
|
+
var warning = require("fbjs/lib/warning");
|
25
|
+
|
26
26
|
function EntryPointContainer(_ref) {
|
27
27
|
var entryPointReference = _ref.entryPointReference,
|
28
28
|
props = _ref.props;
|