relay-runtime 1.3.0 → 1.5.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 (90) hide show
  1. package/LICENSE +16 -26
  2. package/index.js +3 -6
  3. package/lib/ConvertToExecuteFunction.js +73 -0
  4. package/lib/RelayConcreteNode.js +31 -14
  5. package/lib/RelayConcreteVariables.js +11 -6
  6. package/lib/RelayConnectionHandler.js +2 -4
  7. package/lib/RelayConnectionInterface.js +3 -5
  8. package/lib/RelayCore.js +4 -6
  9. package/lib/RelayDataLoader.js +2 -4
  10. package/lib/RelayDeclarativeMutationConfig.js +316 -0
  11. package/lib/RelayDefaultHandleKey.js +2 -4
  12. package/lib/RelayDefaultHandlerProvider.js +2 -4
  13. package/lib/RelayError.js +2 -6
  14. package/lib/RelayInMemoryRecordSource.js +2 -4
  15. package/lib/RelayInternalTypes.js +2 -5
  16. package/lib/RelayInternals.js +2 -5
  17. package/lib/RelayMarkSweepStore.js +22 -5
  18. package/lib/RelayMetricsRecorder.js +9 -9
  19. package/lib/RelayMockRenderer.js +3 -8
  20. package/lib/RelayModernEnvironment.js +120 -135
  21. package/lib/RelayModernFragmentSpecResolver.js +81 -55
  22. package/lib/RelayModernGraphQLTag.js +8 -17
  23. package/lib/RelayModernOperationSelector.js +8 -8
  24. package/lib/RelayModernRecord.js +8 -8
  25. package/lib/RelayModernSelector.js +54 -43
  26. package/lib/RelayNetwork.js +9 -11
  27. package/lib/RelayNetworkDebug.js +4 -7
  28. package/lib/RelayNetworkLogger.js +2 -4
  29. package/lib/RelayNetworkLoggerTransaction.js +18 -20
  30. package/lib/RelayNetworkTypes.js +2 -4
  31. package/lib/RelayObservable.js +193 -120
  32. package/lib/RelayProfiler.js +7 -7
  33. package/lib/RelayPublishQueue.js +17 -9
  34. package/lib/RelayQueryCaching.js +2 -5
  35. package/lib/RelayQueryResponseCache.js +3 -5
  36. package/lib/RelayReader.js +18 -8
  37. package/lib/RelayRecordProxy.js +12 -11
  38. package/lib/RelayRecordSourceMutator.js +9 -9
  39. package/lib/RelayRecordSourceProxy.js +15 -13
  40. package/lib/RelayRecordSourceSelectorProxy.js +2 -4
  41. package/lib/RelayRecordState.js +2 -4
  42. package/lib/RelayReferenceMarker.js +2 -4
  43. package/lib/RelayResponseNormalizer.js +34 -25
  44. package/lib/RelayRuntime.js +25 -14
  45. package/lib/RelayRuntimeTypes.js +22 -0
  46. package/lib/RelayShallowMock.js +4 -7
  47. package/lib/RelayStoreTypes.js +2 -4
  48. package/lib/RelayStoreUtils.js +66 -26
  49. package/lib/RelayTaskQueue.js +2 -5
  50. package/lib/RelayTypes.js +2 -5
  51. package/lib/RelayViewerHandler.js +4 -5
  52. package/lib/applyRelayModernOptimisticMutation.js +9 -8
  53. package/lib/cloneRelayHandleSourceField.js +4 -11
  54. package/lib/commitLocalUpdate.js +2 -4
  55. package/lib/commitRelayModernMutation.js +24 -22
  56. package/lib/createRelayNetworkLogger.js +25 -27
  57. package/lib/dedent.js +2 -5
  58. package/lib/deepFreeze.js +3 -5
  59. package/lib/deferrableFragmentKey.js +21 -0
  60. package/lib/fetchRelayModernQuery.js +13 -21
  61. package/lib/generateRelayClientID.js +2 -4
  62. package/lib/getRelayHandleKey.js +2 -4
  63. package/lib/hasOverlappingIDs.js +2 -4
  64. package/lib/isCompatibleRelayFragmentType.js +2 -5
  65. package/lib/isPromise.js +2 -5
  66. package/lib/isRelayModernEnvironment.js +2 -4
  67. package/lib/isScalarAndEqual.js +3 -5
  68. package/lib/normalizePayload.js +10 -13
  69. package/lib/normalizeRelayPayload.js +8 -5
  70. package/lib/recycleNodesInto.js +2 -4
  71. package/lib/relayUnstableBatchedUpdates.js +2 -5
  72. package/lib/relayUnstableBatchedUpdates.native.js +2 -5
  73. package/lib/requestRelaySubscription.js +20 -34
  74. package/lib/simpleClone.js +2 -4
  75. package/lib/stableCopy.js +35 -0
  76. package/lib/testEditDistance.js +2 -5
  77. package/lib/throwFailedPromise.js +2 -5
  78. package/package.json +4 -5
  79. package/relay-runtime.js +2307 -2665
  80. package/relay-runtime.min.js +6 -9
  81. package/ARCHITECTURE.md +0 -232
  82. package/PATENTS +0 -33
  83. package/lib/ConvertToObserveFunction.js +0 -39
  84. package/lib/RelayDebugger.js +0 -199
  85. package/lib/RelayRecordSourceInspector.js +0 -289
  86. package/lib/RelayStoreProxyDebugger.js +0 -44
  87. package/lib/formatStorageKey.js +0 -37
  88. package/lib/prettyStringify.js +0 -35
  89. package/lib/setRelayModernMutationConfigs.js +0 -302
  90. package/lib/stableJSONStringify.js +0 -45
@@ -1,10 +1,8 @@
1
1
  /**
2
2
  * Copyright (c) 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
3
  *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
8
6
  *
9
7
  * @providesModule RelayModernFragmentSpecResolver
10
8
  *
@@ -65,78 +63,96 @@ var RelayModernFragmentSpecResolver = function () {
65
63
  }
66
64
 
67
65
  RelayModernFragmentSpecResolver.prototype.dispose = function dispose() {
68
- require('fbjs/lib/forEachObject')(this._resolvers, disposeCallback);
66
+ for (var _key in this._resolvers) {
67
+ if (this._resolvers.hasOwnProperty(_key)) {
68
+ disposeCallback(this._resolvers[_key]);
69
+ }
70
+ }
69
71
  };
70
72
 
71
73
  RelayModernFragmentSpecResolver.prototype.resolve = function resolve() {
72
- var _this2 = this;
73
-
74
74
  if (this._stale) {
75
75
  // Avoid mapping the object multiple times, which could occur if data for
76
76
  // multiple keys changes in the same event loop.
77
77
  var prevData = this._data;
78
78
  var nextData = void 0;
79
- require('fbjs/lib/forEachObject')(this._resolvers, function (resolver, key) {
80
- var prevItem = prevData[key];
81
- if (resolver) {
82
- var nextItem = resolver.resolve();
83
- if (nextData || nextItem !== prevItem) {
84
- nextData = nextData || (0, _extends3['default'])({}, prevData);
85
- nextData[key] = nextItem;
86
- }
87
- } else {
88
- var prop = _this2._props[key];
89
- var _nextItem = prop !== undefined ? prop : null;
90
- if (nextData || !require('./isScalarAndEqual')(_nextItem, prevItem)) {
91
- nextData = nextData || (0, _extends3['default'])({}, prevData);
92
- nextData[key] = _nextItem;
79
+ for (var _key2 in this._resolvers) {
80
+ if (this._resolvers.hasOwnProperty(_key2)) {
81
+ var resolver = this._resolvers[_key2];
82
+ var prevItem = prevData[_key2];
83
+ if (resolver) {
84
+ var nextItem = resolver.resolve();
85
+ if (nextData || nextItem !== prevItem) {
86
+ nextData = nextData || (0, _extends3['default'])({}, prevData);
87
+ nextData[_key2] = nextItem;
88
+ }
89
+ } else {
90
+ var prop = this._props[_key2];
91
+ var _nextItem = prop !== undefined ? prop : null;
92
+ if (nextData || !require('./isScalarAndEqual')(_nextItem, prevItem)) {
93
+ nextData = nextData || (0, _extends3['default'])({}, prevData);
94
+ nextData[_key2] = _nextItem;
95
+ }
93
96
  }
94
97
  }
95
- });
98
+ }
96
99
  this._data = nextData || prevData;
97
100
  this._stale = false;
98
101
  }
99
102
  return this._data;
100
103
  };
101
104
 
102
- RelayModernFragmentSpecResolver.prototype.setProps = function setProps(props) {
103
- var _this3 = this;
105
+ RelayModernFragmentSpecResolver.prototype.isLoading = function isLoading() {
106
+ for (var _key3 in this._resolvers) {
107
+ if (this._resolvers.hasOwnProperty(_key3) && this._resolvers[_key3] && this._resolvers[_key3].isLoading()) {
108
+ return true;
109
+ }
110
+ }
111
+ return false;
112
+ };
104
113
 
114
+ RelayModernFragmentSpecResolver.prototype.setProps = function setProps(props) {
105
115
  var selectors = getSelectorsFromObject(this._context.variables, this._fragments, props);
106
- require('fbjs/lib/forEachObject')(selectors, function (selector, key) {
107
- var resolver = _this3._resolvers[key];
108
- if (selector == null) {
109
- if (resolver != null) {
110
- resolver.dispose();
111
- }
112
- resolver = null;
113
- } else if (Array.isArray(selector)) {
114
- if (resolver == null) {
115
- resolver = new SelectorListResolver(_this3._context.environment, selector, _this3._onChange);
116
- } else {
117
- require('fbjs/lib/invariant')(resolver instanceof SelectorListResolver, 'RelayModernFragmentSpecResolver: Expected prop `%s` to always be an array.', key);
118
- resolver.setSelectors(selector);
119
- }
120
- } else {
121
- if (resolver == null) {
122
- resolver = new SelectorResolver(_this3._context.environment, selector, _this3._onChange);
116
+ for (var _key4 in selectors) {
117
+ if (selectors.hasOwnProperty(_key4)) {
118
+ var selector = selectors[_key4];
119
+ var resolver = this._resolvers[_key4];
120
+ if (selector == null) {
121
+ if (resolver != null) {
122
+ resolver.dispose();
123
+ }
124
+ resolver = null;
125
+ } else if (Array.isArray(selector)) {
126
+ if (resolver == null) {
127
+ resolver = new SelectorListResolver(this._context.environment, selector, this._onChange);
128
+ } else {
129
+ require('fbjs/lib/invariant')(resolver instanceof SelectorListResolver, 'RelayModernFragmentSpecResolver: Expected prop `%s` to always be an array.', _key4);
130
+ resolver.setSelectors(selector);
131
+ }
123
132
  } else {
124
- require('fbjs/lib/invariant')(resolver instanceof SelectorResolver, 'RelayModernFragmentSpecResolver: Expected prop `%s` to always be an object.', key);
125
- resolver.setSelector(selector);
133
+ if (resolver == null) {
134
+ resolver = new SelectorResolver(this._context.environment, selector, this._onChange);
135
+ } else {
136
+ require('fbjs/lib/invariant')(resolver instanceof SelectorResolver, 'RelayModernFragmentSpecResolver: Expected prop `%s` to always be an object.', _key4);
137
+ resolver.setSelector(selector);
138
+ }
126
139
  }
140
+ this._resolvers[_key4] = resolver;
127
141
  }
128
- _this3._resolvers[key] = resolver;
129
- });
142
+ }
130
143
  this._props = props;
131
144
  this._stale = true;
132
145
  };
133
146
 
134
147
  RelayModernFragmentSpecResolver.prototype.setVariables = function setVariables(variables) {
135
- require('fbjs/lib/forEachObject')(this._resolvers, function (resolver) {
136
- if (resolver) {
137
- resolver.setVariables(variables);
148
+ for (var _key5 in this._resolvers) {
149
+ if (this._resolvers.hasOwnProperty(_key5)) {
150
+ var resolver = this._resolvers[_key5];
151
+ if (resolver) {
152
+ resolver.setVariables(variables);
153
+ }
138
154
  }
139
- });
155
+ }
140
156
  this._stale = true;
141
157
  };
142
158
 
@@ -191,6 +207,10 @@ var SelectorResolver = function () {
191
207
  this.setSelector(selector);
192
208
  };
193
209
 
210
+ SelectorResolver.prototype.isLoading = function isLoading() {
211
+ return this._environment.isSelectorLoading(this._selector);
212
+ };
213
+
194
214
  return SelectorResolver;
195
215
  }();
196
216
 
@@ -200,23 +220,23 @@ var SelectorResolver = function () {
200
220
 
201
221
 
202
222
  var _initialiseProps = function _initialiseProps() {
203
- var _this5 = this;
223
+ var _this3 = this;
204
224
 
205
225
  this._onChange = function (snapshot) {
206
- _this5._data = snapshot.data;
207
- _this5._callback();
226
+ _this3._data = snapshot.data;
227
+ _this3._callback();
208
228
  };
209
229
  };
210
230
 
211
231
  var SelectorListResolver = function () {
212
232
  function SelectorListResolver(environment, selectors, callback) {
213
- var _this4 = this;
233
+ var _this2 = this;
214
234
 
215
235
  (0, _classCallCheck3['default'])(this, SelectorListResolver);
216
236
 
217
237
  this._onChange = function (data) {
218
- _this4._stale = true;
219
- _this4._callback();
238
+ _this2._stale = true;
239
+ _this2._callback();
220
240
  };
221
241
 
222
242
  this._callback = callback;
@@ -277,6 +297,12 @@ var SelectorListResolver = function () {
277
297
  this._stale = true;
278
298
  };
279
299
 
300
+ SelectorListResolver.prototype.isLoading = function isLoading() {
301
+ return this._resolvers.some(function (resolver) {
302
+ return resolver.isLoading();
303
+ });
304
+ };
305
+
280
306
  return SelectorListResolver;
281
307
  }();
282
308
 
@@ -1,10 +1,8 @@
1
1
  /**
2
2
  * Copyright (c) 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
3
  *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
8
6
  *
9
7
  * @providesModule RelayModernGraphQLTag
10
8
  *
@@ -24,13 +22,6 @@ function graphql(strings) {
24
22
  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`.');
25
23
  }
26
24
 
27
- /**
28
- * Variant of the `graphql` tag that enables experimental features.
29
- */
30
- graphql.experimental = function (strings) {
31
- require('fbjs/lib/invariant')(false, 'graphql.experimental: 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`.');
32
- };
33
-
34
25
  function getNode(taggedNode) {
35
26
  var fn = typeof taggedNode === 'function' ? taggedNode : taggedNode.modern;
36
27
  // Support for classic raw nodes (used in test mock)
@@ -42,18 +33,18 @@ function getNode(taggedNode) {
42
33
 
43
34
  function getFragment(taggedNode) {
44
35
  var fragment = getNode(taggedNode);
45
- require('fbjs/lib/invariant')(typeof fragment === 'object' && fragment !== null && fragment.kind === 'Fragment', 'RelayModernGraphQLTag: Expected a fragment, got `%s`.', JSON.stringify(fragment));
36
+ require('fbjs/lib/invariant')(typeof fragment === 'object' && fragment !== null && fragment.kind === require('./RelayConcreteNode').FRAGMENT, 'RelayModernGraphQLTag: Expected a fragment, got `%s`.', JSON.stringify(fragment));
46
37
  return fragment;
47
38
  }
48
39
 
49
- function getOperation(taggedNode) {
50
- var operation = getNode(taggedNode);
51
- require('fbjs/lib/invariant')(typeof operation === 'object' && operation !== null && operation.kind === 'Batch', 'RelayModernGraphQLTag: Expected an operation, got `%s`.', JSON.stringify(operation));
52
- return operation;
40
+ function getRequest(taggedNode) {
41
+ var request = getNode(taggedNode);
42
+ require('fbjs/lib/invariant')(typeof request === 'object' && request !== null && (request.kind === require('./RelayConcreteNode').REQUEST || request.kind === require('./RelayConcreteNode').BATCH_REQUEST), 'RelayModernGraphQLTag: Expected an request, got `%s`.', JSON.stringify(request));
43
+ return request;
53
44
  }
54
45
 
55
46
  module.exports = {
56
47
  getFragment: getFragment,
57
- getOperation: getOperation,
48
+ getRequest: getRequest,
58
49
  graphql: graphql
59
50
  };
@@ -1,10 +1,8 @@
1
1
  /**
2
2
  * Copyright (c) 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
3
  *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
8
6
  *
9
7
  * @providesModule RelayModernOperationSelector
10
8
  *
@@ -25,19 +23,21 @@ var _require2 = require('./RelayStoreUtils'),
25
23
  * are filtered to exclude variables that do not match defined arguments on the
26
24
  * operation, and default values are populated for null values.
27
25
  */
28
- function createOperationSelector(operation, variables) {
26
+ function createOperationSelector(request, variables, operationFromBatch) {
27
+ var operation = operationFromBatch || (request.kind === require('./RelayConcreteNode').BATCH_REQUEST ? request.requests[0].operation : request.operation);
28
+
29
29
  var operationVariables = getOperationVariables(operation, variables);
30
30
  var dataID = ROOT_ID;
31
31
  return {
32
32
  fragment: {
33
33
  dataID: dataID,
34
- node: operation.fragment,
34
+ node: request.fragment,
35
35
  variables: operationVariables
36
36
  },
37
- node: operation,
37
+ node: request,
38
38
  root: {
39
39
  dataID: dataID,
40
- node: operation.query,
40
+ node: operation,
41
41
  variables: operationVariables
42
42
  },
43
43
  variables: operationVariables
@@ -1,10 +1,8 @@
1
1
  /**
2
2
  * Copyright (c) 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
3
  *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
8
6
  *
9
7
  * @providesModule RelayModernRecord
10
8
  *
@@ -88,11 +86,13 @@ function clone(record) {
88
86
  * copied on write.
89
87
  */
90
88
  function copyFields(source, sink) {
91
- require('fbjs/lib/forEachObject')(source, function (value, key) {
92
- if (key !== ID_KEY && key !== TYPENAME_KEY) {
93
- sink[key] = value;
89
+ for (var key in source) {
90
+ if (source.hasOwnProperty(key)) {
91
+ if (key !== ID_KEY && key !== TYPENAME_KEY) {
92
+ sink[key] = source[key];
93
+ }
94
94
  }
95
- });
95
+ }
96
96
  }
97
97
 
98
98
  /**
@@ -1,10 +1,8 @@
1
1
  /**
2
2
  * Copyright (c) 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
3
  *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
8
6
  *
9
7
  * @providesModule RelayModernSelector
10
8
  *
@@ -98,18 +96,21 @@ function getSelectorList(operationVariables, fragment, items) {
98
96
  */
99
97
  function getSelectorsFromObject(operationVariables, fragments, object) {
100
98
  var selectors = {};
101
- require('fbjs/lib/forEachObject')(fragments, function (fragment, key) {
102
- var item = object[key];
103
- if (item == null) {
104
- selectors[key] = item;
105
- } else if (fragment.metadata && fragment.metadata.plural === true) {
106
- require('fbjs/lib/invariant')(Array.isArray(item), 'RelayModernSelector: Expected value for key `%s` to be an array, got `%s`. ' + 'Remove `@relay(plural: true)` from fragment `%s` to allow the prop to be an object.', key, JSON.stringify(item), fragment.name);
107
- selectors[key] = getSelectorList(operationVariables, fragment, item);
108
- } else {
109
- require('fbjs/lib/invariant')(!Array.isArray(item), 'RelayModernFragmentSpecResolver: Expected value for key `%s` to be an object, got `%s`. ' + 'Add `@relay(plural: true)` to fragment `%s` to allow the prop to be an array of items.', key, JSON.stringify(item), fragment.name);
110
- selectors[key] = getSelector(operationVariables, fragment, item);
99
+ for (var _key in fragments) {
100
+ if (fragments.hasOwnProperty(_key)) {
101
+ var fragment = fragments[_key];
102
+ var item = object[_key];
103
+ if (item == null) {
104
+ selectors[_key] = item;
105
+ } else if (fragment.metadata && fragment.metadata.plural === true) {
106
+ require('fbjs/lib/invariant')(Array.isArray(item), 'RelayModernSelector: Expected value for key `%s` to be an array, got `%s`. ' + 'Remove `@relay(plural: true)` from fragment `%s` to allow the prop to be an object.', _key, JSON.stringify(item), fragment.name);
107
+ selectors[_key] = getSelectorList(operationVariables, fragment, item);
108
+ } else {
109
+ require('fbjs/lib/invariant')(!Array.isArray(item), 'RelayModernFragmentSpecResolver: Expected value for key `%s` to be an object, got `%s`. ' + 'Add `@relay(plural: true)` to fragment `%s` to allow the prop to be an array of items.', _key, JSON.stringify(item), fragment.name);
110
+ selectors[_key] = getSelector(operationVariables, fragment, item);
111
+ }
111
112
  }
112
- });
113
+ }
113
114
  return selectors;
114
115
  }
115
116
 
@@ -124,18 +125,21 @@ function getSelectorsFromObject(operationVariables, fragments, object) {
124
125
  */
125
126
  function getDataIDsFromObject(fragments, object) {
126
127
  var ids = {};
127
- require('fbjs/lib/forEachObject')(fragments, function (fragment, key) {
128
- var item = object[key];
129
- if (item == null) {
130
- ids[key] = item;
131
- } else if (fragment.metadata && fragment.metadata.plural === true) {
132
- require('fbjs/lib/invariant')(Array.isArray(item), 'RelayModernSelector: Expected value for key `%s` to be an array, got `%s`. ' + 'Remove `@relay(plural: true)` from fragment `%s` to allow the prop to be an object.', key, JSON.stringify(item), fragment.name);
133
- ids[key] = getDataIDs(fragment, item);
134
- } else {
135
- require('fbjs/lib/invariant')(!Array.isArray(item), 'RelayModernFragmentSpecResolver: Expected value for key `%s` to be an object, got `%s`. ' + 'Add `@relay(plural: true)` to fragment `%s` to allow the prop to be an array of items.', key, JSON.stringify(item), fragment.name);
136
- ids[key] = getDataID(fragment, item);
128
+ for (var _key2 in fragments) {
129
+ if (fragments.hasOwnProperty(_key2)) {
130
+ var fragment = fragments[_key2];
131
+ var item = object[_key2];
132
+ if (item == null) {
133
+ ids[_key2] = item;
134
+ } else if (fragment.metadata && fragment.metadata.plural === true) {
135
+ require('fbjs/lib/invariant')(Array.isArray(item), 'RelayModernSelector: Expected value for key `%s` to be an array, got `%s`. ' + 'Remove `@relay(plural: true)` from fragment `%s` to allow the prop to be an object.', _key2, JSON.stringify(item), fragment.name);
136
+ ids[_key2] = getDataIDs(fragment, item);
137
+ } else {
138
+ require('fbjs/lib/invariant')(!Array.isArray(item), 'RelayModernFragmentSpecResolver: Expected value for key `%s` to be an object, got `%s`. ' + 'Add `@relay(plural: true)` to fragment `%s` to allow the prop to be an array of items.', _key2, JSON.stringify(item), fragment.name);
139
+ ids[_key2] = getDataID(fragment, item);
140
+ }
137
141
  }
138
- });
142
+ }
139
143
  return ids;
140
144
  }
141
145
 
@@ -179,28 +183,35 @@ function getDataID(fragment, item) {
179
183
  */
180
184
  function getVariablesFromObject(operationVariables, fragments, object) {
181
185
  var variables = {};
182
- require('fbjs/lib/forEachObject')(fragments, function (fragment, key) {
183
- var item = object[key];
184
- if (item == null) {
185
- return;
186
- } else if (fragment.metadata && fragment.metadata.plural === true) {
187
- require('fbjs/lib/invariant')(Array.isArray(item), 'RelayModernSelector: Expected value for key `%s` to be an array, got `%s`. ' + 'Remove `@relay(plural: true)` from fragment `%s` to allow the prop to be an object.', key, JSON.stringify(item), fragment.name);
188
- item.forEach(function (value) {
189
- if (value != null) {
190
- var itemVariables = getVariables(operationVariables, fragment, value);
186
+ for (var _key3 in fragments) {
187
+ if (fragments.hasOwnProperty(_key3)) {
188
+ var _ret = function () {
189
+ var fragment = fragments[_key3];
190
+ var item = object[_key3];
191
+ if (item == null) {
192
+ return 'continue';
193
+ } else if (fragment.metadata && fragment.metadata.plural === true) {
194
+ require('fbjs/lib/invariant')(Array.isArray(item), 'RelayModernSelector: Expected value for key `%s` to be an array, got `%s`. ' + 'Remove `@relay(plural: true)` from fragment `%s` to allow the prop to be an object.', _key3, JSON.stringify(item), fragment.name);
195
+ item.forEach(function (value) {
196
+ if (value != null) {
197
+ var itemVariables = getVariables(operationVariables, fragment, value);
198
+ if (itemVariables) {
199
+ Object.assign(variables, itemVariables);
200
+ }
201
+ }
202
+ });
203
+ } else {
204
+ require('fbjs/lib/invariant')(!Array.isArray(item), 'RelayModernFragmentSpecResolver: Expected value for key `%s` to be an object, got `%s`. ' + 'Add `@relay(plural: true)` to fragment `%s` to allow the prop to be an array of items.', _key3, JSON.stringify(item), fragment.name);
205
+ var itemVariables = getVariables(operationVariables, fragment, item);
191
206
  if (itemVariables) {
192
207
  Object.assign(variables, itemVariables);
193
208
  }
194
209
  }
195
- });
196
- } else {
197
- require('fbjs/lib/invariant')(!Array.isArray(item), 'RelayModernFragmentSpecResolver: Expected value for key `%s` to be an object, got `%s`. ' + 'Add `@relay(plural: true)` to fragment `%s` to allow the prop to be an array of items.', key, JSON.stringify(item), fragment.name);
198
- var itemVariables = getVariables(operationVariables, fragment, item);
199
- if (itemVariables) {
200
- Object.assign(variables, itemVariables);
201
- }
210
+ }();
211
+
212
+ if (_ret === 'continue') continue;
202
213
  }
203
- });
214
+ }
204
215
  return variables;
205
216
  }
206
217
 
@@ -1,10 +1,8 @@
1
1
  /**
2
2
  * Copyright (c) 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
3
  *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
8
6
  *
9
7
  * @providesModule RelayNetwork
10
8
  *
@@ -13,7 +11,7 @@
13
11
 
14
12
  'use strict';
15
13
 
16
- var _require = require('./ConvertToObserveFunction'),
14
+ var _require = require('./ConvertToExecuteFunction'),
17
15
  convertFetch = _require.convertFetch,
18
16
  convertSubscribe = _require.convertSubscribe;
19
17
 
@@ -26,24 +24,24 @@ function create(fetchFn, subscribeFn) {
26
24
  var observeFetch = convertFetch(fetchFn);
27
25
  var observeSubscribe = subscribeFn ? convertSubscribe(subscribeFn) : undefined;
28
26
 
29
- function observe(operation, variables, cacheConfig, uploadables) {
30
- if (operation.query.operation === 'subscription') {
27
+ function execute(request, variables, cacheConfig, uploadables) {
28
+ if (request.operationKind === 'subscription') {
31
29
  require('fbjs/lib/invariant')(observeSubscribe, 'RelayNetwork: This network layer does not support Subscriptions. ' + 'To use Subscriptions, provide a custom network layer.');
32
30
 
33
31
  require('fbjs/lib/invariant')(!uploadables, 'RelayNetwork: Cannot provide uploadables while subscribing.');
34
- return observeSubscribe(operation, variables, cacheConfig);
32
+ return observeSubscribe(request, variables, cacheConfig);
35
33
  }
36
34
 
37
35
  var pollInterval = cacheConfig.poll;
38
36
  if (pollInterval != null) {
39
37
  require('fbjs/lib/invariant')(!uploadables, 'RelayNetwork: Cannot provide uploadables while polling.');
40
- return observeFetch(operation, variables, { force: true }).poll(pollInterval);
38
+ return observeFetch(request, variables, { force: true }).poll(pollInterval);
41
39
  }
42
40
 
43
- return observeFetch(operation, variables, cacheConfig, uploadables);
41
+ return observeFetch(request, variables, cacheConfig, uploadables);
44
42
  }
45
43
 
46
- return { observe: observe };
44
+ return { execute: execute };
47
45
  }
48
46
 
49
47
  module.exports = { create: create };
@@ -1,12 +1,9 @@
1
1
  /**
2
2
  * Copyright (c) 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
3
  *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
8
6
  *
9
- * @providesModule RelayNetworkDebug
10
7
  *
11
8
  * @format
12
9
  */
@@ -76,7 +73,6 @@ function createDebuggableFromRequest(type, request, graphiqlPrinter) {
76
73
  type: type,
77
74
  promise: request.getPromise(),
78
75
  logResult: function logResult(error, response) {
79
- /* eslint-disable no-console-disallow */
80
76
  var requestSize = formatSize(require('fbjs/lib/xhrSimpleDataSerializer')({
81
77
  q: request.getQueryString(),
82
78
  query_params: request.getVariables()
@@ -98,12 +94,13 @@ function createDebuggableFromRequest(type, request, graphiqlPrinter) {
98
94
  console.groupEnd();
99
95
 
100
96
  if (Object.keys(requestVariables).length > 0) {
97
+ // eslint-disable-next-line no-console
101
98
  console.log('Request Variables\n', request.getVariables());
102
99
  }
103
100
 
104
101
  error && console.error(error);
102
+ // eslint-disable-next-line no-console
105
103
  response && console.log(response);
106
- /* eslint-enable no-console-disallow */
107
104
  }
108
105
  };
109
106
  }
@@ -1,10 +1,8 @@
1
1
  /**
2
2
  * Copyright (c) 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
3
  *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
8
6
  *
9
7
  * @providesModule RelayNetworkLogger
10
8
  *