relay-runtime 0.0.0-main-da757ca9 → 0.0.0-main-ee99ea4b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +1 -1
- package/lib/store/RelayConcreteVariables.js +7 -0
- package/lib/store/RelayReader.js +16 -1
- package/package.json +1 -1
- package/relay-runtime.js +2 -2
- package/relay-runtime.min.js +2 -2
- package/store/RelayConcreteVariables.js.flow +11 -2
- package/store/RelayReader.js.flow +26 -0
- package/util/ReaderNode.js.flow +4 -0
|
@@ -15,7 +15,10 @@ import type {
|
|
|
15
15
|
NormalizationLocalArgumentDefinition,
|
|
16
16
|
NormalizationOperation,
|
|
17
17
|
} from '../util/NormalizationNode';
|
|
18
|
-
import type {
|
|
18
|
+
import type {
|
|
19
|
+
ReaderFragment,
|
|
20
|
+
ReaderInlineDataFragmentSpread,
|
|
21
|
+
} from '../util/ReaderNode';
|
|
19
22
|
import type {ProvidedVariablesType} from '../util/RelayConcreteNode';
|
|
20
23
|
import type {Variables} from '../util/RelayRuntimeTypes';
|
|
21
24
|
|
|
@@ -30,10 +33,16 @@ const invariant = require('invariant');
|
|
|
30
33
|
* Note that this is analagous to determining function arguments given a function call.
|
|
31
34
|
*/
|
|
32
35
|
function getFragmentVariables(
|
|
33
|
-
fragment: ReaderFragment,
|
|
36
|
+
fragment: ReaderFragment | ReaderInlineDataFragmentSpread,
|
|
34
37
|
rootVariables: Variables,
|
|
35
38
|
argumentVariables: Variables,
|
|
36
39
|
): Variables {
|
|
40
|
+
// TODO: Support for legacy ReaderInlineDataFragmentSpread nodes.
|
|
41
|
+
// Remove this once all we've updated the ReaderInlineDataFragmentSpread
|
|
42
|
+
// type to indicate that all compiled artifacts have been updated.
|
|
43
|
+
if (fragment.argumentDefinitions == null) {
|
|
44
|
+
return argumentVariables;
|
|
45
|
+
}
|
|
37
46
|
let variables;
|
|
38
47
|
fragment.argumentDefinitions.forEach(definition => {
|
|
39
48
|
if (argumentVariables.hasOwnProperty(definition.name)) {
|
|
@@ -70,6 +70,7 @@ const {
|
|
|
70
70
|
} = require('../util/RelayConcreteNode');
|
|
71
71
|
const RelayFeatureFlags = require('../util/RelayFeatureFlags');
|
|
72
72
|
const ClientID = require('./ClientID');
|
|
73
|
+
const RelayConcreteVariables = require('./RelayConcreteVariables');
|
|
73
74
|
const RelayModernRecord = require('./RelayModernRecord');
|
|
74
75
|
const {getReactFlightClientResponse} = require('./RelayStoreReactFlightUtils');
|
|
75
76
|
const {
|
|
@@ -789,6 +790,7 @@ class RelayReader {
|
|
|
789
790
|
data: SelectorData,
|
|
790
791
|
): ?mixed {
|
|
791
792
|
const applicationName = field.alias ?? field.name;
|
|
793
|
+
getStorageKey(field, this._variables);
|
|
792
794
|
const storageKey = getStorageKey(field, this._variables);
|
|
793
795
|
const linkedID = RelayModernRecord.getLinkedRecordID(record, storageKey);
|
|
794
796
|
if (linkedID == null) {
|
|
@@ -1109,11 +1111,35 @@ class RelayReader {
|
|
|
1109
1111
|
const inlineData = {};
|
|
1110
1112
|
const parentFragmentName = this._fragmentName;
|
|
1111
1113
|
this._fragmentName = fragmentSpreadOrFragment.name;
|
|
1114
|
+
|
|
1115
|
+
const parentVariables = this._variables;
|
|
1116
|
+
|
|
1117
|
+
// We only want to update `this._variables` if we have compiler artifacts that support it.
|
|
1118
|
+
// Until we've rolled out the compiler portion of this change, we need to check at runtime.
|
|
1119
|
+
if (fragmentSpreadOrFragment.argumentDefinitions != null) {
|
|
1120
|
+
// If the inline fragment spread has arguments, we need to temporarily
|
|
1121
|
+
// switch this._variables to include the fragment spread's arguments
|
|
1122
|
+
// for the duration of its traversal.
|
|
1123
|
+
const argumentVariables = fragmentSpreadOrFragment.args
|
|
1124
|
+
? getArgumentValues(fragmentSpreadOrFragment.args, this._variables)
|
|
1125
|
+
: {};
|
|
1126
|
+
|
|
1127
|
+
this._variables = RelayConcreteVariables.getFragmentVariables(
|
|
1128
|
+
fragmentSpreadOrFragment,
|
|
1129
|
+
this._owner.variables,
|
|
1130
|
+
argumentVariables,
|
|
1131
|
+
);
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1112
1134
|
this._traverseSelections(
|
|
1113
1135
|
fragmentSpreadOrFragment.selections,
|
|
1114
1136
|
record,
|
|
1115
1137
|
inlineData,
|
|
1116
1138
|
);
|
|
1139
|
+
|
|
1140
|
+
// Put the parent variables back
|
|
1141
|
+
this._variables = parentVariables;
|
|
1142
|
+
|
|
1117
1143
|
this._fragmentName = parentFragmentName;
|
|
1118
1144
|
// $FlowFixMe[cannot-write] - writing into read-only field
|
|
1119
1145
|
fragmentPointers[fragmentSpreadOrFragment.name] = inlineData;
|
package/util/ReaderNode.js.flow
CHANGED
|
@@ -31,6 +31,10 @@ export type ReaderInlineDataFragmentSpread = {
|
|
|
31
31
|
+kind: 'InlineDataFragmentSpread',
|
|
32
32
|
+name: string,
|
|
33
33
|
+selections: $ReadOnlyArray<ReaderSelection>,
|
|
34
|
+
// TODO: T123948544 Mark both of these as non-optional once the compiler
|
|
35
|
+
// changes have rolled out.
|
|
36
|
+
+args?: ?$ReadOnlyArray<ReaderArgument>,
|
|
37
|
+
+argumentDefinitions?: $ReadOnlyArray<ReaderArgumentDefinition>,
|
|
34
38
|
};
|
|
35
39
|
|
|
36
40
|
export type ReaderFragment = {
|