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.
Files changed (72) hide show
  1. package/LICENSE +1 -1
  2. package/index.js +1 -1
  3. package/lib/ConvertToExecuteFunction.js +12 -75
  4. package/lib/DataChecker.js +400 -0
  5. package/lib/NormalizationNode.js +14 -0
  6. package/lib/ReaderNode.js +10 -0
  7. package/lib/RelayCombinedEnvironmentTypes.js +10 -0
  8. package/lib/RelayConcreteNode.js +12 -29
  9. package/lib/RelayConcreteVariables.js +17 -11
  10. package/lib/RelayConnectionHandler.js +98 -42
  11. package/lib/RelayConnectionInterface.js +5 -13
  12. package/lib/RelayCore.js +17 -14
  13. package/lib/RelayDeclarativeMutationConfig.js +69 -34
  14. package/lib/RelayDefaultHandleKey.js +1 -2
  15. package/lib/RelayDefaultHandlerProvider.js +6 -5
  16. package/lib/RelayError.js +6 -9
  17. package/lib/RelayInMemoryRecordSource.js +20 -22
  18. package/lib/RelayModernEnvironment.js +140 -229
  19. package/lib/RelayModernFragmentSpecResolver.js +110 -102
  20. package/lib/RelayModernGraphQLTag.js +53 -15
  21. package/lib/{RelayModernOperationSelector.js → RelayModernOperationDescriptor.js} +9 -8
  22. package/lib/RelayModernQueryExecutor.js +172 -0
  23. package/lib/RelayModernRecord.js +97 -38
  24. package/lib/RelayModernSelector.js +89 -33
  25. package/lib/RelayModernStore.js +301 -0
  26. package/lib/RelayNetwork.js +16 -28
  27. package/lib/RelayNetworkLogger.js +2 -3
  28. package/lib/RelayNetworkLoggerTransaction.js +32 -30
  29. package/lib/RelayNetworkTypes.js +1 -2
  30. package/lib/RelayObservable.js +127 -155
  31. package/lib/RelayProfiler.js +35 -22
  32. package/lib/RelayPublishQueue.js +144 -96
  33. package/lib/RelayQueryResponseCache.js +37 -21
  34. package/lib/RelayReader.js +194 -61
  35. package/lib/RelayRecordProxy.js +50 -31
  36. package/lib/RelayRecordSourceMutator.js +92 -51
  37. package/lib/RelayRecordSourceProxy.js +43 -35
  38. package/lib/RelayRecordSourceSelectorProxy.js +22 -21
  39. package/lib/RelayRecordState.js +1 -3
  40. package/lib/RelayReferenceMarker.js +110 -37
  41. package/lib/RelayResponseNormalizer.js +248 -82
  42. package/lib/RelayRuntimeTypes.js +1 -3
  43. package/lib/RelayStoreTypes.js +1 -2
  44. package/lib/RelayStoreUtils.js +37 -19
  45. package/lib/RelayViewerHandler.js +14 -10
  46. package/lib/applyRelayModernOptimisticMutation.js +8 -8
  47. package/lib/cloneRelayHandleSourceField.js +8 -9
  48. package/lib/commitLocalUpdate.js +1 -2
  49. package/lib/commitRelayModernMutation.js +21 -14
  50. package/lib/createRelayNetworkLogger.js +11 -9
  51. package/lib/deepFreeze.js +2 -3
  52. package/lib/fetchRelayModernQuery.js +10 -12
  53. package/lib/generateRelayClientID.js +4 -2
  54. package/lib/getRelayHandleKey.js +5 -6
  55. package/lib/hasOverlappingIDs.js +3 -2
  56. package/lib/index.js +59 -62
  57. package/lib/isPromise.js +1 -2
  58. package/lib/isRelayModernEnvironment.js +1 -3
  59. package/lib/isScalarAndEqual.js +1 -3
  60. package/lib/normalizePayload.js +17 -15
  61. package/lib/normalizeRelayPayload.js +9 -9
  62. package/lib/recycleNodesInto.js +25 -9
  63. package/lib/requestRelaySubscription.js +25 -58
  64. package/lib/simpleClone.js +2 -3
  65. package/lib/stableCopy.js +5 -3
  66. package/lib/validateMutation.js +146 -0
  67. package/package.json +3 -3
  68. package/relay-runtime.js +4 -0
  69. package/relay-runtime.min.js +9 -0
  70. package/lib/RelayDataLoader.js +0 -302
  71. package/lib/RelayMarkSweepStore.js +0 -242
  72. package/lib/deferrableFragmentKey.js +0 -20
@@ -0,0 +1,172 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * strict-local
8
+ * @format
9
+ * @emails oncall+relay
10
+ */
11
+ 'use strict';
12
+
13
+ /**
14
+ * Coordinates the execution of a query, handling network callbacks
15
+ * including optimistic payloads, standard payloads, resolution of match
16
+ * dependencies, etc.
17
+ */
18
+ function execute(_ref) {
19
+ var network = _ref.network,
20
+ publishQueue = _ref.publishQueue,
21
+ operation = _ref.operation,
22
+ operationLoader = _ref.operationLoader,
23
+ cacheConfig = _ref.cacheConfig,
24
+ updater = _ref.updater;
25
+ return require("./RelayObservable").create(function (sink) {
26
+ var optimisticResponse = null;
27
+ var subscriptions = new Set();
28
+
29
+ function start(subscription) {
30
+ // NOTE: store the subscription object on the observer so that it
31
+ // can be cleaned up in complete() or the dispose function.
32
+ this._subscription = subscription;
33
+ subscriptions.add(subscription);
34
+ }
35
+
36
+ function complete() {
37
+ subscriptions["delete"](this._subscription);
38
+
39
+ if (subscriptions.size === 0) {
40
+ sink.complete();
41
+ }
42
+ } // Convert each GraphQLResponse from the network to a RelayResponsePayload
43
+ // and process it
44
+
45
+
46
+ function next(response) {
47
+ var _response$extensions;
48
+
49
+ var payload = require("./normalizePayload")(operation, response);
50
+
51
+ var isOptimistic = ((_response$extensions = response.extensions) === null || _response$extensions === void 0 ? void 0 : _response$extensions.isOptimistic) === true;
52
+ processRelayPayload(payload, operation, updater, isOptimistic);
53
+ sink.next(response);
54
+ } // Each RelayResponsePayload contains both data to publish to the store
55
+ // immediately, but may also contain matchPayloads that need to be
56
+ // asynchronously normalized into RelayResponsePayloads, which may
57
+ // themselves have matchPayloads: this function is recursive and relies
58
+ // on GraphQL queries *disallowing* recursion to ensure termination.
59
+
60
+
61
+ var processRelayPayload = function processRelayPayload(payload) {
62
+ var operationDescriptor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
63
+ var payloadUpdater = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
64
+ var isOptimistic = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
65
+ var matchPayloads = payload.matchPayloads;
66
+
67
+ if (matchPayloads && matchPayloads.length) {
68
+ !operationLoader ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelayModernEnvironment: Expected an operationLoader to be ' + 'configured when using `@match`.') : require("fbjs/lib/invariant")(false) : void 0;
69
+ matchPayloads.forEach(function (matchPayload) {
70
+ processMatchPayload(processRelayPayload, operationLoader, matchPayload).subscribe({
71
+ complete: complete,
72
+ error: sink.error,
73
+ start: start
74
+ });
75
+ });
76
+ }
77
+
78
+ if (isOptimistic) {
79
+ !(optimisticResponse === null) ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'environment.execute: only support one optimistic response per ' + 'execute.') : require("fbjs/lib/invariant")(false) : void 0;
80
+ optimisticResponse = {
81
+ source: payload.source,
82
+ fieldPayloads: payload.fieldPayloads
83
+ };
84
+ publishQueue.applyUpdate(optimisticResponse);
85
+ publishQueue.run();
86
+ } else {
87
+ if (optimisticResponse !== null) {
88
+ publishQueue.revertUpdate(optimisticResponse);
89
+ optimisticResponse = null;
90
+ }
91
+
92
+ if (operationDescriptor && payloadUpdater) {
93
+ publishQueue.commitPayload(operationDescriptor, payload, payloadUpdater);
94
+ } else {
95
+ publishQueue.commitRelayPayload(payload);
96
+ }
97
+
98
+ publishQueue.run();
99
+ }
100
+ };
101
+
102
+ var node = operation.node;
103
+ network.execute(node.params, operation.variables, cacheConfig || {}).subscribe({
104
+ complete: complete,
105
+ next: next,
106
+ error: sink.error,
107
+ start: start
108
+ });
109
+ return function () {
110
+ if (subscriptions.size !== 0) {
111
+ subscriptions.forEach(function (sub) {
112
+ return sub.unsubscribe();
113
+ });
114
+ subscriptions.clear();
115
+ }
116
+
117
+ if (optimisticResponse !== null) {
118
+ publishQueue.revertUpdate(optimisticResponse);
119
+ optimisticResponse = null;
120
+ publishQueue.run();
121
+ }
122
+ };
123
+ });
124
+ }
125
+ /**
126
+ * Processes a MatchFieldPayload, asynchronously resolving the fragment,
127
+ * using it to normalize the field data into a RelayResponsePayload.
128
+ * Because @match fields may contain other @match fields, the result of
129
+ * normalizing `matchPayload` may contain *other* MatchFieldPayloads:
130
+ * the processRelayPayload() callback is responsible for publishing
131
+ * both the normalize payload's source as well as recursively calling
132
+ * this function for any matchPayloads it contains.
133
+ *
134
+ * @private
135
+ */
136
+
137
+
138
+ function processMatchPayload(processRelayPayload, operationLoader, matchPayload) {
139
+ return require("./RelayObservable").from(new Promise(function (resolve, reject) {
140
+ operationLoader.load(matchPayload.operationReference).then(resolve, reject);
141
+ })).map(function (operation) {
142
+ if (operation == null) {
143
+ return;
144
+ }
145
+
146
+ var selector = {
147
+ dataID: matchPayload.dataID,
148
+ variables: matchPayload.variables,
149
+ node: operation
150
+ };
151
+ var source = new (require("./RelayInMemoryRecordSource"))();
152
+
153
+ var matchRecord = require("./RelayModernRecord").create(matchPayload.dataID, matchPayload.typeName);
154
+
155
+ source.set(matchPayload.dataID, matchRecord);
156
+
157
+ var normalizeResult = require("./RelayResponseNormalizer").normalize(source, selector, matchPayload.data);
158
+
159
+ var relayPayload = {
160
+ errors: null,
161
+ // Errors are handled as part of the parent GraphQLResponse
162
+ fieldPayloads: normalizeResult.fieldPayloads,
163
+ matchPayloads: normalizeResult.matchPayloads,
164
+ source: source
165
+ };
166
+ processRelayPayload(relayPayload);
167
+ });
168
+ }
169
+
170
+ module.exports = {
171
+ execute: execute
172
+ };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2013-present, Facebook, Inc.
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,12 +7,9 @@
7
7
  *
8
8
  * @format
9
9
  */
10
-
11
10
  'use strict';
12
11
 
13
- var _extends3 = _interopRequireDefault(require('babel-runtime/helpers/extends'));
14
-
15
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
12
+ var _objectSpread2 = require("@babel/runtime/helpers/interopRequireDefault")(require("@babel/runtime/helpers/objectSpread"));
16
13
 
17
14
  /**
18
15
  * @public
@@ -64,9 +61,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'd
64
61
  * Clone a record.
65
62
  */
66
63
  function clone(record) {
67
- return (0, _extends3['default'])({}, record);
64
+ return (0, _objectSpread2["default"])({}, record);
68
65
  }
69
-
70
66
  /**
71
67
  * @public
72
68
  *
@@ -77,91 +73,104 @@ function clone(record) {
77
73
  * copied by reference and not value; callers should ensure that values are
78
74
  * copied on write.
79
75
  */
76
+
77
+
80
78
  function copyFields(source, sink) {
81
79
  for (var key in source) {
82
80
  if (source.hasOwnProperty(key)) {
83
- if (key !== require('./RelayStoreUtils').ID_KEY && key !== require('./RelayStoreUtils').TYPENAME_KEY) {
81
+ if (key !== require("./RelayStoreUtils").ID_KEY && key !== require("./RelayStoreUtils").TYPENAME_KEY) {
84
82
  sink[key] = source[key];
85
83
  }
86
84
  }
87
85
  }
88
86
  }
89
-
90
87
  /**
91
88
  * @public
92
89
  *
93
90
  * Create a new record.
94
91
  */
92
+
93
+
95
94
  function create(dataID, typeName) {
96
95
  // See perf note above for why we aren't using computed property access.
97
96
  var record = {};
98
- record[require('./RelayStoreUtils').ID_KEY] = dataID;
99
- record[require('./RelayStoreUtils').TYPENAME_KEY] = typeName;
97
+ record[require("./RelayStoreUtils").ID_KEY] = dataID;
98
+ record[require("./RelayStoreUtils").TYPENAME_KEY] = typeName;
100
99
  return record;
101
100
  }
102
-
103
101
  /**
104
102
  * @public
105
103
  *
106
104
  * Get the record's `id` if available or the client-generated identifier.
107
105
  */
106
+
107
+
108
108
  function getDataID(record) {
109
- return record[require('./RelayStoreUtils').ID_KEY];
109
+ return record[require("./RelayStoreUtils").ID_KEY];
110
110
  }
111
-
112
111
  /**
113
112
  * @public
114
113
  *
115
114
  * Get the concrete type of the record.
116
115
  */
116
+
117
+
117
118
  function getType(record) {
118
- return record[require('./RelayStoreUtils').TYPENAME_KEY];
119
+ return record[require("./RelayStoreUtils").TYPENAME_KEY];
119
120
  }
120
-
121
121
  /**
122
122
  * @public
123
123
  *
124
124
  * Get a scalar (non-link) field value.
125
125
  */
126
+
127
+
126
128
  function getValue(record, storageKey) {
127
129
  var value = record[storageKey];
130
+
128
131
  if (value && typeof value === 'object') {
129
- !(!value.hasOwnProperty(require('./RelayStoreUtils').REF_KEY) && !value.hasOwnProperty(require('./RelayStoreUtils').REFS_KEY)) ? process.env.NODE_ENV !== 'production' ? require('fbjs/lib/invariant')(false, 'RelayModernRecord.getValue(): Expected a scalar (non-link) value for `%s.%s` ' + 'but found %s.', record[require('./RelayStoreUtils').ID_KEY], storageKey, value.hasOwnProperty(require('./RelayStoreUtils').REF_KEY) ? 'a linked record' : 'plural linked records') : require('fbjs/lib/invariant')(false) : void 0;
132
+ !(!value.hasOwnProperty(require("./RelayStoreUtils").REF_KEY) && !value.hasOwnProperty(require("./RelayStoreUtils").REFS_KEY)) ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelayModernRecord.getValue(): Expected a scalar (non-link) value for `%s.%s` ' + 'but found %s.', record[require("./RelayStoreUtils").ID_KEY], storageKey, value.hasOwnProperty(require("./RelayStoreUtils").REF_KEY) ? 'a linked record' : 'plural linked records') : require("fbjs/lib/invariant")(false) : void 0;
130
133
  }
134
+
131
135
  return value;
132
136
  }
133
-
134
137
  /**
135
138
  * @public
136
139
  *
137
140
  * Get the value of a field as a reference to another record. Throws if the
138
141
  * field has a different type.
139
142
  */
143
+
144
+
140
145
  function getLinkedRecordID(record, storageKey) {
141
146
  var link = record[storageKey];
147
+
142
148
  if (link == null) {
143
149
  return link;
144
150
  }
145
- !(typeof link === 'object' && link && typeof link[require('./RelayStoreUtils').REF_KEY] === 'string') ? process.env.NODE_ENV !== 'production' ? require('fbjs/lib/invariant')(false, 'RelayModernRecord.getLinkedRecordID(): Expected `%s.%s` to be a linked ID, ' + 'was `%s`.', record[require('./RelayStoreUtils').ID_KEY], storageKey, link) : require('fbjs/lib/invariant')(false) : void 0;
146
- return link[require('./RelayStoreUtils').REF_KEY];
147
- }
148
151
 
152
+ !(typeof link === 'object' && link && typeof link[require("./RelayStoreUtils").REF_KEY] === 'string') ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelayModernRecord.getLinkedRecordID(): Expected `%s.%s` to be a linked ID, ' + 'was `%s`.', record[require("./RelayStoreUtils").ID_KEY], storageKey, JSON.stringify(link)) : require("fbjs/lib/invariant")(false) : void 0;
153
+ return link[require("./RelayStoreUtils").REF_KEY];
154
+ }
149
155
  /**
150
156
  * @public
151
157
  *
152
158
  * Get the value of a field as a list of references to other records. Throws if
153
159
  * the field has a different type.
154
160
  */
161
+
162
+
155
163
  function getLinkedRecordIDs(record, storageKey) {
156
164
  var links = record[storageKey];
165
+
157
166
  if (links == null) {
158
167
  return links;
159
168
  }
160
- !(typeof links === 'object' && Array.isArray(links[require('./RelayStoreUtils').REFS_KEY])) ? process.env.NODE_ENV !== 'production' ? require('fbjs/lib/invariant')(false, 'RelayModernRecord.getLinkedRecordIDs(): Expected `%s.%s` to contain an array ' + 'of linked IDs, got `%s`.', record[require('./RelayStoreUtils').ID_KEY], storageKey, JSON.stringify(links)) : require('fbjs/lib/invariant')(false) : void 0;
161
- // assume items of the array are ids
162
- return links[require('./RelayStoreUtils').REFS_KEY];
163
- }
164
169
 
170
+ !(typeof links === 'object' && Array.isArray(links[require("./RelayStoreUtils").REFS_KEY])) ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelayModernRecord.getLinkedRecordIDs(): Expected `%s.%s` to contain an array ' + 'of linked IDs, got `%s`.', record[require("./RelayStoreUtils").ID_KEY], storageKey, JSON.stringify(links)) : require("fbjs/lib/invariant")(false) : void 0; // assume items of the array are ids
171
+
172
+ return links[require("./RelayStoreUtils").REFS_KEY];
173
+ }
165
174
  /**
166
175
  * @public
167
176
  *
@@ -169,73 +178,123 @@ function getLinkedRecordIDs(record, storageKey) {
169
178
  * previous record if all fields are equal or a new record (with merged fields)
170
179
  * if any fields have changed.
171
180
  */
181
+
182
+
172
183
  function update(prevRecord, nextRecord) {
173
- var updated = void 0;
184
+ if (process.env.NODE_ENV !== "production") {
185
+ var _getType, _getType2;
186
+
187
+ var prevID = getDataID(prevRecord);
188
+ var nextID = getDataID(nextRecord);
189
+ process.env.NODE_ENV !== "production" ? require("fbjs/lib/warning")(prevID === nextID, 'RelayModernRecord: Invalid record update, expected both versions of ' + 'the record to have the same id, got `%s` and `%s`.', prevID, nextID) : void 0; // note: coalesce null/undefined to null
190
+
191
+ var prevType = (_getType = getType(prevRecord)) !== null && _getType !== void 0 ? _getType : null;
192
+ var nextType = (_getType2 = getType(nextRecord)) !== null && _getType2 !== void 0 ? _getType2 : null;
193
+ process.env.NODE_ENV !== "production" ? require("fbjs/lib/warning")(prevType === nextType, 'RelayModernRecord: Invalid record update, expected both versions of ' + 'record `%s` to have the same `%s` but got conflicting types `%s` ' + 'and `%s`. The GraphQL server likely violated the globally unique ' + 'id requirement by returning the same id for different objects.', prevID, require("./RelayStoreUtils").TYPENAME_KEY, prevType, nextType) : void 0;
194
+ }
195
+
196
+ var updated = null;
174
197
  var keys = Object.keys(nextRecord);
198
+
175
199
  for (var ii = 0; ii < keys.length; ii++) {
176
200
  var key = keys[ii];
177
- if (updated || !require('fbjs/lib/areEqual')(prevRecord[key], nextRecord[key])) {
178
- updated = updated || (0, _extends3['default'])({}, prevRecord);
179
- if (nextRecord[key] !== require('./RelayStoreUtils').UNPUBLISH_FIELD_SENTINEL) {
201
+
202
+ if (updated || !require("fbjs/lib/areEqual")(prevRecord[key], nextRecord[key])) {
203
+ updated = updated !== null ? updated : (0, _objectSpread2["default"])({}, prevRecord);
204
+
205
+ if (nextRecord[key] !== require("./RelayStoreUtils").UNPUBLISH_FIELD_SENTINEL) {
180
206
  updated[key] = nextRecord[key];
181
207
  } else {
182
208
  delete updated[key];
183
209
  }
184
210
  }
185
211
  }
186
- return updated || prevRecord;
187
- }
188
212
 
213
+ return updated !== null ? updated : prevRecord;
214
+ }
189
215
  /**
190
216
  * @public
191
217
  *
192
218
  * Returns a new record with the contents of the given records. Fields in the
193
219
  * second record will overwrite identical fields in the first record.
194
220
  */
221
+
222
+
195
223
  function merge(record1, record2) {
224
+ if (process.env.NODE_ENV !== "production") {
225
+ var _getType3, _getType4;
226
+
227
+ var prevID = getDataID(record1);
228
+ var nextID = getDataID(record2);
229
+ process.env.NODE_ENV !== "production" ? require("fbjs/lib/warning")(prevID === nextID, 'RelayModernRecord: Invalid record merge, expected both versions of ' + 'the record to have the same id, got `%s` and `%s`.', prevID, nextID) : void 0; // note: coalesce null/undefined to null
230
+
231
+ var prevType = (_getType3 = getType(record1)) !== null && _getType3 !== void 0 ? _getType3 : null;
232
+ var nextType = (_getType4 = getType(record2)) !== null && _getType4 !== void 0 ? _getType4 : null;
233
+ process.env.NODE_ENV !== "production" ? require("fbjs/lib/warning")(prevType === nextType, 'RelayModernRecord: Invalid record merge, expected both versions of ' + 'record `%s` to have the same `%s` but got conflicting types `%s` ' + 'and `%s`. The GraphQL server likely violated the globally unique ' + 'id requirement by returning the same id for different objects.', prevID, require("./RelayStoreUtils").TYPENAME_KEY, prevType, nextType) : void 0;
234
+ }
235
+
196
236
  return Object.assign({}, record1, record2);
197
237
  }
198
-
199
238
  /**
200
239
  * @public
201
240
  *
202
241
  * Prevent modifications to the record. Attempts to call `set*` functions on a
203
242
  * frozen record will fatal at runtime.
204
243
  */
244
+
245
+
205
246
  function freeze(record) {
206
- require('./deepFreeze')(record);
247
+ require("./deepFreeze")(record);
207
248
  }
208
-
209
249
  /**
210
250
  * @public
211
251
  *
212
252
  * Set the value of a storageKey to a scalar.
213
253
  */
254
+
255
+
214
256
  function setValue(record, storageKey, value) {
257
+ if (process.env.NODE_ENV !== "production") {
258
+ var prevID = getDataID(record);
259
+
260
+ if (storageKey === require("./RelayStoreUtils").ID_KEY) {
261
+ process.env.NODE_ENV !== "production" ? require("fbjs/lib/warning")(prevID === value, 'RelayModernRecord: Invalid field update, expected both versions of ' + 'the record to have the same id, got `%s` and `%s`.', prevID, value) : void 0;
262
+ } else if (storageKey === require("./RelayStoreUtils").TYPENAME_KEY) {
263
+ var _getType5, _value;
264
+
265
+ // note: coalesce null/undefined to null
266
+ var prevType = (_getType5 = getType(record)) !== null && _getType5 !== void 0 ? _getType5 : null;
267
+ var nextType = (_value = value) !== null && _value !== void 0 ? _value : null;
268
+ process.env.NODE_ENV !== "production" ? require("fbjs/lib/warning")(prevType === nextType, 'RelayModernRecord: Invalid field update, expected both versions of ' + 'record `%s` to have the same `%s` but got conflicting types `%s` ' + 'and `%s`. The GraphQL server likely violated the globally unique ' + 'id requirement by returning the same id for different objects.', prevID, require("./RelayStoreUtils").TYPENAME_KEY, prevType, nextType) : void 0;
269
+ }
270
+ }
271
+
215
272
  record[storageKey] = value;
216
273
  }
217
-
218
274
  /**
219
275
  * @public
220
276
  *
221
277
  * Set the value of a field to a reference to another record.
222
278
  */
279
+
280
+
223
281
  function setLinkedRecordID(record, storageKey, linkedID) {
224
282
  // See perf note above for why we aren't using computed property access.
225
283
  var link = {};
226
- link[require('./RelayStoreUtils').REF_KEY] = linkedID;
284
+ link[require("./RelayStoreUtils").REF_KEY] = linkedID;
227
285
  record[storageKey] = link;
228
286
  }
229
-
230
287
  /**
231
288
  * @public
232
289
  *
233
290
  * Set the value of a field to a list of references other records.
234
291
  */
292
+
293
+
235
294
  function setLinkedRecordIDs(record, storageKey, linkedIDs) {
236
295
  // See perf note above for why we aren't using computed property access.
237
296
  var links = {};
238
- links[require('./RelayStoreUtils').REFS_KEY] = linkedIDs;
297
+ links[require("./RelayStoreUtils").REFS_KEY] = linkedIDs;
239
298
  record[storageKey] = links;
240
299
  }
241
300