react-relay 16.1.0 → 17.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/ReactRelayContext.js +1 -1
- package/ReactRelayFragmentContainer.js.flow +8 -6
- package/ReactRelayLocalQueryRenderer.js.flow +4 -1
- package/ReactRelayPaginationContainer.js.flow +2 -0
- package/ReactRelayQueryRenderer.js.flow +1 -1
- package/ReactRelayTypes.js.flow +1 -0
- package/buildReactRelayContainer.js.flow +5 -3
- package/getRootVariablesForFragments.js.flow +1 -0
- package/hooks.js +1 -1
- package/hooks.js.flow +1 -1
- package/index.js +1 -1
- package/index.js.flow +1 -1
- package/legacy.js +1 -1
- package/lib/ReactRelayFragmentContainer.js +2 -2
- package/lib/buildReactRelayContainer.js +3 -3
- package/lib/relay-hooks/SuspenseResource.js +7 -4
- package/lib/relay-hooks/{FragmentResource.js → legacy/FragmentResource.js} +19 -20
- package/lib/relay-hooks/{useBlockingPaginationFragment.js → legacy/useBlockingPaginationFragment.js} +2 -2
- package/lib/relay-hooks/{useFragmentNode.js → legacy/useFragmentNode.js} +2 -2
- package/lib/relay-hooks/{useRefetchableFragmentNode.js → legacy/useRefetchableFragmentNode.js} +8 -8
- package/lib/relay-hooks/{experimental/readFragmentInternal_EXPERIMENTAL.js → readFragmentInternal.js} +7 -5
- package/lib/relay-hooks/useFragment.js +3 -13
- package/lib/relay-hooks/{experimental/useFragmentInternal_EXPERIMENTAL.js → useFragmentInternal.js} +67 -31
- package/lib/relay-hooks/useLazyLoadQueryNode.js +2 -13
- package/lib/relay-hooks/usePaginationFragment.js +17 -13
- package/lib/relay-hooks/useRefetchableFragment.js +3 -12
- package/lib/relay-hooks/{experimental/useRefetchableFragmentInternal_EXPERIMENTAL.js → useRefetchableFragmentInternal.js} +7 -7
- package/multi-actor/useRelayActorEnvironment.js.flow +1 -1
- 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/EntryPointTypes.flow.js.flow +22 -27
- package/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js.flow +14 -1
- package/relay-hooks/NestedRelayEntryPointBuilderUtils.js.flow +5 -11
- package/relay-hooks/SuspenseResource.js.flow +11 -8
- package/relay-hooks/__flowtests__/useBlockingPaginationFragment-flowtest.js.flow +22 -1
- package/relay-hooks/__flowtests__/usePaginationFragment-flowtest.js.flow +19 -0
- package/relay-hooks/__flowtests__/useRefetchableFragment-flowtest.js.flow +22 -0
- package/relay-hooks/{FragmentResource.js.flow → legacy/FragmentResource.js.flow} +21 -21
- package/relay-hooks/{useBlockingPaginationFragment.js.flow → legacy/useBlockingPaginationFragment.js.flow} +6 -6
- package/relay-hooks/{useFragmentNode.js.flow → legacy/useFragmentNode.js.flow} +3 -3
- package/relay-hooks/{useRefetchableFragmentNode.js.flow → legacy/useRefetchableFragmentNode.js.flow} +9 -9
- package/relay-hooks/loadQuery.js.flow +9 -8
- package/relay-hooks/{experimental/readFragmentInternal_EXPERIMENTAL.js.flow → readFragmentInternal.js.flow} +8 -4
- package/relay-hooks/useClientQuery.js.flow +1 -1
- package/relay-hooks/useEntryPointLoader.js.flow +1 -1
- package/relay-hooks/useFetchTrackingRef.js.flow +1 -1
- package/relay-hooks/useFragment.js.flow +16 -22
- package/relay-hooks/{experimental/useFragmentInternal_EXPERIMENTAL.js.flow → useFragmentInternal.js.flow} +71 -19
- package/relay-hooks/useIsMountedRef.js.flow +1 -1
- package/relay-hooks/useIsOperationNodeActive.js.flow +1 -1
- package/relay-hooks/useIsParentQueryActive.js.flow +5 -2
- package/relay-hooks/useLazyLoadQuery.js.flow +3 -2
- package/relay-hooks/useLazyLoadQueryNode.js.flow +3 -19
- package/relay-hooks/useLoadMoreFunction.js.flow +1 -1
- package/relay-hooks/useMemoOperationDescriptor.js.flow +1 -1
- package/relay-hooks/useMemoVariables.js.flow +1 -1
- package/relay-hooks/useMutation.js.flow +1 -1
- package/relay-hooks/usePaginationFragment.js.flow +62 -50
- package/relay-hooks/usePreloadedQuery.js.flow +2 -1
- package/relay-hooks/useQueryLoader.js.flow +2 -5
- package/relay-hooks/useRefetchableFragment.js.flow +7 -37
- package/relay-hooks/{experimental/useRefetchableFragmentInternal_EXPERIMENTAL.js.flow → useRefetchableFragmentInternal.js.flow} +11 -11
- package/relay-hooks/useRelayEnvironment.js.flow +1 -1
- package/relay-hooks/useStaticFragmentNodeWarning.js.flow +3 -1
- package/relay-hooks/useSubscribeToInvalidationState.js.flow +1 -1
- package/relay-hooks/useSubscription.js.flow +1 -1
- package/relay-hooks/useUnsafeRef_DEPRECATED.js.flow +1 -1
- package/lib/relay-hooks/HooksImplementation.js +0 -15
- package/lib/relay-hooks/experimental/useFragment_EXPERIMENTAL.js +0 -26
- package/lib/relay-hooks/experimental/usePaginationFragment_EXPERIMENTAL.js +0 -127
- package/lib/relay-hooks/experimental/useRefetchableFragment_EXPERIMENTAL.js +0 -23
- package/relay-hooks/HooksImplementation.js.flow +0 -45
- package/relay-hooks/experimental/useFragment_EXPERIMENTAL.js.flow +0 -66
- package/relay-hooks/experimental/usePaginationFragment_EXPERIMENTAL.js.flow +0 -161
- package/relay-hooks/experimental/useRefetchableFragment_EXPERIMENTAL.js.flow +0 -49
package/ReactRelayContext.js
CHANGED
@@ -242,12 +242,14 @@ function createContainerWithFragments<
|
|
242
242
|
// eslint-disable-next-line no-unused-vars
|
243
243
|
const {componentRef, __relayContext, __rootIsQueryRenderer, ...props} =
|
244
244
|
this.props;
|
245
|
-
return
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
245
|
+
return (
|
246
|
+
<Component
|
247
|
+
{...props}
|
248
|
+
{...this.state.data}
|
249
|
+
ref={componentRef}
|
250
|
+
relay={this.state.relayProp}
|
251
|
+
/>
|
252
|
+
);
|
251
253
|
}
|
252
254
|
};
|
253
255
|
}
|
@@ -40,14 +40,17 @@ const queryRendererContext: ReactRelayQueryRendererContextType = {
|
|
40
40
|
rootIsQueryRenderer: true,
|
41
41
|
};
|
42
42
|
|
43
|
-
|
43
|
+
hook useDeepCompare<T: {...}>(value: T): T {
|
44
44
|
const latestValue = React.useRef(value);
|
45
|
+
// $FlowFixMe[react-rule-unsafe-ref]
|
45
46
|
if (!areEqual(latestValue.current, value)) {
|
46
47
|
if (__DEV__) {
|
47
48
|
deepFreeze(value);
|
48
49
|
}
|
50
|
+
// $FlowFixMe[react-rule-unsafe-ref]
|
49
51
|
latestValue.current = value;
|
50
52
|
}
|
53
|
+
// $FlowFixMe[react-rule-unsafe-ref]
|
51
54
|
return latestValue.current;
|
52
55
|
}
|
53
56
|
|
@@ -595,7 +595,9 @@ function createContainerWithFragments<
|
|
595
595
|
PAGE_INFO,
|
596
596
|
connectionData,
|
597
597
|
);
|
598
|
+
// $FlowFixMe[invalid-computed-prop]
|
598
599
|
const edges = connectionData[EDGES];
|
600
|
+
// $FlowFixMe[invalid-computed-prop]
|
599
601
|
const pageInfo = connectionData[PAGE_INFO];
|
600
602
|
if (edges == null || pageInfo == null) {
|
601
603
|
return null;
|
@@ -378,7 +378,7 @@ function fetchQueryAndComputeStateFromProps(
|
|
378
378
|
requestCacheKey: ?string,
|
379
379
|
): Partial<State> {
|
380
380
|
const {environment, query, variables, cacheConfig} = props;
|
381
|
-
const genericEnvironment =
|
381
|
+
const genericEnvironment: IEnvironment = environment;
|
382
382
|
if (query) {
|
383
383
|
const request = getRequest(query);
|
384
384
|
const operation = createOperationDescriptor(
|
package/ReactRelayTypes.js.flow
CHANGED
@@ -103,6 +103,7 @@ export type $FragmentRef<T> = {
|
|
103
103
|
*/
|
104
104
|
// prettier-ignore
|
105
105
|
// $FlowFixMe[extra-type-arg] xplat redux flow type error
|
106
|
+
// $FlowFixMe[deprecated-type]
|
106
107
|
export type $RelayProps<Props, RelayPropT = RelayProp> = $ObjMap<
|
107
108
|
$Diff<Props, { relay: RelayPropT | void, ... }>,
|
108
109
|
& (<T: { +$fragmentType: empty, ... }>( T) => T)
|
@@ -52,12 +52,13 @@ function buildReactRelayContainer<TBase: React$ComponentType<any>>(
|
|
52
52
|
const Container = createContainerWithFragments(ComponentClass, fragments);
|
53
53
|
Container.displayName = containerName;
|
54
54
|
|
55
|
-
function
|
55
|
+
function ForwardRef(
|
56
56
|
props: any,
|
57
57
|
ref:
|
58
58
|
| ((null | React$ElementRef<TBase>) => mixed)
|
59
59
|
| {-current: null | React$ElementRef<TBase>, ...},
|
60
60
|
) {
|
61
|
+
// $FlowFixMe[react-rule-hook]
|
61
62
|
const context = useContext(ReactRelayContext);
|
62
63
|
invariant(
|
63
64
|
context != null,
|
@@ -66,6 +67,7 @@ function buildReactRelayContainer<TBase: React$ComponentType<any>>(
|
|
66
67
|
containerName,
|
67
68
|
containerName,
|
68
69
|
);
|
70
|
+
// $FlowFixMe[react-rule-hook]
|
69
71
|
const queryRendererContext = useContext(ReactRelayQueryRendererContext);
|
70
72
|
|
71
73
|
return (
|
@@ -79,8 +81,8 @@ function buildReactRelayContainer<TBase: React$ComponentType<any>>(
|
|
79
81
|
/>
|
80
82
|
);
|
81
83
|
}
|
82
|
-
|
83
|
-
const ForwardContainer = React.forwardRef(
|
84
|
+
ForwardRef.displayName = containerName;
|
85
|
+
const ForwardContainer = React.forwardRef(ForwardRef);
|
84
86
|
|
85
87
|
if (__DEV__) {
|
86
88
|
// Used by RelayModernTestUtils
|
@@ -25,6 +25,7 @@ function getRootVariablesForFragments<TProps: {...}>(
|
|
25
25
|
// should all point to the same owner
|
26
26
|
Object.keys(fragments).forEach(key => {
|
27
27
|
const fragmentNode = fragments[key];
|
28
|
+
// $FlowFixMe[invalid-computed-prop]
|
28
29
|
const fragmentRef = props[key];
|
29
30
|
const selector = getSelector(fragmentNode, fragmentRef);
|
30
31
|
const fragmentOwnerVariables =
|
package/hooks.js
CHANGED
package/hooks.js.flow
CHANGED
package/index.js
CHANGED
package/index.js.flow
CHANGED
package/legacy.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
4
|
-
var
|
4
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
5
5
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
6
6
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
7
7
|
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
|
@@ -141,7 +141,7 @@ function createContainerWithFragments(Component, fragments) {
|
|
141
141
|
__relayContext = _this$props.__relayContext,
|
142
142
|
__rootIsQueryRenderer = _this$props.__rootIsQueryRenderer,
|
143
143
|
props = (0, _objectWithoutPropertiesLoose2["default"])(_this$props, _excluded);
|
144
|
-
return React.createElement(Component, (0,
|
144
|
+
return /*#__PURE__*/React.createElement(Component, (0, _extends2["default"])({}, props, this.state.data, {
|
145
145
|
ref: componentRef,
|
146
146
|
relay: this.state.relayProp
|
147
147
|
}));
|
@@ -22,7 +22,7 @@ function buildReactRelayContainer(ComponentClass, fragmentSpec, createContainerW
|
|
22
22
|
}
|
23
23
|
var Container = createContainerWithFragments(ComponentClass, fragments);
|
24
24
|
Container.displayName = containerName;
|
25
|
-
function
|
25
|
+
function ForwardRef(props, ref) {
|
26
26
|
var _queryRendererContext;
|
27
27
|
var context = useContext(ReactRelayContext);
|
28
28
|
!(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;
|
@@ -33,8 +33,8 @@ function buildReactRelayContainer(ComponentClass, fragmentSpec, createContainerW
|
|
33
33
|
componentRef: props.componentRef || ref
|
34
34
|
}));
|
35
35
|
}
|
36
|
-
|
37
|
-
var ForwardContainer = React.forwardRef(
|
36
|
+
ForwardRef.displayName = containerName;
|
37
|
+
var ForwardContainer = React.forwardRef(ForwardRef);
|
38
38
|
if (process.env.NODE_ENV !== "production") {
|
39
39
|
ForwardContainer.__ComponentClass = ComponentClass;
|
40
40
|
ForwardContainer.displayName = containerName;
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
4
4
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
5
|
-
var
|
5
|
+
var warning = require("fbjs/lib/warning");
|
6
6
|
var TEMPORARY_RETAIN_DURATION_MS = 5 * 60 * 1000;
|
7
7
|
var SuspenseResource = /*#__PURE__*/function () {
|
8
8
|
function SuspenseResource(retain) {
|
@@ -19,9 +19,12 @@ var SuspenseResource = /*#__PURE__*/function () {
|
|
19
19
|
dispose: function dispose() {
|
20
20
|
_this._retainCount = Math.max(0, _this._retainCount - 1);
|
21
21
|
if (_this._retainCount === 0) {
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
if (_this._retainDisposable != null) {
|
23
|
+
_this._retainDisposable.dispose();
|
24
|
+
_this._retainDisposable = null;
|
25
|
+
} else {
|
26
|
+
process.env.NODE_ENV !== "production" ? warning(false, 'Relay: Expected disposable to release query to be defined.' + "If you're seeing this, this is likely a bug in Relay.") : void 0;
|
27
|
+
}
|
25
28
|
}
|
26
29
|
}
|
27
30
|
};
|
@@ -4,10 +4,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
4
4
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
5
5
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
6
6
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
7
|
-
var LRUCache = require('
|
8
|
-
var _require = require('
|
7
|
+
var LRUCache = require('../LRUCache');
|
8
|
+
var _require = require('../QueryResource'),
|
9
9
|
getQueryResourceForEnvironment = _require.getQueryResourceForEnvironment;
|
10
|
-
var SuspenseResource = require('
|
10
|
+
var SuspenseResource = require('../SuspenseResource');
|
11
11
|
var invariant = require('invariant');
|
12
12
|
var _require2 = require('relay-runtime'),
|
13
13
|
_require2$__internal = _require2.__internal,
|
@@ -131,9 +131,7 @@ var FragmentResourceImpl = /*#__PURE__*/function () {
|
|
131
131
|
function FragmentResourceImpl(environment) {
|
132
132
|
this._environment = environment;
|
133
133
|
this._cache = LRUCache.create(CACHE_CAPACITY);
|
134
|
-
|
135
|
-
this._clientEdgeQueryResultsCache = new ClientEdgeQueryResultsCache(environment);
|
136
|
-
}
|
134
|
+
this._clientEdgeQueryResultsCache = new ClientEdgeQueryResultsCache(environment);
|
137
135
|
}
|
138
136
|
var _proto2 = FragmentResourceImpl.prototype;
|
139
137
|
_proto2.read = function read(fragmentNode, fragmentRef, componentDisplayName, fragmentKey) {
|
@@ -216,7 +214,7 @@ var FragmentResourceImpl = /*#__PURE__*/function () {
|
|
216
214
|
return fragmentResult;
|
217
215
|
}
|
218
216
|
var clientEdgeRequests = null;
|
219
|
-
if (
|
217
|
+
if (((_fragmentNode$metadat2 = fragmentNode.metadata) === null || _fragmentNode$metadat2 === void 0 ? void 0 : _fragmentNode$metadat2.hasClientEdges) === true && hasMissingClientEdges(snapshot)) {
|
220
218
|
clientEdgeRequests = [];
|
221
219
|
var queryResource = getQueryResourceForEnvironment(this._environment);
|
222
220
|
var queryResults = [];
|
@@ -237,7 +235,7 @@ var FragmentResourceImpl = /*#__PURE__*/function () {
|
|
237
235
|
this._clientEdgeQueryResultsCache.recordQueryResults(fragmentIdentifier, queryResults);
|
238
236
|
}
|
239
237
|
var clientEdgePromises = [];
|
240
|
-
if (
|
238
|
+
if (clientEdgeRequests) {
|
241
239
|
clientEdgePromises = clientEdgeRequests.map(function (request) {
|
242
240
|
return getPromiseForActiveRequest(_this3._environment, request);
|
243
241
|
}).filter(Boolean);
|
@@ -311,10 +309,12 @@ var FragmentResourceImpl = /*#__PURE__*/function () {
|
|
311
309
|
var _this4 = this;
|
312
310
|
if (Array.isArray(snapshot)) {
|
313
311
|
snapshot.forEach(function (s) {
|
314
|
-
|
312
|
+
var _s$selector$node$meta, _s$selector$node$meta2;
|
313
|
+
handlePotentialSnapshotErrors(_this4._environment, s.missingRequiredFields, s.relayResolverErrors, s.errorResponseFields, (_s$selector$node$meta = (_s$selector$node$meta2 = s.selector.node.metadata) === null || _s$selector$node$meta2 === void 0 ? void 0 : _s$selector$node$meta2.throwOnFieldError) !== null && _s$selector$node$meta !== void 0 ? _s$selector$node$meta : false);
|
315
314
|
});
|
316
315
|
} else {
|
317
|
-
|
316
|
+
var _snapshot$selector$no, _snapshot$selector$no2;
|
317
|
+
handlePotentialSnapshotErrors(this._environment, snapshot.missingRequiredFields, snapshot.relayResolverErrors, snapshot.errorResponseFields, (_snapshot$selector$no = (_snapshot$selector$no2 = snapshot.selector.node.metadata) === null || _snapshot$selector$no2 === void 0 ? void 0 : _snapshot$selector$no2.throwOnFieldError) !== null && _snapshot$selector$no !== void 0 ? _snapshot$selector$no : false);
|
318
318
|
}
|
319
319
|
};
|
320
320
|
_proto2.readSpec = function readSpec(fragmentNodes, fragmentRefs, componentDisplayName) {
|
@@ -326,6 +326,7 @@ var FragmentResourceImpl = /*#__PURE__*/function () {
|
|
326
326
|
};
|
327
327
|
_proto2.subscribe = function subscribe(fragmentResult, callback) {
|
328
328
|
var _this5 = this;
|
329
|
+
var _this$_clientEdgeQuer, _this$_clientEdgeQuer2;
|
329
330
|
var environment = this._environment;
|
330
331
|
var cacheKey = fragmentResult.cacheKey;
|
331
332
|
var renderedSnapshot = fragmentResult.snapshot;
|
@@ -370,15 +371,12 @@ var FragmentResourceImpl = /*#__PURE__*/function () {
|
|
370
371
|
callback();
|
371
372
|
}));
|
372
373
|
}
|
373
|
-
|
374
|
-
|
375
|
-
var
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
disposables.push(queryResource.retain(queryResult));
|
380
|
-
});
|
381
|
-
}
|
374
|
+
var clientEdgeQueryResults = (_this$_clientEdgeQuer = (_this$_clientEdgeQuer2 = this._clientEdgeQueryResultsCache) === null || _this$_clientEdgeQuer2 === void 0 ? void 0 : _this$_clientEdgeQuer2.get(cacheKey)) !== null && _this$_clientEdgeQuer !== void 0 ? _this$_clientEdgeQuer : undefined;
|
375
|
+
if (clientEdgeQueryResults !== null && clientEdgeQueryResults !== void 0 && clientEdgeQueryResults.length) {
|
376
|
+
var queryResource = getQueryResourceForEnvironment(this._environment);
|
377
|
+
clientEdgeQueryResults.forEach(function (queryResult) {
|
378
|
+
disposables.push(queryResource.retain(queryResult));
|
379
|
+
});
|
382
380
|
}
|
383
381
|
return {
|
384
382
|
dispose: function dispose() {
|
@@ -459,7 +457,8 @@ var FragmentResourceImpl = /*#__PURE__*/function () {
|
|
459
457
|
seenRecords: currentSnapshot.seenRecords,
|
460
458
|
selector: currentSnapshot.selector,
|
461
459
|
missingRequiredFields: currentSnapshot.missingRequiredFields,
|
462
|
-
relayResolverErrors: currentSnapshot.relayResolverErrors
|
460
|
+
relayResolverErrors: currentSnapshot.relayResolverErrors,
|
461
|
+
errorResponseFields: currentSnapshot.errorResponseFields
|
463
462
|
};
|
464
463
|
if (updatedData !== renderData) {
|
465
464
|
var _result = getFragmentResult(cacheKey, updatedCurrentSnapshot, storeEpoch);
|
package/lib/relay-hooks/{useBlockingPaginationFragment.js → legacy/useBlockingPaginationFragment.js}
RENAMED
@@ -4,9 +4,9 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
4
4
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
5
5
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
6
6
|
var _excluded = ["disableStoreUpdates", "enableStoreUpdates"];
|
7
|
-
var useLoadMoreFunction = require('
|
7
|
+
var useLoadMoreFunction = require('../useLoadMoreFunction');
|
8
|
+
var useStaticFragmentNodeWarning = require('../useStaticFragmentNodeWarning');
|
8
9
|
var useRefetchableFragmentNode = require('./useRefetchableFragmentNode');
|
9
|
-
var useStaticFragmentNodeWarning = require('./useStaticFragmentNodeWarning');
|
10
10
|
var invariant = require('invariant');
|
11
11
|
var _require = require('react'),
|
12
12
|
useCallback = _require.useCallback,
|
@@ -1,9 +1,9 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
+
var useRelayEnvironment = require('../useRelayEnvironment');
|
4
|
+
var useUnsafeRef_DEPRECATED = require('../useUnsafeRef_DEPRECATED');
|
3
5
|
var _require = require('./FragmentResource'),
|
4
6
|
getFragmentResourceForEnvironment = _require.getFragmentResourceForEnvironment;
|
5
|
-
var useRelayEnvironment = require('./useRelayEnvironment');
|
6
|
-
var useUnsafeRef_DEPRECATED = require('./useUnsafeRef_DEPRECATED');
|
7
7
|
var _require2 = require('react'),
|
8
8
|
useEffect = _require2.useEffect,
|
9
9
|
useState = _require2.useState;
|
package/lib/relay-hooks/{useRefetchableFragmentNode.js → legacy/useRefetchableFragmentNode.js}
RENAMED
@@ -2,15 +2,15 @@
|
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
4
4
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
5
|
-
var
|
6
|
-
|
7
|
-
|
8
|
-
var
|
9
|
-
|
5
|
+
var ProfilerContext = require('../ProfilerContext');
|
6
|
+
var _require = require('../QueryResource'),
|
7
|
+
getQueryResourceForEnvironment = _require.getQueryResourceForEnvironment;
|
8
|
+
var useIsMountedRef = require('../useIsMountedRef');
|
9
|
+
var useQueryLoader = require('../useQueryLoader');
|
10
|
+
var useRelayEnvironment = require('../useRelayEnvironment');
|
11
|
+
var _require2 = require('./FragmentResource'),
|
12
|
+
getFragmentResourceForEnvironment = _require2.getFragmentResourceForEnvironment;
|
10
13
|
var useFragmentNode = require('./useFragmentNode');
|
11
|
-
var useIsMountedRef = require('./useIsMountedRef');
|
12
|
-
var useQueryLoader = require('./useQueryLoader');
|
13
|
-
var useRelayEnvironment = require('./useRelayEnvironment');
|
14
14
|
var invariant = require('invariant');
|
15
15
|
var _require3 = require('react'),
|
16
16
|
useCallback = _require3.useCallback,
|
@@ -3,7 +3,7 @@
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
4
4
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
5
5
|
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
|
6
|
-
var _require = require('
|
6
|
+
var _require = require('./QueryResource'),
|
7
7
|
getQueryResourceForEnvironment = _require.getQueryResourceForEnvironment;
|
8
8
|
var invariant = require('invariant');
|
9
9
|
var _require2 = require('relay-runtime'),
|
@@ -66,14 +66,16 @@ function getMissingClientEdges(state) {
|
|
66
66
|
}
|
67
67
|
function handlePotentialSnapshotErrorsForState(environment, state) {
|
68
68
|
if (state.kind === 'singular') {
|
69
|
-
|
69
|
+
var _state$snapshot$selec, _state$snapshot$selec2;
|
70
|
+
handlePotentialSnapshotErrors(environment, state.snapshot.missingRequiredFields, state.snapshot.relayResolverErrors, state.snapshot.errorResponseFields, (_state$snapshot$selec = (_state$snapshot$selec2 = state.snapshot.selector.node.metadata) === null || _state$snapshot$selec2 === void 0 ? void 0 : _state$snapshot$selec2.throwOnFieldError) !== null && _state$snapshot$selec !== void 0 ? _state$snapshot$selec : false);
|
70
71
|
} else if (state.kind === 'plural') {
|
71
72
|
var _iterator3 = (0, _createForOfIteratorHelper2["default"])(state.snapshots),
|
72
73
|
_step3;
|
73
74
|
try {
|
74
75
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
76
|
+
var _snapshot$selector$no, _snapshot$selector$no2;
|
75
77
|
var snapshot = _step3.value;
|
76
|
-
handlePotentialSnapshotErrors(environment, snapshot.missingRequiredFields, snapshot.relayResolverErrors);
|
78
|
+
handlePotentialSnapshotErrors(environment, snapshot.missingRequiredFields, snapshot.relayResolverErrors, snapshot.errorResponseFields, (_snapshot$selector$no = (_snapshot$selector$no2 = snapshot.selector.node.metadata) === null || _snapshot$selector$no2 === void 0 ? void 0 : _snapshot$selector$no2.throwOnFieldError) !== null && _snapshot$selector$no !== void 0 ? _snapshot$selector$no : false);
|
77
79
|
}
|
78
80
|
} catch (err) {
|
79
81
|
_iterator3.e(err);
|
@@ -118,7 +120,7 @@ function getFragmentState(environment, fragmentSelector) {
|
|
118
120
|
};
|
119
121
|
}
|
120
122
|
}
|
121
|
-
function
|
123
|
+
function readFragmentInternal(environment, fragmentNode, fragmentRef, hookDisplayName, queryOptions, fragmentKey) {
|
122
124
|
var _fragmentNode$metadat, _fragmentNode$metadat2;
|
123
125
|
var fragmentSelector = getSelector(fragmentNode, fragmentRef);
|
124
126
|
var isPlural = (fragmentNode === null || fragmentNode === void 0 ? void 0 : (_fragmentNode$metadat = fragmentNode.metadata) === null || _fragmentNode$metadat === void 0 ? void 0 : _fragmentNode$metadat.plural) === true;
|
@@ -179,4 +181,4 @@ function readFragmentInternal_EXPERIMENTAL(environment, fragmentNode, fragmentRe
|
|
179
181
|
clientEdgeQueries: clientEdgeQueries
|
180
182
|
};
|
181
183
|
}
|
182
|
-
module.exports =
|
184
|
+
module.exports = readFragmentInternal;
|
@@ -1,20 +1,18 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
var HooksImplementation = require('./HooksImplementation');
|
4
3
|
var _require = require('./loadQuery'),
|
5
4
|
useTrackLoadQueryInRender = _require.useTrackLoadQueryInRender;
|
6
|
-
var
|
5
|
+
var useFragmentInternal = require('./useFragmentInternal');
|
7
6
|
var useStaticFragmentNodeWarning = require('./useStaticFragmentNodeWarning');
|
8
7
|
var _require2 = require('react'),
|
9
8
|
useDebugValue = _require2.useDebugValue;
|
10
9
|
var _require3 = require('relay-runtime'),
|
11
10
|
getFragment = _require3.getFragment;
|
12
|
-
function
|
11
|
+
function useFragment(fragment, key) {
|
13
12
|
useTrackLoadQueryInRender();
|
14
13
|
var fragmentNode = getFragment(fragment);
|
15
14
|
useStaticFragmentNodeWarning(fragmentNode, 'first argument of useFragment()');
|
16
|
-
var
|
17
|
-
data = _useFragmentNode.data;
|
15
|
+
var data = useFragmentInternal(fragmentNode, key, 'useFragment()');
|
18
16
|
if (process.env.NODE_ENV !== "production") {
|
19
17
|
useDebugValue({
|
20
18
|
fragment: fragmentNode.name,
|
@@ -23,12 +21,4 @@ function useFragment_LEGACY(fragment, key) {
|
|
23
21
|
}
|
24
22
|
return data;
|
25
23
|
}
|
26
|
-
function useFragment(fragment, key) {
|
27
|
-
var impl = HooksImplementation.get();
|
28
|
-
if (impl) {
|
29
|
-
return impl.useFragment(fragment, key);
|
30
|
-
} else {
|
31
|
-
return useFragment_LEGACY(fragment, key);
|
32
|
-
}
|
33
|
-
}
|
34
24
|
module.exports = useFragment;
|