react-relay 14.0.0 → 14.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/ReactRelayContainerUtils.js.flow +0 -2
- package/ReactRelayContext.js +1 -1
- package/ReactRelayContext.js.flow +0 -2
- package/ReactRelayFragmentContainer.js.flow +0 -2
- package/ReactRelayFragmentMockRenderer.js.flow +0 -2
- package/ReactRelayLocalQueryRenderer.js.flow +0 -2
- package/ReactRelayPaginationContainer.js.flow +0 -2
- package/ReactRelayQueryFetcher.js.flow +9 -11
- package/ReactRelayQueryRenderer.js.flow +10 -12
- package/ReactRelayQueryRendererContext.js.flow +1 -3
- package/ReactRelayRefetchContainer.js.flow +0 -4
- package/ReactRelayTestMocker.js.flow +0 -2
- package/ReactRelayTypes.js.flow +6 -8
- package/RelayContext.js.flow +0 -2
- package/__flowtests__/ReactRelayFragmentContainer-flowtest.js.flow +2 -4
- package/__flowtests__/ReactRelayPaginationContainer-flowtest.js.flow +3 -5
- package/__flowtests__/ReactRelayRefetchContainer-flowtest.js.flow +3 -5
- package/__flowtests__/RelayModern-flowtest.js.flow +2 -4
- package/__flowtests__/RelayModernFlowtest_badref.graphql.js.flow +2 -4
- package/__flowtests__/RelayModernFlowtest_notref.graphql.js.flow +2 -4
- package/__flowtests__/RelayModernFlowtest_user.graphql.js.flow +2 -4
- package/__flowtests__/RelayModernFlowtest_users.graphql.js.flow +2 -4
- package/assertFragmentMap.js.flow +0 -2
- package/buildReactRelayContainer.js.flow +0 -2
- package/getRootVariablesForFragments.js.flow +0 -2
- package/hooks.js +1 -1
- package/hooks.js.flow +0 -2
- package/index.js +1 -1
- package/index.js.flow +2 -2
- package/isRelayEnvironment.js.flow +0 -2
- package/legacy.js +1 -1
- package/legacy.js.flow +0 -2
- package/lib/ReactRelayContainerUtils.js +0 -1
- package/lib/ReactRelayContext.js +0 -1
- package/lib/ReactRelayFragmentContainer.js +10 -9
- package/lib/ReactRelayFragmentMockRenderer.js +0 -1
- package/lib/ReactRelayLocalQueryRenderer.js +0 -1
- package/lib/ReactRelayPaginationContainer.js +14 -11
- package/lib/ReactRelayQueryFetcher.js +1 -2
- package/lib/ReactRelayQueryRenderer.js +1 -2
- package/lib/ReactRelayQueryRendererContext.js +0 -1
- package/lib/ReactRelayRefetchContainer.js +11 -14
- package/lib/ReactRelayTestMocker.js +1 -2
- package/lib/ReactRelayTypes.js +0 -1
- package/lib/RelayContext.js +0 -1
- package/lib/assertFragmentMap.js +0 -1
- package/lib/buildReactRelayContainer.js +1 -2
- package/lib/getRootVariablesForFragments.js +1 -2
- package/lib/hooks.js +0 -1
- package/lib/index.js +3 -1
- package/lib/isRelayEnvironment.js +0 -1
- package/lib/legacy.js +0 -1
- package/lib/multi-actor/useRelayActorEnvironment.js +0 -1
- package/lib/readContext.js +0 -1
- package/lib/relay-hooks/EntryPointContainer.react.js +0 -1
- package/lib/relay-hooks/EntryPointTypes.flow.js +0 -1
- package/lib/relay-hooks/FragmentResource.js +7 -7
- package/lib/relay-hooks/HooksImplementation.js +1 -1
- package/lib/relay-hooks/InternalLogger.js +0 -1
- package/lib/relay-hooks/LRUCache.js +0 -1
- package/lib/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js +0 -1
- package/lib/relay-hooks/MatchContainer.js +1 -2
- package/lib/relay-hooks/ProfilerContext.js +0 -1
- package/lib/relay-hooks/QueryResource.js +1 -2
- package/lib/relay-hooks/RelayEnvironmentProvider.js +0 -1
- package/lib/relay-hooks/SuspenseResource.js +1 -2
- package/lib/relay-hooks/loadQuery.js +1 -1
- package/lib/relay-hooks/preloadQuery_DEPRECATED.js +1 -2
- package/lib/relay-hooks/prepareEntryPoint_DEPRECATED.js +0 -1
- package/lib/relay-hooks/react-cache/RelayReactCache.js +0 -1
- package/lib/relay-hooks/react-cache/getQueryResultOrFetchQuery_REACT_CACHE.js +3 -3
- package/lib/relay-hooks/react-cache/readFragmentInternal_REACT_CACHE.js +239 -0
- package/lib/relay-hooks/react-cache/useFragmentInternal_REACT_CACHE.js +183 -125
- package/lib/relay-hooks/react-cache/useFragment_REACT_CACHE.js +0 -1
- package/lib/relay-hooks/react-cache/useLazyLoadQuery_REACT_CACHE.js +0 -1
- package/lib/relay-hooks/react-cache/usePaginationFragment_REACT_CACHE.js +150 -0
- package/lib/relay-hooks/react-cache/usePreloadedQuery_REACT_CACHE.js +0 -1
- package/lib/relay-hooks/react-cache/useRefetchableFragmentInternal_REACT_CACHE.js +367 -0
- package/lib/relay-hooks/react-cache/useRefetchableFragment_REACT_CACHE.js +45 -0
- package/lib/relay-hooks/useBlockingPaginationFragment.js +4 -3
- package/lib/relay-hooks/useClientQuery.js +33 -0
- package/lib/relay-hooks/useEntryPointLoader.js +1 -2
- package/lib/relay-hooks/useFetchTrackingRef.js +0 -1
- package/lib/relay-hooks/useFragment.js +0 -1
- package/lib/relay-hooks/useFragmentNode.js +0 -1
- package/lib/relay-hooks/useIsMountedRef.js +0 -1
- package/lib/relay-hooks/useLazyLoadQuery.js +1 -15
- package/lib/relay-hooks/useLazyLoadQueryNode.js +0 -1
- package/lib/relay-hooks/useLoadMoreFunction.js +1 -2
- package/lib/relay-hooks/useMemoOperationDescriptor.js +0 -1
- package/lib/relay-hooks/useMemoVariables.js +0 -1
- package/lib/relay-hooks/useMutation.js +1 -2
- package/lib/relay-hooks/usePaginationFragment.js +15 -3
- package/lib/relay-hooks/usePreloadedQuery.js +1 -15
- package/lib/relay-hooks/useQueryLoader.js +1 -2
- package/lib/relay-hooks/useRefetchableFragment.js +14 -2
- package/lib/relay-hooks/useRefetchableFragmentNode.js +1 -2
- package/lib/relay-hooks/useRelayEnvironment.js +0 -1
- package/lib/relay-hooks/useStaticFragmentNodeWarning.js +0 -1
- package/lib/relay-hooks/useSubscribeToInvalidationState.js +0 -1
- package/lib/relay-hooks/useSubscription.js +0 -1
- package/multi-actor/useRelayActorEnvironment.js.flow +0 -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/readContext.js.flow +0 -2
- package/relay-hooks/EntryPointContainer.react.js.flow +2 -4
- package/relay-hooks/EntryPointTypes.flow.js.flow +30 -32
- package/relay-hooks/FragmentResource.js.flow +9 -11
- package/relay-hooks/HooksImplementation.js.flow +6 -8
- package/relay-hooks/InternalLogger.js.flow +0 -2
- package/relay-hooks/LRUCache.js.flow +0 -2
- package/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js.flow +4 -6
- package/relay-hooks/MatchContainer.js.flow +5 -7
- package/relay-hooks/ProfilerContext.js.flow +0 -2
- package/relay-hooks/QueryResource.js.flow +4 -6
- package/relay-hooks/RelayEnvironmentProvider.js.flow +2 -4
- package/relay-hooks/SuspenseResource.js.flow +0 -2
- package/relay-hooks/__flowtests__/EntryPointTypes/EntryPointElementConfig-flowtest.js.flow +3 -3
- package/relay-hooks/__flowtests__/EntryPointTypes/NestedEntrypoints-flowtest.js.flow +2 -2
- package/relay-hooks/__flowtests__/useBlockingPaginationFragment-flowtest.js.flow +4 -6
- package/relay-hooks/__flowtests__/useFragment-flowtest.js.flow +0 -2
- package/relay-hooks/__flowtests__/usePaginationFragment-flowtest.js.flow +4 -6
- package/relay-hooks/__flowtests__/useRefetchableFragment-flowtest.js.flow +0 -2
- package/relay-hooks/__flowtests__/utils.js.flow +8 -10
- package/relay-hooks/preloadQuery_DEPRECATED.js.flow +4 -6
- package/relay-hooks/prepareEntryPoint_DEPRECATED.js.flow +0 -2
- package/relay-hooks/react-cache/RelayReactCache.js.flow +0 -2
- package/relay-hooks/react-cache/getQueryResultOrFetchQuery_REACT_CACHE.js.flow +22 -16
- package/relay-hooks/react-cache/readFragmentInternal_REACT_CACHE.js.flow +297 -0
- package/relay-hooks/react-cache/useFragmentInternal_REACT_CACHE.js.flow +134 -94
- package/relay-hooks/react-cache/useFragment_REACT_CACHE.js.flow +0 -2
- package/relay-hooks/react-cache/useLazyLoadQuery_REACT_CACHE.js.flow +2 -4
- package/relay-hooks/react-cache/usePaginationFragment_REACT_CACHE.js.flow +171 -0
- package/relay-hooks/react-cache/usePreloadedQuery_REACT_CACHE.js.flow +2 -4
- package/relay-hooks/react-cache/useRefetchableFragmentInternal_REACT_CACHE.js.flow +595 -0
- package/relay-hooks/react-cache/useRefetchableFragment_REACT_CACHE.js.flow +65 -0
- package/relay-hooks/useBlockingPaginationFragment.js.flow +4 -6
- package/relay-hooks/useClientQuery.js.flow +39 -0
- package/relay-hooks/useEntryPointLoader.js.flow +6 -8
- package/relay-hooks/useFetchTrackingRef.js.flow +2 -4
- package/relay-hooks/useFragment.js.flow +0 -2
- package/relay-hooks/useFragmentNode.js.flow +2 -4
- package/relay-hooks/useIsMountedRef.js.flow +1 -3
- package/relay-hooks/useLazyLoadQuery.js.flow +7 -30
- package/relay-hooks/useLazyLoadQueryNode.js.flow +2 -4
- package/relay-hooks/useLoadMoreFunction.js.flow +6 -8
- package/relay-hooks/useMemoOperationDescriptor.js.flow +0 -2
- package/relay-hooks/useMemoVariables.js.flow +0 -2
- package/relay-hooks/useMutation.js.flow +2 -4
- package/relay-hooks/usePaginationFragment.js.flow +44 -19
- package/relay-hooks/usePreloadedQuery.js.flow +5 -24
- package/relay-hooks/useQueryLoader.js.flow +4 -6
- package/relay-hooks/useRefetchableFragment.js.flow +32 -3
- package/relay-hooks/useRefetchableFragmentNode.js.flow +16 -18
- package/relay-hooks/useRelayEnvironment.js.flow +0 -2
- package/relay-hooks/useStaticFragmentNodeWarning.js.flow +0 -2
- package/relay-hooks/useSubscribeToInvalidationState.js.flow +0 -2
- package/relay-hooks/useSubscription.js.flow +0 -2
@@ -8,10 +8,9 @@
|
|
8
8
|
* @emails oncall+relay
|
9
9
|
* @format
|
10
10
|
*/
|
11
|
-
// flowlint ambiguous-object-type:error
|
12
11
|
'use strict';
|
13
12
|
|
14
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
13
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
15
14
|
|
16
15
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
17
16
|
|
@@ -32,10 +31,11 @@ var _require2 = require('relay-runtime'),
|
|
32
31
|
var warning = require("fbjs/lib/warning");
|
33
32
|
|
34
33
|
var DEFAULT_FETCH_POLICY = 'store-or-network';
|
34
|
+
var WEAKMAP_SUPPORTED = typeof WeakMap === 'function';
|
35
35
|
|
36
36
|
var QueryCache = /*#__PURE__*/function () {
|
37
37
|
function QueryCache() {
|
38
|
-
this._map = new Map();
|
38
|
+
this._map = WEAKMAP_SUPPORTED ? new WeakMap() : new Map();
|
39
39
|
}
|
40
40
|
|
41
41
|
var _proto = QueryCache.prototype;
|
@@ -0,0 +1,239 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and 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 _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
14
|
+
|
15
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
16
|
+
|
17
|
+
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
|
18
|
+
|
19
|
+
var _require = require('../QueryResource'),
|
20
|
+
getQueryResourceForEnvironment = _require.getQueryResourceForEnvironment;
|
21
|
+
|
22
|
+
var invariant = require('invariant');
|
23
|
+
|
24
|
+
var _require2 = require('relay-runtime'),
|
25
|
+
fetchQueryInternal = _require2.__internal.fetchQuery,
|
26
|
+
createOperationDescriptor = _require2.createOperationDescriptor,
|
27
|
+
getPendingOperationsForFragment = _require2.getPendingOperationsForFragment,
|
28
|
+
getSelector = _require2.getSelector,
|
29
|
+
getVariablesFromFragment = _require2.getVariablesFromFragment,
|
30
|
+
handlePotentialSnapshotErrors = _require2.handlePotentialSnapshotErrors;
|
31
|
+
|
32
|
+
var warning = require("fbjs/lib/warning");
|
33
|
+
|
34
|
+
function isMissingData(state) {
|
35
|
+
if (state.kind === 'bailout') {
|
36
|
+
return false;
|
37
|
+
} else if (state.kind === 'singular') {
|
38
|
+
return state.snapshot.isMissingData;
|
39
|
+
} else {
|
40
|
+
return state.snapshots.some(function (s) {
|
41
|
+
return s.isMissingData;
|
42
|
+
});
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
function getMissingClientEdges(state) {
|
47
|
+
if (state.kind === 'bailout') {
|
48
|
+
return null;
|
49
|
+
} else if (state.kind === 'singular') {
|
50
|
+
var _state$snapshot$missi;
|
51
|
+
|
52
|
+
return (_state$snapshot$missi = state.snapshot.missingClientEdges) !== null && _state$snapshot$missi !== void 0 ? _state$snapshot$missi : null;
|
53
|
+
} else {
|
54
|
+
var edges = null;
|
55
|
+
|
56
|
+
var _iterator = (0, _createForOfIteratorHelper2["default"])(state.snapshots),
|
57
|
+
_step;
|
58
|
+
|
59
|
+
try {
|
60
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
61
|
+
var snapshot = _step.value;
|
62
|
+
|
63
|
+
if (snapshot.missingClientEdges) {
|
64
|
+
var _edges;
|
65
|
+
|
66
|
+
edges = (_edges = edges) !== null && _edges !== void 0 ? _edges : [];
|
67
|
+
|
68
|
+
var _iterator2 = (0, _createForOfIteratorHelper2["default"])(snapshot.missingClientEdges),
|
69
|
+
_step2;
|
70
|
+
|
71
|
+
try {
|
72
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
73
|
+
var edge = _step2.value;
|
74
|
+
edges.push(edge);
|
75
|
+
}
|
76
|
+
} catch (err) {
|
77
|
+
_iterator2.e(err);
|
78
|
+
} finally {
|
79
|
+
_iterator2.f();
|
80
|
+
}
|
81
|
+
}
|
82
|
+
}
|
83
|
+
} catch (err) {
|
84
|
+
_iterator.e(err);
|
85
|
+
} finally {
|
86
|
+
_iterator.f();
|
87
|
+
}
|
88
|
+
|
89
|
+
return edges;
|
90
|
+
}
|
91
|
+
}
|
92
|
+
|
93
|
+
function handlePotentialSnapshotErrorsForState(environment, state) {
|
94
|
+
if (state.kind === 'singular') {
|
95
|
+
handlePotentialSnapshotErrors(environment, state.snapshot.missingRequiredFields, state.snapshot.relayResolverErrors);
|
96
|
+
} else if (state.kind === 'plural') {
|
97
|
+
var _iterator3 = (0, _createForOfIteratorHelper2["default"])(state.snapshots),
|
98
|
+
_step3;
|
99
|
+
|
100
|
+
try {
|
101
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
102
|
+
var snapshot = _step3.value;
|
103
|
+
handlePotentialSnapshotErrors(environment, snapshot.missingRequiredFields, snapshot.relayResolverErrors);
|
104
|
+
}
|
105
|
+
} catch (err) {
|
106
|
+
_iterator3.e(err);
|
107
|
+
} finally {
|
108
|
+
_iterator3.f();
|
109
|
+
}
|
110
|
+
}
|
111
|
+
}
|
112
|
+
|
113
|
+
function handleMissingClientEdge(environment, parentFragmentNode, parentFragmentRef, missingClientEdgeRequestInfo, queryOptions) {
|
114
|
+
var originalVariables = getVariablesFromFragment(parentFragmentNode, parentFragmentRef);
|
115
|
+
var variables = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, originalVariables), {}, {
|
116
|
+
id: missingClientEdgeRequestInfo.clientEdgeDestinationID // TODO should be a reserved name
|
117
|
+
|
118
|
+
});
|
119
|
+
var queryOperationDescriptor = createOperationDescriptor(missingClientEdgeRequestInfo.request, variables, queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.networkCacheConfig); // This may suspend. We don't need to do anything with the results; all we're
|
120
|
+
// doing here is started the query if needed and retaining and releasing it
|
121
|
+
// according to the component mount/suspense cycle; QueryResource
|
122
|
+
// already handles this by itself.
|
123
|
+
|
124
|
+
var QueryResource = getQueryResourceForEnvironment(environment);
|
125
|
+
return QueryResource.prepare(queryOperationDescriptor, fetchQueryInternal(environment, queryOperationDescriptor), queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.fetchPolicy);
|
126
|
+
}
|
127
|
+
|
128
|
+
function getFragmentState(environment, fragmentSelector) {
|
129
|
+
if (fragmentSelector == null) {
|
130
|
+
return {
|
131
|
+
kind: 'bailout'
|
132
|
+
};
|
133
|
+
} else if (fragmentSelector.kind === 'PluralReaderSelector') {
|
134
|
+
if (fragmentSelector.selectors.length === 0) {
|
135
|
+
return {
|
136
|
+
kind: 'bailout'
|
137
|
+
};
|
138
|
+
} else {
|
139
|
+
return {
|
140
|
+
kind: 'plural',
|
141
|
+
snapshots: fragmentSelector.selectors.map(function (s) {
|
142
|
+
return environment.lookup(s);
|
143
|
+
}),
|
144
|
+
epoch: environment.getStore().getEpoch()
|
145
|
+
};
|
146
|
+
}
|
147
|
+
} else {
|
148
|
+
return {
|
149
|
+
kind: 'singular',
|
150
|
+
snapshot: environment.lookup(fragmentSelector),
|
151
|
+
epoch: environment.getStore().getEpoch()
|
152
|
+
};
|
153
|
+
}
|
154
|
+
} // fragmentNode cannot change during the lifetime of the component, though fragmentRef may change.
|
155
|
+
|
156
|
+
|
157
|
+
function readFragmentInternal_REACT_CACHE(environment, fragmentNode, fragmentRef, hookDisplayName, queryOptions, fragmentKey) {
|
158
|
+
var _fragmentNode$metadat, _fragmentNode$metadat2;
|
159
|
+
|
160
|
+
var fragmentSelector = getSelector(fragmentNode, fragmentRef);
|
161
|
+
var isPlural = (fragmentNode === null || fragmentNode === void 0 ? void 0 : (_fragmentNode$metadat = fragmentNode.metadata) === null || _fragmentNode$metadat === void 0 ? void 0 : _fragmentNode$metadat.plural) === true;
|
162
|
+
|
163
|
+
if (isPlural) {
|
164
|
+
!(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;
|
165
|
+
} else {
|
166
|
+
!!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;
|
167
|
+
}
|
168
|
+
|
169
|
+
!(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;
|
170
|
+
var state = getFragmentState(environment, fragmentSelector); // Handle the queries for any missing client edges; this may suspend.
|
171
|
+
// FIXME handle client edges in parallel.
|
172
|
+
|
173
|
+
var clientEdgeQueries = null;
|
174
|
+
|
175
|
+
if (((_fragmentNode$metadat2 = fragmentNode.metadata) === null || _fragmentNode$metadat2 === void 0 ? void 0 : _fragmentNode$metadat2.hasClientEdges) === true) {
|
176
|
+
var missingClientEdges = getMissingClientEdges(state);
|
177
|
+
|
178
|
+
if (missingClientEdges !== null && missingClientEdges !== void 0 && missingClientEdges.length) {
|
179
|
+
clientEdgeQueries = [];
|
180
|
+
|
181
|
+
var _iterator4 = (0, _createForOfIteratorHelper2["default"])(missingClientEdges),
|
182
|
+
_step4;
|
183
|
+
|
184
|
+
try {
|
185
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
186
|
+
var edge = _step4.value;
|
187
|
+
clientEdgeQueries.push(handleMissingClientEdge(environment, fragmentNode, fragmentRef, edge, queryOptions));
|
188
|
+
}
|
189
|
+
} catch (err) {
|
190
|
+
_iterator4.e(err);
|
191
|
+
} finally {
|
192
|
+
_iterator4.f();
|
193
|
+
}
|
194
|
+
}
|
195
|
+
}
|
196
|
+
|
197
|
+
if (isMissingData(state)) {
|
198
|
+
// Suspend if an active operation bears on this fragment, either the
|
199
|
+
// fragment's owner or some other mutation etc. that could affect it:
|
200
|
+
!(fragmentSelector != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'refinement, see invariants above') : invariant(false) : void 0;
|
201
|
+
var fragmentOwner = fragmentSelector.kind === 'PluralReaderSelector' ? fragmentSelector.selectors[0].owner : fragmentSelector.owner;
|
202
|
+
var pendingOperationsResult = getPendingOperationsForFragment(environment, fragmentNode, fragmentOwner);
|
203
|
+
|
204
|
+
if (pendingOperationsResult) {
|
205
|
+
throw pendingOperationsResult.promise;
|
206
|
+
} // Report required fields only if we're not suspending, since that means
|
207
|
+
// they're missing even though we are out of options for possibly fetching them:
|
208
|
+
|
209
|
+
|
210
|
+
handlePotentialSnapshotErrorsForState(environment, state);
|
211
|
+
}
|
212
|
+
|
213
|
+
var data;
|
214
|
+
|
215
|
+
if (state.kind === 'bailout') {
|
216
|
+
data = isPlural ? [] : null;
|
217
|
+
} else if (state.kind === 'singular') {
|
218
|
+
data = state.snapshot.data;
|
219
|
+
} else {
|
220
|
+
data = state.snapshots.map(function (s) {
|
221
|
+
return s.data;
|
222
|
+
});
|
223
|
+
}
|
224
|
+
|
225
|
+
if (process.env.NODE_ENV !== "production") {
|
226
|
+
if (fragmentRef != null && (data === undefined || Array.isArray(data) && data.length > 0 && data.every(function (d) {
|
227
|
+
return d === undefined;
|
228
|
+
}))) {
|
229
|
+
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;
|
230
|
+
}
|
231
|
+
}
|
232
|
+
|
233
|
+
return {
|
234
|
+
data: data,
|
235
|
+
clientEdgeQueries: clientEdgeQueries
|
236
|
+
};
|
237
|
+
}
|
238
|
+
|
239
|
+
module.exports = readFragmentInternal_REACT_CACHE;
|