relay-runtime 0.0.0-main-dcf2098c → 0.0.0-main-e8bf0b68
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
CHANGED
|
@@ -37,7 +37,7 @@ function readUpdatableQuery_EXPERIMENTAL(query, variables, proxy) {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
function updateProxyFromSelections(mutableUpdatableProxy, recordProxy, queryVariables, selections, root) {
|
|
40
|
-
var _selection$
|
|
40
|
+
var _selection$alias3;
|
|
41
41
|
|
|
42
42
|
var _iterator = (0, _createForOfIteratorHelper2["default"])(selections),
|
|
43
43
|
_step;
|
|
@@ -48,21 +48,23 @@ function updateProxyFromSelections(mutableUpdatableProxy, recordProxy, queryVari
|
|
|
48
48
|
|
|
49
49
|
switch (selection.kind) {
|
|
50
50
|
case 'LinkedField':
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
51
|
+
if (selection.plural) {
|
|
52
|
+
Object.defineProperty(mutableUpdatableProxy, (_selection$alias = selection.alias) !== null && _selection$alias !== void 0 ? _selection$alias : selection.name, {
|
|
53
|
+
// $FlowFixMe[incompatible-call] these getters and setters have different types on purpose
|
|
54
|
+
get: createGetterForPluralLinkedField(selection, queryVariables, recordProxy, root),
|
|
55
|
+
set: createSetterForPluralLinkedField(selection, queryVariables, recordProxy, root)
|
|
56
|
+
});
|
|
57
|
+
} else {
|
|
58
|
+
Object.defineProperty(mutableUpdatableProxy, (_selection$alias2 = selection.alias) !== null && _selection$alias2 !== void 0 ? _selection$alias2 : selection.name, {
|
|
59
|
+
get: createGetterForSingularLinkedField(selection, queryVariables, recordProxy, root),
|
|
60
|
+
set: createSetterForSingularLinkedField(selection, queryVariables, recordProxy, root)
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
62
64
|
break;
|
|
63
65
|
|
|
64
66
|
case 'ScalarField':
|
|
65
|
-
var scalarFieldName = (_selection$
|
|
67
|
+
var scalarFieldName = (_selection$alias3 = selection.alias) !== null && _selection$alias3 !== void 0 ? _selection$alias3 : selection.name;
|
|
66
68
|
Object.defineProperty(mutableUpdatableProxy, scalarFieldName, {
|
|
67
69
|
get: function get() {
|
|
68
70
|
var _selection$args;
|
|
@@ -106,6 +108,10 @@ function updateProxyFromSelections(mutableUpdatableProxy, recordProxy, queryVari
|
|
|
106
108
|
};
|
|
107
109
|
|
|
108
110
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
111
|
+
var _selection$alias;
|
|
112
|
+
|
|
113
|
+
var _selection$alias2;
|
|
114
|
+
|
|
109
115
|
_loop();
|
|
110
116
|
}
|
|
111
117
|
} catch (err) {
|
|
@@ -122,8 +128,7 @@ function createSetterForPluralLinkedField(selection, queryVariables, recordProxy
|
|
|
122
128
|
var variables = getArgumentValues((_selection$args3 = selection.args) !== null && _selection$args3 !== void 0 ? _selection$args3 : [], queryVariables);
|
|
123
129
|
|
|
124
130
|
if (newValue == null) {
|
|
125
|
-
|
|
126
|
-
recordProxy.setValue(null, selection.name, variables);
|
|
131
|
+
throw new Error('Do not assign null to plural linked fields; assign an empty array instead.');
|
|
127
132
|
} else {
|
|
128
133
|
var recordProxies = newValue.map(function (item) {
|
|
129
134
|
if (item == null) {
|
|
@@ -55,50 +55,46 @@ function updateProxyFromSelections<TQuery: OperationType>(
|
|
|
55
55
|
for (const selection of selections) {
|
|
56
56
|
switch (selection.kind) {
|
|
57
57
|
case 'LinkedField':
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
get,
|
|
99
|
-
set,
|
|
100
|
-
},
|
|
101
|
-
);
|
|
58
|
+
if (selection.plural) {
|
|
59
|
+
Object.defineProperty(
|
|
60
|
+
mutableUpdatableProxy,
|
|
61
|
+
selection.alias ?? selection.name,
|
|
62
|
+
{
|
|
63
|
+
// $FlowFixMe[incompatible-call] these getters and setters have different types on purpose
|
|
64
|
+
get: createGetterForPluralLinkedField(
|
|
65
|
+
selection,
|
|
66
|
+
queryVariables,
|
|
67
|
+
recordProxy,
|
|
68
|
+
root,
|
|
69
|
+
),
|
|
70
|
+
set: createSetterForPluralLinkedField(
|
|
71
|
+
selection,
|
|
72
|
+
queryVariables,
|
|
73
|
+
recordProxy,
|
|
74
|
+
root,
|
|
75
|
+
),
|
|
76
|
+
},
|
|
77
|
+
);
|
|
78
|
+
} else {
|
|
79
|
+
Object.defineProperty(
|
|
80
|
+
mutableUpdatableProxy,
|
|
81
|
+
selection.alias ?? selection.name,
|
|
82
|
+
{
|
|
83
|
+
get: createGetterForSingularLinkedField(
|
|
84
|
+
selection,
|
|
85
|
+
queryVariables,
|
|
86
|
+
recordProxy,
|
|
87
|
+
root,
|
|
88
|
+
),
|
|
89
|
+
set: createSetterForSingularLinkedField(
|
|
90
|
+
selection,
|
|
91
|
+
queryVariables,
|
|
92
|
+
recordProxy,
|
|
93
|
+
root,
|
|
94
|
+
),
|
|
95
|
+
},
|
|
96
|
+
);
|
|
97
|
+
}
|
|
102
98
|
break;
|
|
103
99
|
case 'ScalarField':
|
|
104
100
|
const scalarFieldName = selection.alias ?? selection.name;
|
|
@@ -171,11 +167,12 @@ function createSetterForPluralLinkedField<TQuery: OperationType>(
|
|
|
171
167
|
recordProxy: RecordProxy,
|
|
172
168
|
root: RecordSourceProxy,
|
|
173
169
|
) {
|
|
174
|
-
return function set(newValue:
|
|
170
|
+
return function set(newValue: $ReadOnlyArray<{__id: string, ...}>) {
|
|
175
171
|
const variables = getArgumentValues(selection.args ?? [], queryVariables);
|
|
176
172
|
if (newValue == null) {
|
|
177
|
-
|
|
178
|
-
|
|
173
|
+
throw new Error(
|
|
174
|
+
'Do not assign null to plural linked fields; assign an empty array instead.',
|
|
175
|
+
);
|
|
179
176
|
} else {
|
|
180
177
|
const recordProxies = newValue.map(item => {
|
|
181
178
|
if (item == null) {
|
|
@@ -206,6 +203,7 @@ function createSetterForPluralLinkedField<TQuery: OperationType>(
|
|
|
206
203
|
}
|
|
207
204
|
};
|
|
208
205
|
}
|
|
206
|
+
|
|
209
207
|
function createSetterForSingularLinkedField<TQuery: OperationType>(
|
|
210
208
|
selection: ReaderLinkedField,
|
|
211
209
|
queryVariables: TQuery['variables'],
|