relay-runtime 1.7.0-rc.1 → 2.0.0
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/LICENSE +1 -1
- package/index.js +1 -1
- package/lib/ConvertToExecuteFunction.js +12 -75
- package/lib/DataChecker.js +400 -0
- package/lib/NormalizationNode.js +14 -0
- package/lib/ReaderNode.js +10 -0
- package/lib/RelayCombinedEnvironmentTypes.js +10 -0
- package/lib/RelayConcreteNode.js +12 -29
- package/lib/RelayConcreteVariables.js +17 -11
- package/lib/RelayConnectionHandler.js +98 -42
- package/lib/RelayConnectionInterface.js +5 -13
- package/lib/RelayCore.js +17 -14
- package/lib/RelayDeclarativeMutationConfig.js +69 -34
- package/lib/RelayDefaultHandleKey.js +1 -2
- package/lib/RelayDefaultHandlerProvider.js +6 -5
- package/lib/RelayError.js +6 -9
- package/lib/RelayInMemoryRecordSource.js +20 -22
- package/lib/RelayModernEnvironment.js +140 -229
- package/lib/RelayModernFragmentSpecResolver.js +110 -102
- package/lib/RelayModernGraphQLTag.js +53 -15
- package/lib/{RelayModernOperationSelector.js → RelayModernOperationDescriptor.js} +9 -8
- package/lib/RelayModernQueryExecutor.js +172 -0
- package/lib/RelayModernRecord.js +97 -38
- package/lib/RelayModernSelector.js +89 -33
- package/lib/RelayModernStore.js +301 -0
- package/lib/RelayNetwork.js +16 -28
- package/lib/RelayNetworkLogger.js +2 -3
- package/lib/RelayNetworkLoggerTransaction.js +32 -30
- package/lib/RelayNetworkTypes.js +1 -2
- package/lib/RelayObservable.js +127 -155
- package/lib/RelayProfiler.js +35 -22
- package/lib/RelayPublishQueue.js +144 -96
- package/lib/RelayQueryResponseCache.js +37 -21
- package/lib/RelayReader.js +194 -61
- package/lib/RelayRecordProxy.js +50 -31
- package/lib/RelayRecordSourceMutator.js +92 -51
- package/lib/RelayRecordSourceProxy.js +43 -35
- package/lib/RelayRecordSourceSelectorProxy.js +22 -21
- package/lib/RelayRecordState.js +1 -3
- package/lib/RelayReferenceMarker.js +110 -37
- package/lib/RelayResponseNormalizer.js +248 -82
- package/lib/RelayRuntimeTypes.js +1 -3
- package/lib/RelayStoreTypes.js +1 -2
- package/lib/RelayStoreUtils.js +37 -19
- package/lib/RelayViewerHandler.js +14 -10
- package/lib/applyRelayModernOptimisticMutation.js +8 -8
- package/lib/cloneRelayHandleSourceField.js +8 -9
- package/lib/commitLocalUpdate.js +1 -2
- package/lib/commitRelayModernMutation.js +21 -14
- package/lib/createRelayNetworkLogger.js +11 -9
- package/lib/deepFreeze.js +2 -3
- package/lib/fetchRelayModernQuery.js +10 -12
- package/lib/generateRelayClientID.js +4 -2
- package/lib/getRelayHandleKey.js +5 -6
- package/lib/hasOverlappingIDs.js +3 -2
- package/lib/index.js +59 -62
- package/lib/isPromise.js +1 -2
- package/lib/isRelayModernEnvironment.js +1 -3
- package/lib/isScalarAndEqual.js +1 -3
- package/lib/normalizePayload.js +17 -15
- package/lib/normalizeRelayPayload.js +9 -9
- package/lib/recycleNodesInto.js +25 -9
- package/lib/requestRelaySubscription.js +25 -58
- package/lib/simpleClone.js +2 -3
- package/lib/stableCopy.js +5 -3
- package/lib/validateMutation.js +146 -0
- package/package.json +3 -3
- package/relay-runtime.js +4 -0
- package/relay-runtime.min.js +9 -0
- package/lib/RelayDataLoader.js +0 -302
- package/lib/RelayMarkSweepStore.js +0 -242
- package/lib/deferrableFragmentKey.js +0 -20
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -7,14 +7,11 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
|
-
|
|
11
10
|
'use strict';
|
|
12
11
|
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
var _classCallCheck3 = _interopRequireDefault(require('babel-runtime/helpers/classCallCheck'));
|
|
12
|
+
var _objectSpread2 = require("@babel/runtime/helpers/interopRequireDefault")(require("@babel/runtime/helpers/objectSpread"));
|
|
16
13
|
|
|
17
|
-
|
|
14
|
+
var _defineProperty2 = require("@babel/runtime/helpers/interopRequireDefault")(require("@babel/runtime/helpers/defineProperty"));
|
|
18
15
|
|
|
19
16
|
/**
|
|
20
17
|
* A utility for resolving and subscribing to the results of a fragment spec
|
|
@@ -35,20 +32,19 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'd
|
|
|
35
32
|
* the resolver as stale and notify the caller, and the actual results are
|
|
36
33
|
* recomputed the first time `resolve()` is called.
|
|
37
34
|
*/
|
|
38
|
-
var RelayModernFragmentSpecResolver =
|
|
35
|
+
var RelayModernFragmentSpecResolver =
|
|
36
|
+
/*#__PURE__*/
|
|
37
|
+
function () {
|
|
39
38
|
function RelayModernFragmentSpecResolver(context, fragments, props, callback) {
|
|
40
39
|
var _this = this;
|
|
41
40
|
|
|
42
|
-
(0,
|
|
43
|
-
|
|
44
|
-
this._onChange = function () {
|
|
41
|
+
(0, _defineProperty2["default"])(this, "_onChange", function () {
|
|
45
42
|
_this._stale = true;
|
|
46
43
|
|
|
47
44
|
if (typeof _this._callback === 'function') {
|
|
48
45
|
_this._callback();
|
|
49
46
|
}
|
|
50
|
-
};
|
|
51
|
-
|
|
47
|
+
});
|
|
52
48
|
this._callback = callback;
|
|
53
49
|
this._context = context;
|
|
54
50
|
this._data = {};
|
|
@@ -56,11 +52,12 @@ var RelayModernFragmentSpecResolver = function () {
|
|
|
56
52
|
this._props = props;
|
|
57
53
|
this._resolvers = {};
|
|
58
54
|
this._stale = false;
|
|
59
|
-
|
|
60
55
|
this.setProps(props);
|
|
61
56
|
}
|
|
62
57
|
|
|
63
|
-
RelayModernFragmentSpecResolver.prototype
|
|
58
|
+
var _proto = RelayModernFragmentSpecResolver.prototype;
|
|
59
|
+
|
|
60
|
+
_proto.dispose = function dispose() {
|
|
64
61
|
for (var _key in this._resolvers) {
|
|
65
62
|
if (this._resolvers.hasOwnProperty(_key)) {
|
|
66
63
|
disposeCallback(this._resolvers[_key]);
|
|
@@ -68,220 +65,235 @@ var RelayModernFragmentSpecResolver = function () {
|
|
|
68
65
|
}
|
|
69
66
|
};
|
|
70
67
|
|
|
71
|
-
|
|
68
|
+
_proto.resolve = function resolve() {
|
|
72
69
|
if (this._stale) {
|
|
73
70
|
// Avoid mapping the object multiple times, which could occur if data for
|
|
74
71
|
// multiple keys changes in the same event loop.
|
|
75
72
|
var prevData = this._data;
|
|
76
|
-
var nextData
|
|
73
|
+
var nextData;
|
|
74
|
+
|
|
77
75
|
for (var _key2 in this._resolvers) {
|
|
78
76
|
if (this._resolvers.hasOwnProperty(_key2)) {
|
|
79
77
|
var resolver = this._resolvers[_key2];
|
|
80
78
|
var prevItem = prevData[_key2];
|
|
79
|
+
|
|
81
80
|
if (resolver) {
|
|
82
81
|
var nextItem = resolver.resolve();
|
|
82
|
+
|
|
83
83
|
if (nextData || nextItem !== prevItem) {
|
|
84
|
-
nextData = nextData || (0,
|
|
84
|
+
nextData = nextData || (0, _objectSpread2["default"])({}, prevData);
|
|
85
85
|
nextData[_key2] = nextItem;
|
|
86
86
|
}
|
|
87
87
|
} else {
|
|
88
88
|
var prop = this._props[_key2];
|
|
89
|
+
|
|
89
90
|
var _nextItem = prop !== undefined ? prop : null;
|
|
90
|
-
|
|
91
|
-
|
|
91
|
+
|
|
92
|
+
if (nextData || !require("./isScalarAndEqual")(_nextItem, prevItem)) {
|
|
93
|
+
nextData = nextData || (0, _objectSpread2["default"])({}, prevData);
|
|
92
94
|
nextData[_key2] = _nextItem;
|
|
93
95
|
}
|
|
94
96
|
}
|
|
95
97
|
}
|
|
96
98
|
}
|
|
99
|
+
|
|
97
100
|
this._data = nextData || prevData;
|
|
98
101
|
this._stale = false;
|
|
99
102
|
}
|
|
100
|
-
return this._data;
|
|
101
|
-
};
|
|
102
103
|
|
|
103
|
-
|
|
104
|
-
for (var _key3 in this._resolvers) {
|
|
105
|
-
if (this._resolvers.hasOwnProperty(_key3) && this._resolvers[_key3] && this._resolvers[_key3].isLoading()) {
|
|
106
|
-
return true;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return false;
|
|
104
|
+
return this._data;
|
|
110
105
|
};
|
|
111
106
|
|
|
112
|
-
|
|
107
|
+
_proto.setCallback = function setCallback(callback) {
|
|
113
108
|
this._callback = callback;
|
|
114
109
|
};
|
|
115
110
|
|
|
116
|
-
|
|
117
|
-
var
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
var
|
|
122
|
-
|
|
111
|
+
_proto.setProps = function setProps(props) {
|
|
112
|
+
var ownedSelectors = require("./RelayModernSelector").getSelectorsFromObject(this._context.variables, this._fragments, props);
|
|
113
|
+
|
|
114
|
+
for (var _key3 in ownedSelectors) {
|
|
115
|
+
if (ownedSelectors.hasOwnProperty(_key3)) {
|
|
116
|
+
var ownedSelector = ownedSelectors[_key3];
|
|
117
|
+
var resolver = this._resolvers[_key3];
|
|
118
|
+
|
|
119
|
+
if (ownedSelector == null) {
|
|
123
120
|
if (resolver != null) {
|
|
124
121
|
resolver.dispose();
|
|
125
122
|
}
|
|
123
|
+
|
|
126
124
|
resolver = null;
|
|
127
|
-
} else if (Array.isArray(
|
|
125
|
+
} else if (Array.isArray(ownedSelector)) {
|
|
128
126
|
if (resolver == null) {
|
|
129
|
-
resolver = new SelectorListResolver(this._context.environment,
|
|
127
|
+
resolver = new SelectorListResolver(this._context.environment, ownedSelector, this._onChange);
|
|
130
128
|
} else {
|
|
131
|
-
!(resolver instanceof SelectorListResolver) ? process.env.NODE_ENV !==
|
|
132
|
-
resolver.setSelectors(
|
|
129
|
+
!(resolver instanceof SelectorListResolver) ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelayModernFragmentSpecResolver: Expected prop `%s` to always be an array.', _key3) : require("fbjs/lib/invariant")(false) : void 0;
|
|
130
|
+
resolver.setSelectors(ownedSelector);
|
|
133
131
|
}
|
|
134
132
|
} else {
|
|
135
133
|
if (resolver == null) {
|
|
136
|
-
resolver = new SelectorResolver(this._context.environment,
|
|
134
|
+
resolver = new SelectorResolver(this._context.environment, ownedSelector, this._onChange);
|
|
137
135
|
} else {
|
|
138
|
-
!(resolver instanceof SelectorResolver) ? process.env.NODE_ENV !==
|
|
139
|
-
resolver.setSelector(
|
|
136
|
+
!(resolver instanceof SelectorResolver) ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelayModernFragmentSpecResolver: Expected prop `%s` to always be an object.', _key3) : require("fbjs/lib/invariant")(false) : void 0;
|
|
137
|
+
resolver.setSelector(ownedSelector);
|
|
140
138
|
}
|
|
141
139
|
}
|
|
142
|
-
|
|
140
|
+
|
|
141
|
+
this._resolvers[_key3] = resolver;
|
|
143
142
|
}
|
|
144
143
|
}
|
|
144
|
+
|
|
145
145
|
this._props = props;
|
|
146
146
|
this._stale = true;
|
|
147
147
|
};
|
|
148
148
|
|
|
149
|
-
|
|
150
|
-
for (var
|
|
151
|
-
if (this._resolvers.hasOwnProperty(
|
|
152
|
-
var resolver = this._resolvers[
|
|
149
|
+
_proto.setVariables = function setVariables(variables) {
|
|
150
|
+
for (var _key4 in this._resolvers) {
|
|
151
|
+
if (this._resolvers.hasOwnProperty(_key4)) {
|
|
152
|
+
var resolver = this._resolvers[_key4];
|
|
153
|
+
|
|
153
154
|
if (resolver) {
|
|
154
155
|
resolver.setVariables(variables);
|
|
155
156
|
}
|
|
156
157
|
}
|
|
157
158
|
}
|
|
159
|
+
|
|
158
160
|
this._stale = true;
|
|
159
161
|
};
|
|
160
162
|
|
|
161
163
|
return RelayModernFragmentSpecResolver;
|
|
162
164
|
}();
|
|
163
|
-
|
|
164
165
|
/**
|
|
165
166
|
* A resolver for a single Selector.
|
|
166
167
|
*/
|
|
167
168
|
|
|
168
169
|
|
|
169
|
-
var SelectorResolver =
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
var SelectorResolver =
|
|
171
|
+
/*#__PURE__*/
|
|
172
|
+
function () {
|
|
173
|
+
function SelectorResolver(environment, ownedSelector, callback) {
|
|
174
|
+
var _this2 = this;
|
|
175
|
+
|
|
176
|
+
(0, _defineProperty2["default"])(this, "_onChange", function (snapshot) {
|
|
177
|
+
_this2._data = snapshot.data;
|
|
178
|
+
|
|
179
|
+
_this2._callback();
|
|
180
|
+
});
|
|
172
181
|
|
|
173
|
-
|
|
182
|
+
var _snapshot = environment.lookup(ownedSelector.selector);
|
|
174
183
|
|
|
175
|
-
var snapshot = environment.lookup(selector);
|
|
176
184
|
this._callback = callback;
|
|
177
|
-
this._data =
|
|
185
|
+
this._data = _snapshot.data;
|
|
178
186
|
this._environment = environment;
|
|
179
|
-
this.
|
|
180
|
-
this._subscription = environment.subscribe(
|
|
187
|
+
this._ownedSelector = ownedSelector;
|
|
188
|
+
this._subscription = environment.subscribe(_snapshot, this._onChange);
|
|
181
189
|
}
|
|
182
190
|
|
|
183
|
-
SelectorResolver.prototype
|
|
191
|
+
var _proto2 = SelectorResolver.prototype;
|
|
192
|
+
|
|
193
|
+
_proto2.dispose = function dispose() {
|
|
184
194
|
if (this._subscription) {
|
|
185
195
|
this._subscription.dispose();
|
|
196
|
+
|
|
186
197
|
this._subscription = null;
|
|
187
198
|
}
|
|
188
199
|
};
|
|
189
200
|
|
|
190
|
-
|
|
201
|
+
_proto2.resolve = function resolve() {
|
|
191
202
|
return this._data;
|
|
192
203
|
};
|
|
193
204
|
|
|
194
|
-
|
|
195
|
-
if (this._subscription != null && require(
|
|
205
|
+
_proto2.setSelector = function setSelector(ownedSelector) {
|
|
206
|
+
if (this._subscription != null && require("./RelayModernSelector").areEqualSelectors(ownedSelector, this._ownedSelector)) {
|
|
196
207
|
return;
|
|
197
208
|
}
|
|
209
|
+
|
|
198
210
|
this.dispose();
|
|
199
|
-
|
|
211
|
+
|
|
212
|
+
var snapshot = this._environment.lookup(ownedSelector.selector);
|
|
213
|
+
|
|
200
214
|
this._data = snapshot.data;
|
|
201
|
-
this.
|
|
215
|
+
this._ownedSelector = ownedSelector;
|
|
202
216
|
this._subscription = this._environment.subscribe(snapshot, this._onChange);
|
|
203
217
|
};
|
|
204
218
|
|
|
205
|
-
|
|
206
|
-
var
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
return this._environment.isSelectorLoading(this._selector);
|
|
219
|
+
_proto2.setVariables = function setVariables(variables) {
|
|
220
|
+
var ownedSelector = {
|
|
221
|
+
owner: null,
|
|
222
|
+
selector: (0, _objectSpread2["default"])({}, this._ownedSelector.selector, {
|
|
223
|
+
variables: variables
|
|
224
|
+
})
|
|
225
|
+
};
|
|
226
|
+
this.setSelector(ownedSelector);
|
|
214
227
|
};
|
|
215
228
|
|
|
216
229
|
return SelectorResolver;
|
|
217
230
|
}();
|
|
218
|
-
|
|
219
231
|
/**
|
|
220
232
|
* A resolver for an array of Selectors.
|
|
221
233
|
*/
|
|
222
234
|
|
|
223
235
|
|
|
224
|
-
var
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
this._onChange = function (snapshot) {
|
|
228
|
-
_this3._data = snapshot.data;
|
|
229
|
-
_this3._callback();
|
|
230
|
-
};
|
|
231
|
-
};
|
|
232
|
-
|
|
233
|
-
var SelectorListResolver = function () {
|
|
236
|
+
var SelectorListResolver =
|
|
237
|
+
/*#__PURE__*/
|
|
238
|
+
function () {
|
|
234
239
|
function SelectorListResolver(environment, selectors, callback) {
|
|
235
|
-
var
|
|
240
|
+
var _this3 = this;
|
|
236
241
|
|
|
237
|
-
(0,
|
|
238
|
-
|
|
239
|
-
this._onChange = function (data) {
|
|
240
|
-
_this2._stale = true;
|
|
241
|
-
_this2._callback();
|
|
242
|
-
};
|
|
242
|
+
(0, _defineProperty2["default"])(this, "_onChange", function (data) {
|
|
243
|
+
_this3._stale = true;
|
|
243
244
|
|
|
245
|
+
_this3._callback();
|
|
246
|
+
});
|
|
244
247
|
this._callback = callback;
|
|
245
248
|
this._data = [];
|
|
246
249
|
this._environment = environment;
|
|
247
250
|
this._resolvers = [];
|
|
248
251
|
this._stale = true;
|
|
249
|
-
|
|
250
252
|
this.setSelectors(selectors);
|
|
251
253
|
}
|
|
252
254
|
|
|
253
|
-
SelectorListResolver.prototype
|
|
255
|
+
var _proto3 = SelectorListResolver.prototype;
|
|
256
|
+
|
|
257
|
+
_proto3.dispose = function dispose() {
|
|
254
258
|
this._resolvers.forEach(disposeCallback);
|
|
255
259
|
};
|
|
256
260
|
|
|
257
|
-
|
|
261
|
+
_proto3.resolve = function resolve() {
|
|
258
262
|
if (this._stale) {
|
|
259
263
|
// Avoid mapping the array multiple times, which could occur if data for
|
|
260
264
|
// multiple indices changes in the same event loop.
|
|
261
265
|
var prevData = this._data;
|
|
262
|
-
var nextData
|
|
266
|
+
var nextData;
|
|
267
|
+
|
|
263
268
|
for (var ii = 0; ii < this._resolvers.length; ii++) {
|
|
264
269
|
var prevItem = prevData[ii];
|
|
270
|
+
|
|
265
271
|
var nextItem = this._resolvers[ii].resolve();
|
|
272
|
+
|
|
266
273
|
if (nextData || nextItem !== prevItem) {
|
|
267
274
|
nextData = nextData || prevData.slice(0, ii);
|
|
268
275
|
nextData.push(nextItem);
|
|
269
276
|
}
|
|
270
277
|
}
|
|
278
|
+
|
|
271
279
|
if (!nextData && this._resolvers.length !== prevData.length) {
|
|
272
280
|
nextData = prevData.slice(0, this._resolvers.length);
|
|
273
281
|
}
|
|
282
|
+
|
|
274
283
|
this._data = nextData || prevData;
|
|
275
284
|
this._stale = false;
|
|
276
285
|
}
|
|
286
|
+
|
|
277
287
|
return this._data;
|
|
278
288
|
};
|
|
279
289
|
|
|
280
|
-
|
|
290
|
+
_proto3.setSelectors = function setSelectors(selectors) {
|
|
281
291
|
while (this._resolvers.length > selectors.length) {
|
|
282
292
|
var resolver = this._resolvers.pop();
|
|
293
|
+
|
|
283
294
|
resolver.dispose();
|
|
284
295
|
}
|
|
296
|
+
|
|
285
297
|
for (var ii = 0; ii < selectors.length; ii++) {
|
|
286
298
|
if (ii < this._resolvers.length) {
|
|
287
299
|
this._resolvers[ii].setSelector(selectors[ii]);
|
|
@@ -289,20 +301,16 @@ var SelectorListResolver = function () {
|
|
|
289
301
|
this._resolvers[ii] = new SelectorResolver(this._environment, selectors[ii], this._onChange);
|
|
290
302
|
}
|
|
291
303
|
}
|
|
304
|
+
|
|
292
305
|
this._stale = true;
|
|
293
306
|
};
|
|
294
307
|
|
|
295
|
-
|
|
308
|
+
_proto3.setVariables = function setVariables(variables) {
|
|
296
309
|
this._resolvers.forEach(function (resolver) {
|
|
297
310
|
return resolver.setVariables(variables);
|
|
298
311
|
});
|
|
299
|
-
this._stale = true;
|
|
300
|
-
};
|
|
301
312
|
|
|
302
|
-
|
|
303
|
-
return this._resolvers.some(function (resolver) {
|
|
304
|
-
return resolver.isLoading();
|
|
305
|
-
});
|
|
313
|
+
this._stale = true;
|
|
306
314
|
};
|
|
307
315
|
|
|
308
316
|
return SelectorListResolver;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -7,45 +7,83 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
|
-
|
|
11
10
|
'use strict';
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
13
|
* Runtime function to correspond to the `graphql` tagged template function.
|
|
15
14
|
* All calls to this function should be transformed by the plugin.
|
|
16
15
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
// The type of a graphql`...` tagged template expression.
|
|
20
16
|
function graphql(strings) {
|
|
21
|
-
!false ? process.env.NODE_ENV !==
|
|
17
|
+
!false ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'graphql: Unexpected invocation at runtime. Either the Babel transform ' + 'was not set up, or it failed to identify this call site. Make sure it ' + 'is being used verbatim as `graphql`.') : require("fbjs/lib/invariant")(false) : void 0;
|
|
22
18
|
}
|
|
23
19
|
|
|
24
20
|
function getNode(taggedNode) {
|
|
25
|
-
var fn = typeof taggedNode === 'function' ? taggedNode : taggedNode.modern;
|
|
26
|
-
|
|
27
|
-
if (
|
|
21
|
+
var fn = typeof taggedNode === 'function' ? taggedNode : typeof taggedNode.modern === 'function' ? taggedNode.modern : null; // Support for classic raw nodes (used in test mock)
|
|
22
|
+
|
|
23
|
+
if (fn === null) {
|
|
28
24
|
return taggedNode;
|
|
29
25
|
}
|
|
30
|
-
|
|
31
|
-
// Support for languages that work (best) with ES6 modules, such as TypeScript.
|
|
32
|
-
|
|
26
|
+
|
|
27
|
+
var data = fn(); // Support for languages that work (best) with ES6 modules, such as TypeScript.
|
|
28
|
+
|
|
29
|
+
return data["default"] ? data["default"] : data;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function isFragment(node) {
|
|
33
|
+
var fragment = getNode(node);
|
|
34
|
+
return typeof fragment === 'object' && fragment !== null && fragment.kind === require("./RelayConcreteNode").FRAGMENT;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function isRequest(node) {
|
|
38
|
+
var request = getNode(node);
|
|
39
|
+
return typeof request === 'object' && request !== null && request.kind === require("./RelayConcreteNode").REQUEST;
|
|
33
40
|
}
|
|
34
41
|
|
|
35
42
|
function getFragment(taggedNode) {
|
|
36
43
|
var fragment = getNode(taggedNode);
|
|
37
|
-
!(
|
|
44
|
+
!isFragment(fragment) ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelayModernGraphQLTag: Expected a fragment, got `%s`.', JSON.stringify(fragment)) : require("fbjs/lib/invariant")(false) : void 0;
|
|
45
|
+
return fragment;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function getPaginationFragment(taggedNode) {
|
|
49
|
+
var _fragment$metadata;
|
|
50
|
+
|
|
51
|
+
var fragment = getFragment(taggedNode);
|
|
52
|
+
var refetch = (_fragment$metadata = fragment.metadata) === null || _fragment$metadata === void 0 ? void 0 : _fragment$metadata.refetch;
|
|
53
|
+
var connection = refetch === null || refetch === void 0 ? void 0 : refetch.connection;
|
|
54
|
+
|
|
55
|
+
if (refetch === null || typeof refetch !== 'object' || connection === null || typeof connection !== 'object') {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return fragment;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function getRefetchableFragment(taggedNode) {
|
|
63
|
+
var _fragment$metadata2;
|
|
64
|
+
|
|
65
|
+
var fragment = getFragment(taggedNode);
|
|
66
|
+
var refetch = (_fragment$metadata2 = fragment.metadata) === null || _fragment$metadata2 === void 0 ? void 0 : _fragment$metadata2.refetch;
|
|
67
|
+
|
|
68
|
+
if (refetch === null || typeof refetch !== 'object') {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
|
|
38
72
|
return fragment;
|
|
39
73
|
}
|
|
40
74
|
|
|
41
75
|
function getRequest(taggedNode) {
|
|
42
76
|
var request = getNode(taggedNode);
|
|
43
|
-
!(
|
|
77
|
+
!isRequest(request) ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelayModernGraphQLTag: Expected a request, got `%s`.', JSON.stringify(request)) : require("fbjs/lib/invariant")(false) : void 0;
|
|
44
78
|
return request;
|
|
45
79
|
}
|
|
46
80
|
|
|
47
81
|
module.exports = {
|
|
48
82
|
getFragment: getFragment,
|
|
83
|
+
getPaginationFragment: getPaginationFragment,
|
|
84
|
+
getRefetchableFragment: getRefetchableFragment,
|
|
49
85
|
getRequest: getRequest,
|
|
50
|
-
graphql: graphql
|
|
86
|
+
graphql: graphql,
|
|
87
|
+
isFragment: isFragment,
|
|
88
|
+
isRequest: isRequest
|
|
51
89
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -7,20 +7,21 @@
|
|
|
7
7
|
* strict-local
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
|
-
|
|
11
10
|
'use strict';
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
|
-
* Creates an instance of the `
|
|
13
|
+
* Creates an instance of the `OperationDescriptor` type defined in
|
|
15
14
|
* `RelayStoreTypes` given an operation and some variables. The input variables
|
|
16
15
|
* are filtered to exclude variables that do not match defined arguments on the
|
|
17
16
|
* operation, and default values are populated for null values.
|
|
18
17
|
*/
|
|
19
|
-
function
|
|
20
|
-
var operation =
|
|
18
|
+
function createOperationDescriptor(request, variables) {
|
|
19
|
+
var operation = request.operation;
|
|
20
|
+
|
|
21
|
+
var operationVariables = require("./RelayConcreteVariables").getOperationVariables(operation, variables);
|
|
22
|
+
|
|
23
|
+
var dataID = require("./RelayStoreUtils").ROOT_ID;
|
|
21
24
|
|
|
22
|
-
var operationVariables = require('./RelayConcreteVariables').getOperationVariables(operation, variables);
|
|
23
|
-
var dataID = require('./RelayStoreUtils').ROOT_ID;
|
|
24
25
|
return {
|
|
25
26
|
fragment: {
|
|
26
27
|
dataID: dataID,
|
|
@@ -38,5 +39,5 @@ function createOperationSelector(request, variables, operationFromBatch) {
|
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
module.exports = {
|
|
41
|
-
|
|
42
|
+
createOperationDescriptor: createOperationDescriptor
|
|
42
43
|
};
|