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
@@ -5,45 +5,36 @@
|
|
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 _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
14
|
-
|
15
15
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
16
|
-
|
17
16
|
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
|
18
|
-
|
19
17
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
20
|
-
|
21
18
|
var _require = require('../QueryResource'),
|
22
|
-
|
23
|
-
|
19
|
+
getQueryResourceForEnvironment = _require.getQueryResourceForEnvironment;
|
24
20
|
var useRelayEnvironment = require('../useRelayEnvironment');
|
25
|
-
|
26
21
|
var invariant = require('invariant');
|
27
|
-
|
28
22
|
var _require2 = require('react'),
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
23
|
+
useDebugValue = _require2.useDebugValue,
|
24
|
+
useEffect = _require2.useEffect,
|
25
|
+
useMemo = _require2.useMemo,
|
26
|
+
useRef = _require2.useRef,
|
27
|
+
useState = _require2.useState;
|
35
28
|
var _require3 = require('relay-runtime'),
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
29
|
+
fetchQueryInternal = _require3.__internal.fetchQuery,
|
30
|
+
areEqualSelectors = _require3.areEqualSelectors,
|
31
|
+
createOperationDescriptor = _require3.createOperationDescriptor,
|
32
|
+
getPendingOperationsForFragment = _require3.getPendingOperationsForFragment,
|
33
|
+
getSelector = _require3.getSelector,
|
34
|
+
getVariablesFromFragment = _require3.getVariablesFromFragment,
|
35
|
+
handlePotentialSnapshotErrors = _require3.handlePotentialSnapshotErrors,
|
36
|
+
recycleNodesInto = _require3.recycleNodesInto;
|
45
37
|
var warning = require("fbjs/lib/warning");
|
46
|
-
|
47
38
|
function isMissingData(state) {
|
48
39
|
if (state.kind === 'bailout') {
|
49
40
|
return false;
|
@@ -55,32 +46,24 @@ function isMissingData(state) {
|
|
55
46
|
});
|
56
47
|
}
|
57
48
|
}
|
58
|
-
|
59
49
|
function getMissingClientEdges(state) {
|
60
50
|
if (state.kind === 'bailout') {
|
61
51
|
return null;
|
62
52
|
} else if (state.kind === 'singular') {
|
63
53
|
var _state$snapshot$missi;
|
64
|
-
|
65
54
|
return (_state$snapshot$missi = state.snapshot.missingClientEdges) !== null && _state$snapshot$missi !== void 0 ? _state$snapshot$missi : null;
|
66
55
|
} else {
|
67
56
|
var edges = null;
|
68
|
-
|
69
57
|
var _iterator = (0, _createForOfIteratorHelper2["default"])(state.snapshots),
|
70
|
-
|
71
|
-
|
58
|
+
_step;
|
72
59
|
try {
|
73
60
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
74
61
|
var snapshot = _step.value;
|
75
|
-
|
76
62
|
if (snapshot.missingClientEdges) {
|
77
63
|
var _edges;
|
78
|
-
|
79
64
|
edges = (_edges = edges) !== null && _edges !== void 0 ? _edges : [];
|
80
|
-
|
81
65
|
var _iterator2 = (0, _createForOfIteratorHelper2["default"])(snapshot.missingClientEdges),
|
82
|
-
|
83
|
-
|
66
|
+
_step2;
|
84
67
|
try {
|
85
68
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
86
69
|
var edge = _step2.value;
|
@@ -98,36 +81,27 @@ function getMissingClientEdges(state) {
|
|
98
81
|
} finally {
|
99
82
|
_iterator.f();
|
100
83
|
}
|
101
|
-
|
102
84
|
return edges;
|
103
85
|
}
|
104
86
|
}
|
105
|
-
|
106
87
|
function getSuspendingLiveResolver(state) {
|
107
88
|
if (state.kind === 'bailout') {
|
108
89
|
return null;
|
109
90
|
} else if (state.kind === 'singular') {
|
110
91
|
var _state$snapshot$missi2;
|
111
|
-
|
112
92
|
return (_state$snapshot$missi2 = state.snapshot.missingLiveResolverFields) !== null && _state$snapshot$missi2 !== void 0 ? _state$snapshot$missi2 : null;
|
113
93
|
} else {
|
114
94
|
var missingFields = null;
|
115
|
-
|
116
95
|
var _iterator3 = (0, _createForOfIteratorHelper2["default"])(state.snapshots),
|
117
|
-
|
118
|
-
|
96
|
+
_step3;
|
119
97
|
try {
|
120
98
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
121
99
|
var snapshot = _step3.value;
|
122
|
-
|
123
100
|
if (snapshot.missingLiveResolverFields) {
|
124
101
|
var _missingFields;
|
125
|
-
|
126
102
|
missingFields = (_missingFields = missingFields) !== null && _missingFields !== void 0 ? _missingFields : [];
|
127
|
-
|
128
103
|
var _iterator4 = (0, _createForOfIteratorHelper2["default"])(snapshot.missingLiveResolverFields),
|
129
|
-
|
130
|
-
|
104
|
+
_step4;
|
131
105
|
try {
|
132
106
|
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
133
107
|
var edge = _step4.value;
|
@@ -145,18 +119,15 @@ function getSuspendingLiveResolver(state) {
|
|
145
119
|
} finally {
|
146
120
|
_iterator3.f();
|
147
121
|
}
|
148
|
-
|
149
122
|
return missingFields;
|
150
123
|
}
|
151
124
|
}
|
152
|
-
|
153
125
|
function handlePotentialSnapshotErrorsForState(environment, state) {
|
154
126
|
if (state.kind === 'singular') {
|
155
127
|
handlePotentialSnapshotErrors(environment, state.snapshot.missingRequiredFields, state.snapshot.relayResolverErrors);
|
156
128
|
} else if (state.kind === 'plural') {
|
157
129
|
var _iterator5 = (0, _createForOfIteratorHelper2["default"])(state.snapshots),
|
158
|
-
|
159
|
-
|
130
|
+
_step5;
|
160
131
|
try {
|
161
132
|
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
162
133
|
var snapshot = _step5.value;
|
@@ -169,26 +140,22 @@ function handlePotentialSnapshotErrorsForState(environment, state) {
|
|
169
140
|
}
|
170
141
|
}
|
171
142
|
}
|
143
|
+
|
172
144
|
/**
|
173
145
|
* Check for updates to the store that occurred concurrently with rendering the given `state` value,
|
174
146
|
* returning a new (updated) state if there were updates or null if there were no changes.
|
175
147
|
*/
|
176
|
-
|
177
|
-
|
178
148
|
function handleMissedUpdates(environment, state) {
|
179
149
|
if (state.kind === 'bailout') {
|
180
150
|
return null;
|
181
|
-
}
|
182
|
-
|
183
|
-
|
151
|
+
}
|
152
|
+
// FIXME this is invalid if we've just switched environments.
|
184
153
|
var currentEpoch = environment.getStore().getEpoch();
|
185
|
-
|
186
154
|
if (currentEpoch === state.epoch) {
|
187
155
|
return null;
|
188
|
-
}
|
156
|
+
}
|
157
|
+
// The store has updated since we rendered (without us being subscribed yet),
|
189
158
|
// so check for any updates to the data we're rendering:
|
190
|
-
|
191
|
-
|
192
159
|
if (state.kind === 'singular') {
|
193
160
|
var currentSnapshot = environment.lookup(state.snapshot.selector);
|
194
161
|
var updatedData = recycleNodesInto(state.snapshot.data, currentSnapshot.data);
|
@@ -210,14 +177,10 @@ function handleMissedUpdates(environment, state) {
|
|
210
177
|
} else {
|
211
178
|
var didMissUpdates = false;
|
212
179
|
var currentSnapshots = [];
|
213
|
-
|
214
180
|
for (var index = 0; index < state.snapshots.length; index++) {
|
215
181
|
var snapshot = state.snapshots[index];
|
216
|
-
|
217
182
|
var _currentSnapshot = environment.lookup(snapshot.selector);
|
218
|
-
|
219
183
|
var _updatedData = recycleNodesInto(snapshot.data, _currentSnapshot.data);
|
220
|
-
|
221
184
|
var _updatedCurrentSnapshot = {
|
222
185
|
data: _updatedData,
|
223
186
|
isMissingData: _currentSnapshot.isMissingData,
|
@@ -228,14 +191,11 @@ function handleMissedUpdates(environment, state) {
|
|
228
191
|
missingRequiredFields: _currentSnapshot.missingRequiredFields,
|
229
192
|
relayResolverErrors: _currentSnapshot.relayResolverErrors
|
230
193
|
};
|
231
|
-
|
232
194
|
if (_updatedData !== snapshot.data) {
|
233
195
|
didMissUpdates = true;
|
234
196
|
}
|
235
|
-
|
236
197
|
currentSnapshots.push(_updatedCurrentSnapshot);
|
237
198
|
}
|
238
|
-
|
239
199
|
!(currentSnapshots.length === state.snapshots.length) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Expected same number of snapshots') : invariant(false) : void 0;
|
240
200
|
return [didMissUpdates, {
|
241
201
|
kind: 'plural',
|
@@ -244,22 +204,20 @@ function handleMissedUpdates(environment, state) {
|
|
244
204
|
}];
|
245
205
|
}
|
246
206
|
}
|
247
|
-
|
248
207
|
function handleMissingClientEdge(environment, parentFragmentNode, parentFragmentRef, missingClientEdgeRequestInfo, queryOptions) {
|
249
208
|
var originalVariables = getVariablesFromFragment(parentFragmentNode, parentFragmentRef);
|
250
209
|
var variables = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, originalVariables), {}, {
|
251
210
|
id: missingClientEdgeRequestInfo.clientEdgeDestinationID // TODO should be a reserved name
|
252
|
-
|
253
211
|
});
|
254
|
-
|
212
|
+
|
213
|
+
var queryOperationDescriptor = createOperationDescriptor(missingClientEdgeRequestInfo.request, variables, queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.networkCacheConfig);
|
214
|
+
// This may suspend. We don't need to do anything with the results; all we're
|
255
215
|
// doing here is started the query if needed and retaining and releasing it
|
256
216
|
// according to the component mount/suspense cycle; QueryResource
|
257
217
|
// already handles this by itself.
|
258
|
-
|
259
218
|
var QueryResource = getQueryResourceForEnvironment(environment);
|
260
219
|
return QueryResource.prepare(queryOperationDescriptor, fetchQueryInternal(environment, queryOperationDescriptor), queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.fetchPolicy);
|
261
220
|
}
|
262
|
-
|
263
221
|
function subscribeToSnapshot(environment, state, setState) {
|
264
222
|
if (state.kind === 'bailout') {
|
265
223
|
return function () {};
|
@@ -272,7 +230,6 @@ function subscribeToSnapshot(environment, state, setState) {
|
|
272
230
|
if (prevState.kind !== 'singular' || prevState.snapshot.selector !== latestSnapshot.selector) {
|
273
231
|
return prevState;
|
274
232
|
}
|
275
|
-
|
276
233
|
return {
|
277
234
|
kind: 'singular',
|
278
235
|
snapshot: latestSnapshot,
|
@@ -288,14 +245,12 @@ function subscribeToSnapshot(environment, state, setState) {
|
|
288
245
|
return environment.subscribe(snapshot, function (latestSnapshot) {
|
289
246
|
setState(function (prevState) {
|
290
247
|
var _prevState$snapshots$;
|
291
|
-
|
292
248
|
// In theory a setState from a subscription could be batched together
|
293
249
|
// with a setState to change the fragment selector. Guard against this
|
294
250
|
// by bailing out of the state update if the selector has changed.
|
295
251
|
if (prevState.kind !== 'plural' || ((_prevState$snapshots$ = prevState.snapshots[index]) === null || _prevState$snapshots$ === void 0 ? void 0 : _prevState$snapshots$.selector) !== latestSnapshot.selector) {
|
296
252
|
return prevState;
|
297
253
|
}
|
298
|
-
|
299
254
|
var updated = (0, _toConsumableArray2["default"])(prevState.snapshots);
|
300
255
|
updated[index] = latestSnapshot;
|
301
256
|
return {
|
@@ -308,8 +263,7 @@ function subscribeToSnapshot(environment, state, setState) {
|
|
308
263
|
});
|
309
264
|
return function () {
|
310
265
|
var _iterator6 = (0, _createForOfIteratorHelper2["default"])(disposables),
|
311
|
-
|
312
|
-
|
266
|
+
_step6;
|
313
267
|
try {
|
314
268
|
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
315
269
|
var d = _step6.value;
|
@@ -323,7 +277,6 @@ function subscribeToSnapshot(environment, state, setState) {
|
|
323
277
|
};
|
324
278
|
}
|
325
279
|
}
|
326
|
-
|
327
280
|
function getFragmentState(environment, fragmentSelector) {
|
328
281
|
if (fragmentSelector == null) {
|
329
282
|
return {
|
@@ -346,51 +299,43 @@ function getFragmentState(environment, fragmentSelector) {
|
|
346
299
|
epoch: environment.getStore().getEpoch()
|
347
300
|
};
|
348
301
|
}
|
349
|
-
}
|
350
|
-
|
302
|
+
}
|
351
303
|
|
304
|
+
// fragmentNode cannot change during the lifetime of the component, though fragmentRef may change.
|
352
305
|
function useFragmentInternal_REACT_CACHE(fragmentNode, fragmentRef, hookDisplayName, queryOptions, fragmentKey) {
|
353
306
|
var _fragmentNode$metadat, _fragmentNode$metadat2;
|
354
|
-
|
355
307
|
var fragmentSelector = useMemo(function () {
|
356
308
|
return getSelector(fragmentNode, fragmentRef);
|
357
309
|
}, [fragmentNode, fragmentRef]);
|
358
310
|
var isPlural = (fragmentNode === null || fragmentNode === void 0 ? void 0 : (_fragmentNode$metadat = fragmentNode.metadata) === null || _fragmentNode$metadat === void 0 ? void 0 : _fragmentNode$metadat.plural) === true;
|
359
|
-
|
360
311
|
if (isPlural) {
|
361
312
|
!(fragmentRef == null || Array.isArray(fragmentRef)) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Relay: Expected fragment pointer%s for fragment `%s` to be ' + 'an array, instead got `%s`. Remove `@relay(plural: true)` ' + 'from fragment `%s` to allow the prop to be an object.', fragmentKey != null ? " for key `".concat(fragmentKey, "`") : '', fragmentNode.name, typeof fragmentRef, fragmentNode.name) : invariant(false) : void 0;
|
362
313
|
} else {
|
363
314
|
!!Array.isArray(fragmentRef) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Relay: Expected fragment pointer%s for fragment `%s` not to be ' + 'an array, instead got `%s`. Add `@relay(plural: true)` ' + 'to fragment `%s` to allow the prop to be an array.', fragmentKey != null ? " for key `".concat(fragmentKey, "`") : '', fragmentNode.name, typeof fragmentRef, fragmentNode.name) : invariant(false) : void 0;
|
364
315
|
}
|
365
|
-
|
366
316
|
!(fragmentRef == null || isPlural && Array.isArray(fragmentRef) && fragmentRef.length === 0 || fragmentSelector != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Relay: Expected to receive an object where `...%s` was spread, ' + 'but the fragment reference was not found`. This is most ' + 'likely the result of:\n' + "- Forgetting to spread `%s` in `%s`'s parent's fragment.\n" + '- Conditionally fetching `%s` but unconditionally passing %s prop ' + 'to `%s`. If the parent fragment only fetches the fragment conditionally ' + '- with e.g. `@include`, `@skip`, or inside a `... on SomeType { }` ' + 'spread - then the fragment reference will not exist. ' + 'In this case, pass `null` if the conditions for evaluating the ' + 'fragment are not met (e.g. if the `@include(if)` value is false.)', fragmentNode.name, fragmentNode.name, hookDisplayName, fragmentNode.name, fragmentKey == null ? 'a fragment reference' : "the `".concat(fragmentKey, "`"), hookDisplayName) : invariant(false) : void 0;
|
367
317
|
var environment = useRelayEnvironment();
|
368
|
-
|
369
318
|
var _useState = useState(function () {
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
319
|
+
return getFragmentState(environment, fragmentSelector);
|
320
|
+
}),
|
321
|
+
_state = _useState[0],
|
322
|
+
setState = _useState[1];
|
323
|
+
var state = _state;
|
374
324
|
|
375
|
-
|
325
|
+
// This copy of the state we only update when something requires us to
|
376
326
|
// unsubscribe and re-subscribe, namely a changed environment or
|
377
327
|
// fragment selector.
|
378
|
-
|
379
328
|
var _useState2 = useState(state),
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
329
|
+
_subscribedState = _useState2[0],
|
330
|
+
setSubscribedState = _useState2[1];
|
331
|
+
// FIXME since this is used as an effect dependency, it needs to be memoized.
|
384
332
|
var subscribedState = _subscribedState;
|
385
|
-
|
386
333
|
var _useState3 = useState(fragmentSelector),
|
387
|
-
|
388
|
-
|
389
|
-
|
334
|
+
previousFragmentSelector = _useState3[0],
|
335
|
+
setPreviousFragmentSelector = _useState3[1];
|
390
336
|
var _useState4 = useState(environment),
|
391
|
-
|
392
|
-
|
393
|
-
|
337
|
+
previousEnvironment = _useState4[0],
|
338
|
+
setPreviousEnvironment = _useState4[1];
|
394
339
|
if (!areEqualSelectors(fragmentSelector, previousFragmentSelector) || environment !== previousEnvironment) {
|
395
340
|
// Enqueue setState to record the new selector and state
|
396
341
|
setPreviousFragmentSelector(fragmentSelector);
|
@@ -401,39 +346,36 @@ function useFragmentInternal_REACT_CACHE(fragmentNode, fragmentRef, hookDisplayN
|
|
401
346
|
// But render with the latest state w/o waiting for the setState. Otherwise
|
402
347
|
// the component would render the wrong information temporarily (including
|
403
348
|
// possibly incorrectly triggering some warnings below).
|
404
|
-
|
405
349
|
state = newState;
|
406
350
|
subscribedState = newState;
|
407
|
-
}
|
351
|
+
}
|
352
|
+
|
353
|
+
// The purpose of this is to detect whether we have ever committed, because we
|
408
354
|
// don't suspend on store updates, only when the component either is first trying
|
409
355
|
// to mount or when the our selector changes. The selector change in particular is
|
410
356
|
// how we suspend for pagination and refetech. Also, fragment selector can be null
|
411
357
|
// or undefined, so we use false as a special value to distinguish from all fragment
|
412
358
|
// selectors; false means that the component hasn't mounted yet.
|
413
|
-
|
414
|
-
|
415
359
|
var committedFragmentSelectorRef = useRef(false);
|
416
360
|
useEffect(function () {
|
417
361
|
committedFragmentSelectorRef.current = fragmentSelector;
|
418
|
-
}, [fragmentSelector]);
|
419
|
-
// FIXME handle client edges in parallel.
|
362
|
+
}, [fragmentSelector]);
|
420
363
|
|
364
|
+
// Handle the queries for any missing client edges; this may suspend.
|
365
|
+
// FIXME handle client edges in parallel.
|
421
366
|
if (((_fragmentNode$metadat2 = fragmentNode.metadata) === null || _fragmentNode$metadat2 === void 0 ? void 0 : _fragmentNode$metadat2.hasClientEdges) === true) {
|
422
367
|
// The fragment is validated to be static (in useFragment) and hasClientEdges is
|
423
368
|
// a static (constant) property of the fragment. In practice, this effect will
|
424
369
|
// always or never run for a given invocation of this hook.
|
425
370
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
426
371
|
var clientEdgeQueries = useMemo(function () {
|
427
|
-
var missingClientEdges = getMissingClientEdges(state);
|
428
|
-
|
372
|
+
var missingClientEdges = getMissingClientEdges(state);
|
373
|
+
// eslint-disable-next-line no-shadow
|
429
374
|
var clientEdgeQueries;
|
430
|
-
|
431
375
|
if (missingClientEdges !== null && missingClientEdges !== void 0 && missingClientEdges.length) {
|
432
376
|
clientEdgeQueries = [];
|
433
|
-
|
434
377
|
var _iterator7 = (0, _createForOfIteratorHelper2["default"])(missingClientEdges),
|
435
|
-
|
436
|
-
|
378
|
+
_step7;
|
437
379
|
try {
|
438
380
|
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
439
381
|
var edge = _step7.value;
|
@@ -445,20 +387,17 @@ function useFragmentInternal_REACT_CACHE(fragmentNode, fragmentRef, hookDisplayN
|
|
445
387
|
_iterator7.f();
|
446
388
|
}
|
447
389
|
}
|
448
|
-
|
449
390
|
return clientEdgeQueries;
|
450
|
-
}, [state, environment, fragmentNode, fragmentRef, queryOptions]);
|
451
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
391
|
+
}, [state, environment, fragmentNode, fragmentRef, queryOptions]);
|
452
392
|
|
393
|
+
// See above note
|
394
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
453
395
|
useEffect(function () {
|
454
396
|
var QueryResource = getQueryResourceForEnvironment(environment);
|
455
|
-
|
456
397
|
if (clientEdgeQueries !== null && clientEdgeQueries !== void 0 && clientEdgeQueries.length) {
|
457
398
|
var disposables = [];
|
458
|
-
|
459
399
|
var _iterator8 = (0, _createForOfIteratorHelper2["default"])(clientEdgeQueries),
|
460
|
-
|
461
|
-
|
400
|
+
_step8;
|
462
401
|
try {
|
463
402
|
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
464
403
|
var query = _step8.value;
|
@@ -469,11 +408,9 @@ function useFragmentInternal_REACT_CACHE(fragmentNode, fragmentRef, hookDisplayN
|
|
469
408
|
} finally {
|
470
409
|
_iterator8.f();
|
471
410
|
}
|
472
|
-
|
473
411
|
return function () {
|
474
412
|
var _iterator9 = (0, _createForOfIteratorHelper2["default"])(disposables),
|
475
|
-
|
476
|
-
|
413
|
+
_step9;
|
477
414
|
try {
|
478
415
|
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
479
416
|
var disposable = _step9.value;
|
@@ -488,64 +425,54 @@ function useFragmentInternal_REACT_CACHE(fragmentNode, fragmentRef, hookDisplayN
|
|
488
425
|
}
|
489
426
|
}, [environment, clientEdgeQueries]);
|
490
427
|
}
|
491
|
-
|
492
428
|
if (isMissingData(state)) {
|
493
429
|
// Suspend if a Live Resolver within this fragment is in a suspended state:
|
494
430
|
var suspendingLiveResolvers = getSuspendingLiveResolver(state);
|
495
|
-
|
496
431
|
if (suspendingLiveResolvers != null && suspendingLiveResolvers.length > 0) {
|
497
432
|
throw Promise.all(suspendingLiveResolvers.map(function (_ref) {
|
498
433
|
var liveStateID = _ref.liveStateID;
|
499
434
|
// $FlowFixMe[prop-missing] This is expected to be a LiveResolverStore
|
500
435
|
return environment.getStore().getLiveResolverPromise(liveStateID);
|
501
436
|
}));
|
502
|
-
}
|
437
|
+
}
|
438
|
+
// Suspend if an active operation bears on this fragment, either the
|
503
439
|
// fragment's owner or some other mutation etc. that could affect it.
|
504
440
|
// We only suspend when the component is first trying to mount or changing
|
505
441
|
// selectors, not if data becomes missing later:
|
506
|
-
|
507
|
-
|
508
442
|
if (!committedFragmentSelectorRef.current || !areEqualSelectors(committedFragmentSelectorRef.current, fragmentSelector)) {
|
509
443
|
!(fragmentSelector != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'refinement, see invariants above') : invariant(false) : void 0;
|
510
444
|
var fragmentOwner = fragmentSelector.kind === 'PluralReaderSelector' ? fragmentSelector.selectors[0].owner : fragmentSelector.owner;
|
511
445
|
var pendingOperationsResult = getPendingOperationsForFragment(environment, fragmentNode, fragmentOwner);
|
512
|
-
|
513
446
|
if (pendingOperationsResult) {
|
514
447
|
throw pendingOperationsResult.promise;
|
515
448
|
}
|
516
|
-
}
|
449
|
+
}
|
450
|
+
// Report required fields only if we're not suspending, since that means
|
517
451
|
// they're missing even though we are out of options for possibly fetching them:
|
518
|
-
|
519
|
-
|
520
452
|
handlePotentialSnapshotErrorsForState(environment, state);
|
521
453
|
}
|
522
|
-
|
523
454
|
useEffect(function () {
|
524
455
|
// Check for updates since the state was rendered
|
525
456
|
var currentState = subscribedState;
|
526
457
|
var updates = handleMissedUpdates(environment, subscribedState);
|
527
|
-
|
528
458
|
if (updates !== null) {
|
529
459
|
var didMissUpdates = updates[0],
|
530
|
-
|
460
|
+
updatedState = updates[1];
|
461
|
+
// TODO: didMissUpdates only checks for changes to snapshot data, but it's possible
|
531
462
|
// that other snapshot properties may have changed that should also trigger a re-render,
|
532
463
|
// such as changed missing resolver fields, missing client edges, etc.
|
533
464
|
// A potential alternative is for handleMissedUpdates() to recycle the entire state
|
534
465
|
// value, and return the new (recycled) state only if there was some change. In that
|
535
466
|
// case the code would always setState if something in the snapshot changed, in addition
|
536
467
|
// to using the latest snapshot to subscribe.
|
537
|
-
|
538
468
|
if (didMissUpdates) {
|
539
469
|
setState(updatedState);
|
540
470
|
}
|
541
|
-
|
542
471
|
currentState = updatedState;
|
543
472
|
}
|
544
|
-
|
545
473
|
return subscribeToSnapshot(environment, currentState, setState);
|
546
474
|
}, [environment, subscribedState]);
|
547
475
|
var data;
|
548
|
-
|
549
476
|
if (isPlural) {
|
550
477
|
// Plural fragments require allocating an array of the snasphot data values,
|
551
478
|
// which has to be memoized to avoid triggering downstream re-renders.
|
@@ -554,7 +481,6 @@ function useFragmentInternal_REACT_CACHE(fragmentNode, fragmentRef, hookDisplayN
|
|
554
481
|
// for a particular useFragment invocation site
|
555
482
|
var fragmentRefIsNullish = fragmentRef == null; // for less sensitive memoization
|
556
483
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
557
|
-
|
558
484
|
data = useMemo(function () {
|
559
485
|
if (state.kind === 'bailout') {
|
560
486
|
// Bailout state can happen if the fragmentRef is a plural array that is empty or has no
|
@@ -575,7 +501,6 @@ function useFragmentInternal_REACT_CACHE(fragmentNode, fragmentRef, hookDisplayN
|
|
575
501
|
!(state.kind === 'singular') ? process.env.NODE_ENV !== "production" ? invariant(false, 'Expected state to be singular because fragment is singular') : invariant(false) : void 0;
|
576
502
|
data = state.snapshot.data;
|
577
503
|
}
|
578
|
-
|
579
504
|
if (process.env.NODE_ENV !== "production") {
|
580
505
|
if (fragmentRef != null && (data === undefined || Array.isArray(data) && data.length > 0 && data.every(function (d) {
|
581
506
|
return d === undefined;
|
@@ -583,7 +508,6 @@ function useFragmentInternal_REACT_CACHE(fragmentNode, fragmentRef, hookDisplayN
|
|
583
508
|
process.env.NODE_ENV !== "production" ? warning(false, 'Relay: Expected to have been able to read non-null data for ' + 'fragment `%s` declared in ' + '`%s`, since fragment reference was non-null. ' + "Make sure that that `%s`'s parent isn't " + 'holding on to and/or passing a fragment reference for data that ' + 'has been deleted.', fragmentNode.name, hookDisplayName, hookDisplayName) : void 0;
|
584
509
|
}
|
585
510
|
}
|
586
|
-
|
587
511
|
if (process.env.NODE_ENV !== "production") {
|
588
512
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
589
513
|
useDebugValue({
|
@@ -591,8 +515,6 @@ function useFragmentInternal_REACT_CACHE(fragmentNode, fragmentRef, hookDisplayN
|
|
591
515
|
data: data
|
592
516
|
});
|
593
517
|
}
|
594
|
-
|
595
518
|
return data;
|
596
519
|
}
|
597
|
-
|
598
520
|
module.exports = useFragmentInternal_REACT_CACHE;
|
@@ -4,38 +4,31 @@
|
|
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 _require = require('../loadQuery'),
|
14
|
-
|
15
|
-
|
15
|
+
useTrackLoadQueryInRender = _require.useTrackLoadQueryInRender;
|
16
16
|
var useStaticFragmentNodeWarning = require('../useStaticFragmentNodeWarning');
|
17
|
-
|
18
17
|
var useFragmentInternal = require('./useFragmentInternal_REACT_CACHE');
|
19
|
-
|
20
18
|
var _require2 = require('react'),
|
21
|
-
|
22
|
-
|
19
|
+
useDebugValue = _require2.useDebugValue;
|
23
20
|
var _require3 = require('relay-runtime'),
|
24
|
-
|
25
|
-
|
21
|
+
getFragment = _require3.getFragment;
|
26
22
|
function useFragment(fragment, key) {
|
27
23
|
// We need to use this hook in order to be able to track if
|
28
24
|
// loadQuery was called during render
|
29
25
|
useTrackLoadQueryInRender();
|
30
26
|
var fragmentNode = getFragment(fragment);
|
31
|
-
|
32
27
|
if (process.env.NODE_ENV !== "production") {
|
33
28
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
34
29
|
useStaticFragmentNodeWarning(fragmentNode, 'first argument of useFragment()');
|
35
30
|
}
|
36
|
-
|
37
31
|
var data = useFragmentInternal(fragmentNode, key, 'useFragment()');
|
38
|
-
|
39
32
|
if (process.env.NODE_ENV !== "production") {
|
40
33
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
41
34
|
useDebugValue({
|
@@ -43,8 +36,6 @@ function useFragment(fragment, key) {
|
|
43
36
|
data: data
|
44
37
|
});
|
45
38
|
}
|
46
|
-
|
47
39
|
return data;
|
48
40
|
}
|
49
|
-
|
50
41
|
module.exports = useFragment;
|
@@ -5,51 +5,45 @@
|
|
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 _require = require('../loadQuery'),
|
14
|
-
|
15
|
-
|
15
|
+
useTrackLoadQueryInRender = _require.useTrackLoadQueryInRender;
|
16
16
|
var useMemoOperationDescriptor = require('../useMemoOperationDescriptor');
|
17
|
-
|
18
17
|
var useRelayEnvironment = require('../useRelayEnvironment');
|
19
|
-
|
20
18
|
var getQueryResultOrFetchQuery = require('./getQueryResultOrFetchQuery_REACT_CACHE');
|
21
|
-
|
22
19
|
var useFragmentInternal = require('./useFragmentInternal_REACT_CACHE');
|
23
|
-
|
24
20
|
var _require2 = require('react'),
|
25
|
-
|
26
|
-
|
21
|
+
useEffect = _require2.useEffect;
|
27
22
|
function useLazyLoadQuery_REACT_CACHE(gqlQuery, variables, options) {
|
28
23
|
var _options$networkCache;
|
29
|
-
|
30
24
|
useTrackLoadQueryInRender();
|
31
25
|
var environment = useRelayEnvironment();
|
32
26
|
var queryOperationDescriptor = useMemoOperationDescriptor(gqlQuery, variables, (_options$networkCache = options === null || options === void 0 ? void 0 : options.networkCacheConfig) !== null && _options$networkCache !== void 0 ? _options$networkCache : {
|
33
27
|
force: true
|
34
|
-
});
|
28
|
+
});
|
35
29
|
|
30
|
+
// Get the query going if needed -- this may suspend.
|
36
31
|
var _getQueryResultOrFetc = getQueryResultOrFetchQuery(environment, queryOperationDescriptor, {
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
32
|
+
fetchPolicy: options === null || options === void 0 ? void 0 : options.fetchPolicy,
|
33
|
+
renderPolicy: options === null || options === void 0 ? void 0 : options.UNSTABLE_renderPolicy,
|
34
|
+
fetchKey: options === null || options === void 0 ? void 0 : options.fetchKey
|
35
|
+
}),
|
36
|
+
queryResult = _getQueryResultOrFetc[0],
|
37
|
+
effect = _getQueryResultOrFetc[1];
|
38
|
+
useEffect(effect);
|
39
|
+
|
40
|
+
// Read the query's root fragment -- this may suspend.
|
46
41
|
var fragmentNode = queryResult.fragmentNode,
|
47
|
-
|
48
|
-
|
42
|
+
fragmentRef = queryResult.fragmentRef;
|
43
|
+
// $FlowExpectedError[incompatible-return] Is this a fixable incompatible-return?
|
49
44
|
return useFragmentInternal(fragmentNode, fragmentRef, 'useLazyLoadQuery()', {
|
50
45
|
fetchPolicy: options === null || options === void 0 ? void 0 : options.fetchPolicy,
|
51
46
|
networkCacheConfig: options === null || options === void 0 ? void 0 : options.networkCacheConfig
|
52
47
|
});
|
53
48
|
}
|
54
|
-
|
55
49
|
module.exports = useLazyLoadQuery_REACT_CACHE;
|