react-relay 17.0.0 → 18.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/ReactRelayContainerUtils.js.flow +2 -2
- package/ReactRelayContext.js +1 -1
- package/ReactRelayContext.js.flow +1 -1
- package/ReactRelayFragmentContainer.js.flow +2 -2
- package/ReactRelayPaginationContainer.js.flow +2 -2
- package/ReactRelayQueryRenderer.js.flow +1 -1
- package/ReactRelayQueryRendererContext.js.flow +1 -1
- package/ReactRelayRefetchContainer.js.flow +2 -2
- package/ReactRelayTypes.js.flow +45 -18
- package/__flowtests__/ReactRelayFragmentContainer-flowtest.js.flow +2 -2
- package/buildReactRelayContainer.js.flow +6 -5
- package/hooks.js +1 -1
- package/index.js +1 -1
- package/legacy.js +1 -1
- package/lib/relay-hooks/getConnectionState.js +47 -0
- package/lib/relay-hooks/legacy/FragmentResource.js +2 -6
- package/lib/relay-hooks/loadEntryPoint.js +8 -5
- package/lib/relay-hooks/loadQuery.js +2 -14
- package/lib/relay-hooks/readFragmentInternal.js +2 -4
- package/lib/relay-hooks/useEntryPointLoader.js +5 -8
- package/lib/relay-hooks/useFragment.js +4 -7
- package/lib/relay-hooks/useFragmentInternal.js +6 -484
- package/lib/relay-hooks/useFragmentInternal_CURRENT.js +477 -0
- package/lib/relay-hooks/useFragmentInternal_EXPERIMENTAL.js +499 -0
- package/lib/relay-hooks/useLazyLoadQuery.js +2 -5
- package/lib/relay-hooks/useLoadMoreFunction.js +10 -43
- package/lib/relay-hooks/useLoadMoreFunction_EXPERIMENTAL.js +130 -0
- package/lib/relay-hooks/usePreloadedQuery.js +6 -9
- package/lib/relay-hooks/useQueryLoader.js +9 -3
- package/lib/relay-hooks/useQueryLoader_EXPERIMENTAL.js +120 -0
- package/multi-actor/ActorChange.js.flow +1 -1
- package/package.json +3 -3
- package/react-relay-hooks.js +2 -2
- package/react-relay-hooks.min.js +2 -2
- package/react-relay-legacy.js +1 -1
- package/react-relay-legacy.min.js +1 -1
- package/react-relay.js +2 -2
- package/react-relay.min.js +2 -2
- package/relay-hooks/EntryPointTypes.flow.js.flow +35 -12
- package/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js.flow +8 -4
- package/relay-hooks/MatchContainer.js.flow +1 -1
- package/relay-hooks/ProfilerContext.js.flow +1 -1
- package/relay-hooks/__flowtests__/EntryPointTypes/ExtractQueryTypes-flowtest.js.flow +43 -0
- package/relay-hooks/getConnectionState.js.flow +97 -0
- package/relay-hooks/legacy/FragmentResource.js.flow +2 -13
- package/relay-hooks/loadEntryPoint.js.flow +10 -4
- package/relay-hooks/loadQuery.js.flow +4 -28
- package/relay-hooks/prepareEntryPoint_DEPRECATED.js.flow +4 -1
- package/relay-hooks/readFragmentInternal.js.flow +1 -10
- package/relay-hooks/useEntryPointLoader.js.flow +3 -4
- package/relay-hooks/useFragment.js.flow +0 -5
- package/relay-hooks/useFragmentInternal.js.flow +19 -643
- package/relay-hooks/useFragmentInternal_CURRENT.js.flow +656 -0
- package/relay-hooks/useFragmentInternal_EXPERIMENTAL.js.flow +718 -0
- package/relay-hooks/useLazyLoadQuery.js.flow +0 -5
- package/relay-hooks/useLoadMoreFunction.js.flow +14 -80
- package/relay-hooks/useLoadMoreFunction_EXPERIMENTAL.js.flow +280 -0
- package/relay-hooks/usePaginationFragment.js.flow +1 -1
- package/relay-hooks/usePreloadedQuery.js.flow +0 -5
- package/relay-hooks/useQueryLoader.js.flow +28 -5
- package/relay-hooks/useQueryLoader_EXPERIMENTAL.js.flow +253 -0
@@ -11,11 +11,11 @@
|
|
11
11
|
|
12
12
|
'use strict';
|
13
13
|
|
14
|
-
function getComponentName(component: React
|
14
|
+
function getComponentName(component: React.ComponentType<any>): string {
|
15
15
|
return component.displayName || component.name || 'Component';
|
16
16
|
}
|
17
17
|
|
18
|
-
function getContainerName(Component: React
|
18
|
+
function getContainerName(Component: React.ComponentType<any>): string {
|
19
19
|
return 'Relay(' + getComponentName(Component) + ')';
|
20
20
|
}
|
21
21
|
|
package/ReactRelayContext.js
CHANGED
@@ -51,7 +51,7 @@ function createContainerWithFragments<
|
|
51
51
|
Component: TComponent,
|
52
52
|
fragments: FragmentMap,
|
53
53
|
): React.ComponentType<
|
54
|
-
$RelayProps<React
|
54
|
+
$RelayProps<React.ElementConfig<TComponent>, RelayProp>,
|
55
55
|
> {
|
56
56
|
const containerName = getContainerName(Component);
|
57
57
|
|
@@ -275,7 +275,7 @@ function createContainer<
|
|
275
275
|
Component: TComponent,
|
276
276
|
fragmentSpec: GeneratedNodeMap,
|
277
277
|
): React.AbstractComponent<
|
278
|
-
$RelayProps<React
|
278
|
+
$RelayProps<React.ElementConfig<TComponent>, RelayProp>,
|
279
279
|
Instance,
|
280
280
|
> {
|
281
281
|
// $FlowFixMe[incompatible-return]
|
@@ -325,7 +325,7 @@ function createContainerWithFragments<
|
|
325
325
|
fragments: FragmentMap,
|
326
326
|
connectionConfig: ConnectionConfig,
|
327
327
|
): React.ComponentType<
|
328
|
-
$RelayProps<React
|
328
|
+
$RelayProps<React.ElementConfig<TComponent>, RelayPaginationProp>,
|
329
329
|
> {
|
330
330
|
const componentName = getComponentName(Component);
|
331
331
|
const containerName = getContainerName(Component);
|
@@ -942,7 +942,7 @@ function createContainer<Props: {...}, TComponent: React.ComponentType<Props>>(
|
|
942
942
|
fragmentSpec: GeneratedNodeMap,
|
943
943
|
connectionConfig: ConnectionConfig,
|
944
944
|
): React.ComponentType<
|
945
|
-
$RelayProps<React
|
945
|
+
$RelayProps<React.ElementConfig<TComponent>, RelayPaginationProp>,
|
946
946
|
> {
|
947
947
|
// $FlowFixMe[incompatible-return]
|
948
948
|
return buildReactRelayContainer(
|
@@ -263,7 +263,7 @@ class ReactRelayQueryRenderer extends React.Component<Props, State> {
|
|
263
263
|
});
|
264
264
|
};
|
265
265
|
|
266
|
-
render(): React.
|
266
|
+
render(): React.MixedElement {
|
267
267
|
const {renderProps, relayContext} = this.state;
|
268
268
|
// Note that the root fragment results in `renderProps.props` is already
|
269
269
|
// frozen by the store; this call is to freeze the renderProps object and
|
@@ -16,4 +16,4 @@ export type ReactRelayQueryRendererContext = {rootIsQueryRenderer: boolean};
|
|
16
16
|
|
17
17
|
module.exports = (React.createContext({
|
18
18
|
rootIsQueryRenderer: false,
|
19
|
-
}): React
|
19
|
+
}): React.Context<ReactRelayQueryRendererContext | null>);
|
@@ -75,7 +75,7 @@ function createContainerWithFragments<
|
|
75
75
|
fragments: FragmentMap,
|
76
76
|
taggedNode: GraphQLTaggedNode,
|
77
77
|
): React.ComponentType<
|
78
|
-
$RelayProps<React
|
78
|
+
$RelayProps<React.ElementConfig<TComponent>, RelayRefetchProp>,
|
79
79
|
> {
|
80
80
|
const containerName = getContainerName(Component);
|
81
81
|
|
@@ -491,7 +491,7 @@ function createContainer<Props: {...}, TComponent: React.ComponentType<Props>>(
|
|
491
491
|
fragmentSpec: GeneratedNodeMap,
|
492
492
|
taggedNode: GraphQLTaggedNode,
|
493
493
|
): React.ComponentType<
|
494
|
-
$RelayProps<React
|
494
|
+
$RelayProps<React.ElementConfig<TComponent>, RelayRefetchProp>,
|
495
495
|
> {
|
496
496
|
// $FlowFixMe[incompatible-return]
|
497
497
|
return buildReactRelayContainer(
|
package/ReactRelayTypes.js.flow
CHANGED
@@ -103,28 +103,55 @@ export type $FragmentRef<T> = {
|
|
103
103
|
*/
|
104
104
|
// prettier-ignore
|
105
105
|
// $FlowFixMe[extra-type-arg] xplat redux flow type error
|
106
|
-
|
107
|
-
|
108
|
-
$Diff<Props, { relay: RelayPropT | void, ... }>,
|
109
|
-
& (<T: { +$fragmentType: empty, ... }>( T) => T)
|
110
|
-
& (<T: { +$fragmentType: empty, ... }>(?T) => ?T)
|
111
|
-
& (<TFragmentType: FragmentType, T: { +$fragmentType: TFragmentType, ... }>( T ) => $FragmentRef<T> )
|
112
|
-
& (<TFragmentType: FragmentType, T: { +$fragmentType: TFragmentType, ... }>(? T ) => ? $FragmentRef<T> )
|
113
|
-
& (<TFragmentType: FragmentType, T: { +$fragmentType: TFragmentType, ... }>( $ReadOnlyArray< T>) => $ReadOnlyArray< $FragmentRef<T>>)
|
114
|
-
& (<TFragmentType: FragmentType, T: { +$fragmentType: TFragmentType, ... }>(?$ReadOnlyArray< T>) => ?$ReadOnlyArray< $FragmentRef<T>>)
|
115
|
-
& (<TFragmentType: FragmentType, T: { +$fragmentType: TFragmentType, ... }>( $ReadOnlyArray<?T>) => $ReadOnlyArray<?$FragmentRef<T>>)
|
116
|
-
& (<TFragmentType: FragmentType, T: { +$fragmentType: TFragmentType, ... }>(?$ReadOnlyArray<?T>) => ?$ReadOnlyArray<?$FragmentRef<T>>)
|
117
|
-
& (<T>(T) => T),
|
106
|
+
export type $RelayProps<Props, RelayPropT = RelayProp> = MapRelayProps<
|
107
|
+
$Diff<Props, {relay: RelayPropT | void, ...}>,
|
118
108
|
>;
|
119
109
|
|
120
|
-
|
121
|
-
|
110
|
+
type MapRelayProps<Props> = {[K in keyof Props]: MapRelayProp<Props[K]>};
|
111
|
+
type MapRelayProp<T> = [+t: T] extends [+t: {+$fragmentType: empty, ...}]
|
112
|
+
? T
|
113
|
+
: [+t: T] extends [+t: ?{+$fragmentType: empty, ...}]
|
114
|
+
? ?T
|
115
|
+
: [+t: T] extends [+t: {+$fragmentType: FragmentType, ...}]
|
116
|
+
? $FragmentRef<T>
|
117
|
+
: [+t: T] extends [+t: ?{+$fragmentType: FragmentType, ...}]
|
118
|
+
? ?$FragmentRef<$NonMaybeType<T>>
|
119
|
+
: [+t: T] extends [
|
120
|
+
+t: $ReadOnlyArray<
|
121
|
+
infer V extends {+$fragmentType: FragmentType, ...},
|
122
|
+
>,
|
123
|
+
]
|
124
|
+
? $ReadOnlyArray<$FragmentRef<V>>
|
125
|
+
: [+t: T] extends [
|
126
|
+
+t: ?$ReadOnlyArray<
|
127
|
+
infer V extends {+$fragmentType: FragmentType, ...},
|
128
|
+
>,
|
129
|
+
]
|
130
|
+
? ?$ReadOnlyArray<$FragmentRef<V>>
|
131
|
+
: [+t: T] extends [
|
132
|
+
+t: $ReadOnlyArray<?infer V extends {
|
133
|
+
+$fragmentType: FragmentType,
|
134
|
+
...
|
135
|
+
}>,
|
136
|
+
]
|
137
|
+
? $ReadOnlyArray<?$FragmentRef<$NonMaybeType<V>>>
|
138
|
+
: [+t: T] extends [
|
139
|
+
+t: ?$ReadOnlyArray<?infer V extends {
|
140
|
+
+$fragmentType: FragmentType,
|
141
|
+
...
|
142
|
+
}>,
|
143
|
+
]
|
144
|
+
? ?$ReadOnlyArray<?$FragmentRef<$NonMaybeType<V>>>
|
145
|
+
: T;
|
146
|
+
|
147
|
+
export type RelayFragmentContainer<TComponent> = React.ComponentType<
|
148
|
+
$RelayProps<React.ElementConfig<TComponent>, RelayProp>,
|
122
149
|
>;
|
123
150
|
|
124
|
-
export type RelayPaginationContainer<TComponent> = React
|
125
|
-
$RelayProps<React
|
151
|
+
export type RelayPaginationContainer<TComponent> = React.ComponentType<
|
152
|
+
$RelayProps<React.ElementConfig<TComponent>, RelayPaginationProp>,
|
126
153
|
>;
|
127
154
|
|
128
|
-
export type RelayRefetchContainer<TComponent> = React
|
129
|
-
$RelayProps<React
|
155
|
+
export type RelayRefetchContainer<TComponent> = React.ComponentType<
|
156
|
+
$RelayProps<React.ElementConfig<TComponent>, RelayRefetchProp>,
|
130
157
|
>;
|
@@ -50,7 +50,7 @@ class BarComponent extends React.Component<{
|
|
50
50
|
getNum(): number {
|
51
51
|
return 42;
|
52
52
|
}
|
53
|
-
render(): React.
|
53
|
+
render(): React.MixedElement {
|
54
54
|
const reqLen = this.props.requiredProp.length;
|
55
55
|
const optionalProp = this.props.optionalProp;
|
56
56
|
|
@@ -137,7 +137,7 @@ module.exports = {
|
|
137
137
|
/** $FlowExpectedError: Bar `getNum` gives number, but `getString` assumes string **/
|
138
138
|
return bad ? 'not good' : ok;
|
139
139
|
}
|
140
|
-
render(): React.
|
140
|
+
render(): React.MixedElement {
|
141
141
|
return (
|
142
142
|
<Bar
|
143
143
|
componentRef={(ref: empty) => {
|
@@ -28,15 +28,15 @@ const {getFragment} = require('relay-runtime');
|
|
28
28
|
const {useContext} = React;
|
29
29
|
|
30
30
|
type ContainerCreator = (
|
31
|
-
Component: React
|
31
|
+
Component: React.ComponentType<any>,
|
32
32
|
fragments: FragmentMap,
|
33
|
-
) => React
|
33
|
+
) => React.ComponentType<any>;
|
34
34
|
|
35
35
|
/**
|
36
36
|
* Helper to create the Relay HOCs with ref forwarding, setting the displayName
|
37
37
|
* and reading the React context.
|
38
38
|
*/
|
39
|
-
function buildReactRelayContainer<TBase: React
|
39
|
+
function buildReactRelayContainer<TBase: React.ComponentType<any>>(
|
40
40
|
ComponentClass: TBase,
|
41
41
|
fragmentSpec: GeneratedNodeMap,
|
42
42
|
createContainerWithFragments: ContainerCreator,
|
@@ -55,8 +55,8 @@ function buildReactRelayContainer<TBase: React$ComponentType<any>>(
|
|
55
55
|
function ForwardRef(
|
56
56
|
props: any,
|
57
57
|
ref:
|
58
|
-
| ((null | React
|
59
|
-
| {-current: null | React
|
58
|
+
| ((null | React.ElementRef<TBase>) => mixed)
|
59
|
+
| {-current: null | React.ElementRef<TBase>, ...},
|
60
60
|
) {
|
61
61
|
// $FlowFixMe[react-rule-hook]
|
62
62
|
const context = useContext(ReactRelayContext);
|
@@ -82,6 +82,7 @@ function buildReactRelayContainer<TBase: React$ComponentType<any>>(
|
|
82
82
|
);
|
83
83
|
}
|
84
84
|
ForwardRef.displayName = containerName;
|
85
|
+
// $FlowFixMe[incompatible-call]
|
85
86
|
const ForwardContainer = React.forwardRef(ForwardRef);
|
86
87
|
|
87
88
|
if (__DEV__) {
|
package/hooks.js
CHANGED
package/index.js
CHANGED
package/legacy.js
CHANGED
@@ -0,0 +1,47 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var invariant = require('invariant');
|
4
|
+
var _require = require('relay-runtime'),
|
5
|
+
ConnectionInterface = _require.ConnectionInterface,
|
6
|
+
getValueAtPath = _require.getValueAtPath;
|
7
|
+
function getConnectionState(direction, fragmentNode, fragmentData, connectionPathInFragmentData) {
|
8
|
+
var _pageInfo$END_CURSOR, _pageInfo$START_CURSO;
|
9
|
+
var _ConnectionInterface$ = ConnectionInterface.get(),
|
10
|
+
EDGES = _ConnectionInterface$.EDGES,
|
11
|
+
PAGE_INFO = _ConnectionInterface$.PAGE_INFO,
|
12
|
+
HAS_NEXT_PAGE = _ConnectionInterface$.HAS_NEXT_PAGE,
|
13
|
+
HAS_PREV_PAGE = _ConnectionInterface$.HAS_PREV_PAGE,
|
14
|
+
END_CURSOR = _ConnectionInterface$.END_CURSOR,
|
15
|
+
START_CURSOR = _ConnectionInterface$.START_CURSOR;
|
16
|
+
var connection = getValueAtPath(fragmentData, connectionPathInFragmentData);
|
17
|
+
if (connection == null) {
|
18
|
+
return {
|
19
|
+
cursor: null,
|
20
|
+
hasMore: false
|
21
|
+
};
|
22
|
+
}
|
23
|
+
!(typeof connection === 'object') ? process.env.NODE_ENV !== "production" ? invariant(false, 'Relay: Expected connection in fragment `%s` to have been `null`, or ' + 'a plain object with %s and %s properties. Instead got `%s`.', fragmentNode.name, EDGES, PAGE_INFO, connection) : invariant(false) : void 0;
|
24
|
+
var edges = connection[EDGES];
|
25
|
+
var pageInfo = connection[PAGE_INFO];
|
26
|
+
if (edges == null || pageInfo == null) {
|
27
|
+
return {
|
28
|
+
cursor: null,
|
29
|
+
hasMore: false
|
30
|
+
};
|
31
|
+
}
|
32
|
+
!Array.isArray(edges) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Relay: Expected connection in fragment `%s` to have a plural `%s` field. ' + 'Instead got `%s`.', fragmentNode.name, EDGES, edges) : invariant(false) : void 0;
|
33
|
+
!(typeof pageInfo === 'object') ? process.env.NODE_ENV !== "production" ? invariant(false, 'Relay: Expected connection in fragment `%s` to have a `%s` field. ' + 'Instead got `%s`.', fragmentNode.name, PAGE_INFO, pageInfo) : invariant(false) : void 0;
|
34
|
+
var cursor = direction === 'forward' ? (_pageInfo$END_CURSOR = pageInfo[END_CURSOR]) !== null && _pageInfo$END_CURSOR !== void 0 ? _pageInfo$END_CURSOR : null : (_pageInfo$START_CURSO = pageInfo[START_CURSOR]) !== null && _pageInfo$START_CURSO !== void 0 ? _pageInfo$START_CURSO : null;
|
35
|
+
!(cursor === null || typeof cursor === 'string') ? process.env.NODE_ENV !== "production" ? invariant(false, 'Relay: Expected page info for connection in fragment `%s` to have a ' + 'valid `%s`. Instead got `%s`.', fragmentNode.name, START_CURSOR, cursor) : invariant(false) : void 0;
|
36
|
+
var hasMore;
|
37
|
+
if (direction === 'forward') {
|
38
|
+
hasMore = cursor != null && pageInfo[HAS_NEXT_PAGE] === true;
|
39
|
+
} else {
|
40
|
+
hasMore = cursor != null && pageInfo[HAS_PREV_PAGE] === true;
|
41
|
+
}
|
42
|
+
return {
|
43
|
+
cursor: cursor,
|
44
|
+
hasMore: hasMore
|
45
|
+
};
|
46
|
+
}
|
47
|
+
module.exports = getConnectionState;
|
@@ -309,12 +309,10 @@ var FragmentResourceImpl = /*#__PURE__*/function () {
|
|
309
309
|
var _this4 = this;
|
310
310
|
if (Array.isArray(snapshot)) {
|
311
311
|
snapshot.forEach(function (s) {
|
312
|
-
|
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);
|
312
|
+
handlePotentialSnapshotErrors(_this4._environment, s.errorResponseFields);
|
314
313
|
});
|
315
314
|
} else {
|
316
|
-
|
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);
|
315
|
+
handlePotentialSnapshotErrors(this._environment, snapshot.errorResponseFields);
|
318
316
|
}
|
319
317
|
};
|
320
318
|
_proto2.readSpec = function readSpec(fragmentNodes, fragmentRefs, componentDisplayName) {
|
@@ -456,8 +454,6 @@ var FragmentResourceImpl = /*#__PURE__*/function () {
|
|
456
454
|
missingLiveResolverFields: currentSnapshot.missingLiveResolverFields,
|
457
455
|
seenRecords: currentSnapshot.seenRecords,
|
458
456
|
selector: currentSnapshot.selector,
|
459
|
-
missingRequiredFields: currentSnapshot.missingRequiredFields,
|
460
|
-
relayResolverErrors: currentSnapshot.relayResolverErrors,
|
461
457
|
errorResponseFields: currentSnapshot.errorResponseFields
|
462
458
|
};
|
463
459
|
if (updatedData !== renderData) {
|
@@ -16,11 +16,14 @@ function loadEntryPoint(environmentProvider, entryPoint, entryPointParams) {
|
|
16
16
|
if (queries != null) {
|
17
17
|
var queriesPropNames = Object.keys(queries);
|
18
18
|
queriesPropNames.forEach(function (queryPropName) {
|
19
|
-
var
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
var query = queries[queryPropName];
|
20
|
+
if (query == null) {
|
21
|
+
return;
|
22
|
+
}
|
23
|
+
var environmentProviderOptions = query.environmentProviderOptions,
|
24
|
+
options = query.options,
|
25
|
+
parameters = query.parameters,
|
26
|
+
variables = query.variables;
|
24
27
|
var environment = environmentProvider.getEnvironment(environmentProviderOptions);
|
25
28
|
preloadedQueries[queryPropName] = loadQuery(environment, parameters, variables, {
|
26
29
|
fetchPolicy: options === null || options === void 0 ? void 0 : options.fetchPolicy,
|
@@ -3,7 +3,6 @@
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
4
4
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
5
5
|
var invariant = require('invariant');
|
6
|
-
var React = require('react');
|
7
6
|
var _require = require('relay-runtime'),
|
8
7
|
fetchQueryDeduped = _require.__internal.fetchQueryDeduped,
|
9
8
|
Observable = _require.Observable,
|
@@ -13,19 +12,9 @@ var _require = require('relay-runtime'),
|
|
13
12
|
createOperationDescriptor = _require.createOperationDescriptor,
|
14
13
|
getRequest = _require.getRequest,
|
15
14
|
getRequestIdentifier = _require.getRequestIdentifier;
|
16
|
-
var warning = require("fbjs/lib/warning");
|
17
|
-
var RenderDispatcher = null;
|
18
15
|
var fetchKey = 100001;
|
19
|
-
function useTrackLoadQueryInRender() {
|
20
|
-
if (RenderDispatcher === null) {
|
21
|
-
var _React$__SECRET_INTER, _React$__SECRET_INTER2;
|
22
|
-
RenderDispatcher = (_React$__SECRET_INTER = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED) === null || _React$__SECRET_INTER === void 0 ? void 0 : (_React$__SECRET_INTER2 = _React$__SECRET_INTER.ReactCurrentDispatcher) === null || _React$__SECRET_INTER2 === void 0 ? void 0 : _React$__SECRET_INTER2.current;
|
23
|
-
}
|
24
|
-
}
|
25
16
|
function loadQuery(environment, preloadableRequest, variables, options, environmentProviderOptions) {
|
26
|
-
var
|
27
|
-
var CurrentDispatcher = (_React$__SECRET_INTER3 = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED) === null || _React$__SECRET_INTER3 === void 0 ? void 0 : (_React$__SECRET_INTER4 = _React$__SECRET_INTER3.ReactCurrentDispatcher) === null || _React$__SECRET_INTER4 === void 0 ? void 0 : _React$__SECRET_INTER4.current;
|
28
|
-
process.env.NODE_ENV !== "production" ? warning(RenderDispatcher == null || CurrentDispatcher !== RenderDispatcher, 'Relay: `%s` should not be called inside a React render function.', (_options$__nameForWar = options === null || options === void 0 ? void 0 : options.__nameForWarning) !== null && _options$__nameForWar !== void 0 ? _options$__nameForWar : 'loadQuery') : void 0;
|
17
|
+
var _options$fetchPolicy;
|
29
18
|
fetchKey++;
|
30
19
|
var fetchPolicy = (_options$fetchPolicy = options === null || options === void 0 ? void 0 : options.fetchPolicy) !== null && _options$fetchPolicy !== void 0 ? _options$fetchPolicy : 'store-or-network';
|
31
20
|
var networkCacheConfig = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, options === null || options === void 0 ? void 0 : options.networkCacheConfig), {}, {
|
@@ -201,6 +190,5 @@ function loadQuery(environment, preloadableRequest, variables, options, environm
|
|
201
190
|
};
|
202
191
|
}
|
203
192
|
module.exports = {
|
204
|
-
loadQuery: loadQuery
|
205
|
-
useTrackLoadQueryInRender: useTrackLoadQueryInRender
|
193
|
+
loadQuery: loadQuery
|
206
194
|
};
|
@@ -66,16 +66,14 @@ function getMissingClientEdges(state) {
|
|
66
66
|
}
|
67
67
|
function handlePotentialSnapshotErrorsForState(environment, state) {
|
68
68
|
if (state.kind === 'singular') {
|
69
|
-
|
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);
|
69
|
+
handlePotentialSnapshotErrors(environment, state.snapshot.errorResponseFields);
|
71
70
|
} else if (state.kind === 'plural') {
|
72
71
|
var _iterator3 = (0, _createForOfIteratorHelper2["default"])(state.snapshots),
|
73
72
|
_step3;
|
74
73
|
try {
|
75
74
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
76
|
-
var _snapshot$selector$no, _snapshot$selector$no2;
|
77
75
|
var snapshot = _step3.value;
|
78
|
-
handlePotentialSnapshotErrors(environment, snapshot.
|
76
|
+
handlePotentialSnapshotErrors(environment, snapshot.errorResponseFields);
|
79
77
|
}
|
80
78
|
} catch (err) {
|
81
79
|
_iterator3.e(err);
|
@@ -3,20 +3,17 @@
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
4
4
|
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
|
5
5
|
var loadEntryPoint = require('./loadEntryPoint');
|
6
|
-
var _require = require('./loadQuery'),
|
7
|
-
useTrackLoadQueryInRender = _require.useTrackLoadQueryInRender;
|
8
6
|
var useIsMountedRef = require('./useIsMountedRef');
|
9
|
-
var
|
10
|
-
useCallback =
|
11
|
-
useEffect =
|
12
|
-
useRef =
|
13
|
-
useState =
|
7
|
+
var _require = require('react'),
|
8
|
+
useCallback = _require.useCallback,
|
9
|
+
useEffect = _require.useEffect,
|
10
|
+
useRef = _require.useRef,
|
11
|
+
useState = _require.useState;
|
14
12
|
var initialNullEntryPointReferenceState = {
|
15
13
|
kind: 'NullEntryPointReference'
|
16
14
|
};
|
17
15
|
function useLoadEntryPoint(environmentProvider, entryPoint, options) {
|
18
16
|
var _options$TEST_ONLY__i, _options$TEST_ONLY__i2, _options$TEST_ONLY__i3, _options$TEST_ONLY__i4;
|
19
|
-
useTrackLoadQueryInRender();
|
20
17
|
var initialEntryPointReferenceInternal = (_options$TEST_ONLY__i = options === null || options === void 0 ? void 0 : (_options$TEST_ONLY__i2 = options.TEST_ONLY__initialEntryPointData) === null || _options$TEST_ONLY__i2 === void 0 ? void 0 : _options$TEST_ONLY__i2.entryPointReference) !== null && _options$TEST_ONLY__i !== void 0 ? _options$TEST_ONLY__i : initialNullEntryPointReferenceState;
|
21
18
|
var initialEntryPointParamsInternal = (_options$TEST_ONLY__i3 = options === null || options === void 0 ? void 0 : (_options$TEST_ONLY__i4 = options.TEST_ONLY__initialEntryPointData) === null || _options$TEST_ONLY__i4 === void 0 ? void 0 : _options$TEST_ONLY__i4.entryPointParams) !== null && _options$TEST_ONLY__i3 !== void 0 ? _options$TEST_ONLY__i3 : null;
|
22
19
|
var isMountedRef = useIsMountedRef();
|
@@ -1,15 +1,12 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
var _require = require('./loadQuery'),
|
4
|
-
useTrackLoadQueryInRender = _require.useTrackLoadQueryInRender;
|
5
3
|
var useFragmentInternal = require('./useFragmentInternal');
|
6
4
|
var useStaticFragmentNodeWarning = require('./useStaticFragmentNodeWarning');
|
7
|
-
var
|
8
|
-
useDebugValue =
|
9
|
-
var
|
10
|
-
getFragment =
|
5
|
+
var _require = require('react'),
|
6
|
+
useDebugValue = _require.useDebugValue;
|
7
|
+
var _require2 = require('relay-runtime'),
|
8
|
+
getFragment = _require2.getFragment;
|
11
9
|
function useFragment(fragment, key) {
|
12
|
-
useTrackLoadQueryInRender();
|
13
10
|
var fragmentNode = getFragment(fragment);
|
14
11
|
useStaticFragmentNodeWarning(fragmentNode, 'first argument of useFragment()');
|
15
12
|
var data = useFragmentInternal(fragmentNode, key, 'useFragment()');
|