react-relay 2.0.0-rc.2 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (166) hide show
  1. package/index.js +2 -2
  2. package/lib/ReactRelayContext.js +6 -3
  3. package/lib/ReactRelayFragmentContainer.js +48 -46
  4. package/lib/ReactRelayFragmentMockRenderer.js +5 -1
  5. package/lib/ReactRelayPaginationContainer.js +102 -68
  6. package/lib/ReactRelayQueryFetcher.js +54 -28
  7. package/lib/ReactRelayQueryRenderer.js +28 -20
  8. package/lib/ReactRelayRefetchContainer.js +70 -58
  9. package/lib/ReactRelayTestMocker.js +56 -43
  10. package/lib/ReactRelayTypes.js +1 -1
  11. package/lib/RelayContext.js +8 -2
  12. package/lib/assertFragmentMap.js +9 -7
  13. package/lib/buildReactRelayContainer.js +32 -23
  14. package/lib/index.js +41 -0
  15. package/lib/isRelayEnvironment.js +1 -1
  16. package/lib/isRelayVariables.js +1 -1
  17. package/lib/readContext.js +7 -4
  18. package/package.json +4 -4
  19. package/react-relay.js +2 -2
  20. package/react-relay.min.js +2 -2
  21. package/classic.js +0 -10
  22. package/compat.js +0 -10
  23. package/lib/ConcreteQuery.js +0 -10
  24. package/lib/GraphQLQueryRunner.js +0 -264
  25. package/lib/GraphQLRange.js +0 -1124
  26. package/lib/GraphQLSegment.js +0 -743
  27. package/lib/GraphQLStoreChangeEmitter.js +0 -141
  28. package/lib/GraphQLStoreQueryResolver.js +0 -288
  29. package/lib/GraphQLStoreRangeUtils.js +0 -126
  30. package/lib/QueryBuilder.js +0 -228
  31. package/lib/ReactRelayClassicExports.js +0 -29
  32. package/lib/ReactRelayCompatContainerBuilder.js +0 -175
  33. package/lib/ReactRelayCompatPublic.js +0 -28
  34. package/lib/ReactRelayContainerProfiler.js +0 -30
  35. package/lib/ReactRelayFragmentContainer-flowtest.js +0 -201
  36. package/lib/ReactRelayPaginationContainer-flowtest.js +0 -213
  37. package/lib/ReactRelayPublic.js +0 -29
  38. package/lib/ReactRelayRefetchContainer-flowtest.js +0 -191
  39. package/lib/RelayCacheProcessor.js +0 -196
  40. package/lib/RelayChangeTracker.js +0 -83
  41. package/lib/RelayClassicContainerUtils.js +0 -49
  42. package/lib/RelayClassicCore.js +0 -34
  43. package/lib/RelayClassicRecordState.js +0 -31
  44. package/lib/RelayCompatContainer.js +0 -25
  45. package/lib/RelayCompatEnvironment.js +0 -27
  46. package/lib/RelayCompatMutations.js +0 -133
  47. package/lib/RelayCompatPaginationContainer.js +0 -27
  48. package/lib/RelayCompatRefetchContainer.js +0 -27
  49. package/lib/RelayCompatTypes.js +0 -10
  50. package/lib/RelayContainer.js +0 -889
  51. package/lib/RelayContainerComparators.js +0 -75
  52. package/lib/RelayContainerProxy.js +0 -21
  53. package/lib/RelayDefaultNetworkLayer.js +0 -192
  54. package/lib/RelayEnvironment.js +0 -449
  55. package/lib/RelayEnvironmentTypes.js +0 -10
  56. package/lib/RelayFetchMode.js +0 -17
  57. package/lib/RelayFragmentPointer.js +0 -161
  58. package/lib/RelayFragmentReference.js +0 -249
  59. package/lib/RelayFragmentSpecResolver.js +0 -305
  60. package/lib/RelayGraphQLMutation.js +0 -288
  61. package/lib/RelayGraphQLTag.js +0 -42
  62. package/lib/RelayInternalTypes.js +0 -15
  63. package/lib/RelayInternals.js +0 -24
  64. package/lib/RelayMetaRoute.js +0 -35
  65. package/lib/RelayMockRenderer.js +0 -71
  66. package/lib/RelayModern-flowtest.js +0 -342
  67. package/lib/RelayModernFlowtest_badref.graphql.js +0 -10
  68. package/lib/RelayModernFlowtest_notref.graphql.js +0 -10
  69. package/lib/RelayModernFlowtest_user.graphql.js +0 -10
  70. package/lib/RelayModernFlowtest_users.graphql.js +0 -10
  71. package/lib/RelayMutation.js +0 -322
  72. package/lib/RelayMutationDebugPrinter.js +0 -47
  73. package/lib/RelayMutationQuery.js +0 -558
  74. package/lib/RelayMutationQueue.js +0 -530
  75. package/lib/RelayMutationRequest.js +0 -103
  76. package/lib/RelayMutationTracker.js +0 -113
  77. package/lib/RelayMutationTransaction.js +0 -92
  78. package/lib/RelayMutationTransactionStatus.js +0 -55
  79. package/lib/RelayNetworkDebug.js +0 -131
  80. package/lib/RelayNetworkLayer.js +0 -185
  81. package/lib/RelayNodeInterface.js +0 -104
  82. package/lib/RelayOperationDescriptor.js +0 -40
  83. package/lib/RelayOptimisticMutationUtils.js +0 -208
  84. package/lib/RelayPendingQueryTracker.js +0 -166
  85. package/lib/RelayPropTypes.js +0 -57
  86. package/lib/RelayPublic.js +0 -44
  87. package/lib/RelayQL.js +0 -128
  88. package/lib/RelayQuery.js +0 -1584
  89. package/lib/RelayQueryCaching.js +0 -33
  90. package/lib/RelayQueryConfig.js +0 -58
  91. package/lib/RelayQueryPath.js +0 -204
  92. package/lib/RelayQueryRequest.js +0 -103
  93. package/lib/RelayQueryTracker.js +0 -86
  94. package/lib/RelayQueryTransform.js +0 -91
  95. package/lib/RelayQueryVisitor.js +0 -93
  96. package/lib/RelayQueryWriter.js +0 -573
  97. package/lib/RelayReadyState.js +0 -83
  98. package/lib/RelayReadyStateRenderer.js +0 -145
  99. package/lib/RelayRecord.js +0 -75
  100. package/lib/RelayRecordStatusMap.js +0 -57
  101. package/lib/RelayRecordStore.js +0 -433
  102. package/lib/RelayRecordWriter.js +0 -601
  103. package/lib/RelayRefQueryDescriptor.js +0 -27
  104. package/lib/RelayRenderer.js +0 -268
  105. package/lib/RelayRootContainer.js +0 -125
  106. package/lib/RelayRoute.js +0 -92
  107. package/lib/RelayRouteFragment.js +0 -44
  108. package/lib/RelaySelector.js +0 -201
  109. package/lib/RelayShallowMock.js +0 -69
  110. package/lib/RelayStaticContainer.js +0 -38
  111. package/lib/RelayStore.js +0 -12
  112. package/lib/RelayStoreConstants.js +0 -20
  113. package/lib/RelayStoreData.js +0 -660
  114. package/lib/RelayTaskQueue.js +0 -189
  115. package/lib/RelayTypes.js +0 -13
  116. package/lib/RelayVariable.js +0 -32
  117. package/lib/RelayVariables.js +0 -92
  118. package/lib/buildRQL.js +0 -160
  119. package/lib/callsFromGraphQL.js +0 -74
  120. package/lib/callsToGraphQL.js +0 -34
  121. package/lib/checkRelayQueryData.js +0 -250
  122. package/lib/createRelayQuery.js +0 -17
  123. package/lib/dedent.js +0 -49
  124. package/lib/diffRelayQuery.js +0 -757
  125. package/lib/directivesToGraphQL.js +0 -39
  126. package/lib/filterRelayQuery.js +0 -29
  127. package/lib/findRelayQueryLeaves.js +0 -293
  128. package/lib/flattenRelayQuery.js +0 -121
  129. package/lib/flattenSplitRelayQueries.js +0 -44
  130. package/lib/forEachRootCallArg.js +0 -40
  131. package/lib/fromGraphQL.js +0 -48
  132. package/lib/generateClientEdgeID.js +0 -22
  133. package/lib/generateClientID.js +0 -27
  134. package/lib/generateConcreteFragmentID.js +0 -30
  135. package/lib/generateForceIndex.js +0 -24
  136. package/lib/generateRQLFieldAlias.js +0 -39
  137. package/lib/getRangeBehavior.js +0 -58
  138. package/lib/getRelayQueries.js +0 -83
  139. package/lib/intersectRelayQuery.js +0 -149
  140. package/lib/isClassicRelayContext.js +0 -20
  141. package/lib/isClassicRelayEnvironment.js +0 -20
  142. package/lib/isCompatibleRelayFragmentType.js +0 -27
  143. package/lib/isRelayContainer.js +0 -16
  144. package/lib/makeLegacyStringishComponentRef.js +0 -52
  145. package/lib/printRelayOSSQuery.js +0 -329
  146. package/lib/printRelayQuery.js +0 -26
  147. package/lib/rangeOperationToMetadataKey.js +0 -25
  148. package/lib/readRelayQueryData.js +0 -551
  149. package/lib/relayUnstableBatchedUpdates.js +0 -12
  150. package/lib/relayUnstableBatchedUpdates.native.js +0 -11
  151. package/lib/restoreRelayCacheData.js +0 -188
  152. package/lib/serializeRelayQueryCall.js +0 -42
  153. package/lib/splitDeferredRelayQueries.js +0 -298
  154. package/lib/stableStringify.js +0 -85
  155. package/lib/testEditDistance.js +0 -112
  156. package/lib/throwFailedPromise.js +0 -26
  157. package/lib/toGraphQL.js +0 -94
  158. package/lib/transformRelayQueryPayload.js +0 -145
  159. package/lib/validateMutationConfig.js +0 -117
  160. package/lib/validateRelayReadQuery.js +0 -112
  161. package/lib/writeRelayQueryPayload.js +0 -44
  162. package/lib/writeRelayUpdatePayload.js +0 -513
  163. package/react-relay-classic.js +0 -4
  164. package/react-relay-classic.min.js +0 -9
  165. package/react-relay-compat.js +0 -4
  166. package/react-relay-compat.min.js +0 -9
@@ -1,189 +0,0 @@
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
- *
8
- * @format
9
- */
10
- 'use strict';
11
-
12
- /**
13
- * A task queue that can be configured with an optional scheduler function. The
14
- * scheduling function is invoked with a callback that will execute the next
15
- * unit of work. The callback will return a promise that resolves with a new
16
- * callback when the next unit of work is available. For example, a scheduler
17
- * can defer each task to the next animation frame:
18
- *
19
- * new RelayTaskQueue(executeTask => {
20
- * // This function will be invoked whenever a task is enqueued. It will not
21
- * // be invoked again until `executeTask` has been invoked. Also, invoking
22
- * // `executeTask` more than once is an error.
23
- * requestAnimationFrame(executeTask);
24
- * });
25
- *
26
- * By default, the next task is executed synchronously after the previous one is
27
- * finished. An injected scheduler using `setImmediate` can alter this behavior.
28
- */
29
- var RelayTaskQueue =
30
- /*#__PURE__*/
31
- function () {
32
- function RelayTaskQueue(injectedScheduler) {
33
- this._queue = [];
34
- this._running = false;
35
- this._schedule = injectedScheduler;
36
- }
37
- /**
38
- * @internal
39
- *
40
- * Enqueues one or more callbacks that each represent a synchronous unit of
41
- * work that can be scheduled to be executed at a later time.
42
- *
43
- * The return value of each callback will be passed in as an argument to the
44
- * next callback. If one of the callbacks throw an error, the execution will
45
- * be aborted and the returned promise be rejected with the thrown error.
46
- * Otherwise, the returned promise will be resolved with the return value of
47
- * the last callback. For example:
48
- *
49
- * const taskQueue = new RelayTaskQueue();
50
- * taskQueue.enqueue(
51
- * function() {
52
- * return 'foo';
53
- * },
54
- * function(foo) {
55
- * return 'bar';
56
- * }
57
- * ).done(
58
- * function(bar) {
59
- * // ...
60
- * }
61
- * );
62
- *
63
- * RelayTaskQueue.enqueue(
64
- * function() {
65
- * return 'foo';
66
- * },
67
- * function(foo) {
68
- * throw new Error();
69
- * },
70
- * function() {
71
- * // Never executed.
72
- * }
73
- * ).catch(
74
- * function(error) {}
75
- * );
76
- */
77
-
78
-
79
- var _proto = RelayTaskQueue.prototype;
80
-
81
- _proto.enqueue = function enqueue() {
82
- var _this = this;
83
-
84
- for (var _len = arguments.length, callbacks = new Array(_len), _key = 0; _key < _len; _key++) {
85
- callbacks[_key] = arguments[_key];
86
- }
87
-
88
- var promise = new Promise(function (resolve, reject) {
89
- var nextIndex = 0;
90
- var error = null;
91
-
92
- var enqueueNext = function enqueueNext(value) {
93
- if (error) {
94
- reject(error);
95
- return;
96
- }
97
-
98
- if (nextIndex >= callbacks.length) {
99
- resolve(value);
100
- } else {
101
- _this._queue.push(function () {
102
- enqueueNext(function () {
103
- var nextCallback = callbacks[nextIndex++];
104
-
105
- try {
106
- value = nextCallback(value);
107
- } catch (e) {
108
- error = e;
109
- value = undefined;
110
- }
111
-
112
- return value;
113
- }());
114
- });
115
- }
116
- };
117
-
118
- enqueueNext(undefined);
119
- });
120
-
121
- this._scheduleIfNecessary();
122
-
123
- return promise;
124
- };
125
- /**
126
- * @public
127
- *
128
- * Injects a scheduling function that is invoked with a callback that will
129
- * execute the next unit of work. The callback will return a promise that
130
- * resolves with a new callback when the next unit of work is available.
131
- */
132
-
133
-
134
- _proto.injectScheduler = function injectScheduler(injectedScheduler) {
135
- this._schedule = injectedScheduler;
136
- };
137
-
138
- _proto._createTaskExecutor = function _createTaskExecutor(callback) {
139
- var _this2 = this;
140
-
141
- var invoked = false;
142
- return function () {
143
- !!invoked ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelayTaskQueue: Tasks can only be executed once.') : require("fbjs/lib/invariant")(false) : void 0;
144
- invoked = true;
145
-
146
- _this2._invokeWithinScopedQueue(callback);
147
-
148
- _this2._running = false;
149
-
150
- _this2._scheduleIfNecessary();
151
- };
152
- };
153
-
154
- _proto._invokeWithinScopedQueue = function _invokeWithinScopedQueue(callback) {
155
- var originalQueue = this._queue;
156
- this._queue = [];
157
-
158
- try {
159
- callback();
160
- } finally {
161
- Array.prototype.unshift.apply(originalQueue, this._queue);
162
- this._queue = originalQueue;
163
- }
164
- };
165
-
166
- _proto._scheduleIfNecessary = function _scheduleIfNecessary() {
167
- if (this._running) {
168
- return;
169
- }
170
-
171
- if (this._queue.length) {
172
- this._running = true;
173
-
174
- var _executeTask = this._createTaskExecutor(this._queue.shift());
175
-
176
- if (this._schedule) {
177
- this._schedule(_executeTask);
178
- } else {
179
- _executeTask();
180
- }
181
- } else {
182
- this._running = false;
183
- }
184
- };
185
-
186
- return RelayTaskQueue;
187
- }();
188
-
189
- module.exports = RelayTaskQueue;
package/lib/RelayTypes.js DELETED
@@ -1,13 +0,0 @@
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
- *
8
- * @format
9
- */
10
- 'use strict';
11
- /**
12
- * Types that Relay framework users may find useful.
13
- */
@@ -1,32 +0,0 @@
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
8
- * @format
9
- */
10
- 'use strict';
11
-
12
- var RelayVariable =
13
- /*#__PURE__*/
14
- function () {
15
- function RelayVariable(name) {
16
- this.name = name;
17
- }
18
-
19
- var _proto = RelayVariable.prototype;
20
-
21
- _proto.equals = function equals(other) {
22
- return other instanceof RelayVariable && other.getName() === this.name;
23
- };
24
-
25
- _proto.getName = function getName() {
26
- return this.name;
27
- };
28
-
29
- return RelayVariable;
30
- }();
31
-
32
- module.exports = RelayVariable;
@@ -1,92 +0,0 @@
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
- *
8
- * @format
9
- */
10
- 'use strict';
11
-
12
- var _objectSpread2 = require("@babel/runtime/helpers/interopRequireDefault")(require("@babel/runtime/helpers/objectSpread"));
13
-
14
- /**
15
- * Determines the variables that are in scope for a fragment given the variables
16
- * in scope at the root query as well as any arguments applied at the fragment
17
- * spread via `@arguments`.
18
- *
19
- * Note that this is analagous to determining function arguments given a function call.
20
- */
21
- function getFragmentVariables(fragment, rootVariables, argumentVariables) {
22
- var variables;
23
- fragment.argumentDefinitions.forEach(function (definition) {
24
- if (argumentVariables.hasOwnProperty(definition.name)) {
25
- return;
26
- }
27
-
28
- variables = variables || (0, _objectSpread2["default"])({}, argumentVariables);
29
-
30
- switch (definition.kind) {
31
- case 'LocalArgument':
32
- variables[definition.name] = definition.defaultValue;
33
- break;
34
-
35
- case 'RootArgument':
36
- // In the new core this would be an error. In the classic core a variable
37
- // may be conditionally unused, in which case it's okay for it to be
38
- // null.
39
- var rootValue = rootVariables[definition.name];
40
- variables[definition.name] = rootValue !== undefined ? rootValue : null;
41
- break;
42
-
43
- default:
44
- !false ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelayVariables: Unexpected node kind `%s` in fragment `%s`.', definition.kind, fragment.node.name) : require("fbjs/lib/invariant")(false) : void 0;
45
- }
46
- });
47
- return variables || argumentVariables;
48
- }
49
-
50
- function getFragmentSpreadArguments(fragmentName, variableMapping, parentVariables, rootVariables) {
51
- return require("fbjs/lib/mapObject")(variableMapping, function (value, name) {
52
- var callVariable = require("./QueryBuilder").getCallVariable(value);
53
-
54
- if (callVariable) {
55
- value = parentVariables.hasOwnProperty(callVariable.callVariableName) ? parentVariables[callVariable.callVariableName] : rootVariables[callVariable.callVariableName];
56
- }
57
-
58
- if (value === undefined) {
59
- process.env.NODE_ENV !== "production" ? require("fbjs/lib/warning")(false, 'RelayVariables.getFragmentSpreadArguments(): Variable `%s` is ' + 'undefined in fragment `%s`.', name, fragmentName) : void 0;
60
- value = null;
61
- }
62
-
63
- return value;
64
- });
65
- }
66
- /**
67
- * Determines the variables that are in scope for a given operation given values
68
- * for some/all of its arguments. Extraneous input variables are filtered from
69
- * the output, and missing variables are set to default values (if given in the
70
- * operation's definition).
71
- */
72
-
73
-
74
- function getOperationVariables(operation, variables) {
75
- var operationVariables = {};
76
- operation.argumentDefinitions.forEach(function (def) {
77
- var value = def.defaultValue;
78
-
79
- if (variables[def.name] != null) {
80
- value = variables[def.name];
81
- }
82
-
83
- operationVariables[def.name] = value;
84
- });
85
- return operationVariables;
86
- }
87
-
88
- module.exports = {
89
- getFragmentSpreadArguments: getFragmentSpreadArguments,
90
- getFragmentVariables: getFragmentVariables,
91
- getOperationVariables: getOperationVariables
92
- };
package/lib/buildRQL.js DELETED
@@ -1,160 +0,0 @@
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
- *
8
- * @format
9
- */
10
- 'use strict';
11
-
12
- var _objectSpread2 = require("@babel/runtime/helpers/interopRequireDefault")(require("@babel/runtime/helpers/objectSpread"));
13
-
14
- var _toConsumableArray2 = require("@babel/runtime/helpers/interopRequireDefault")(require("@babel/runtime/helpers/toConsumableArray"));
15
-
16
- // Cache results of executing fragment query builders.
17
- var fragmentCache = new Map(); // Cache results of executing component-specific route query builders.
18
-
19
- var queryCache = new Map();
20
-
21
- function isDeprecatedCallWithArgCountGreaterThan(nodeBuilder, count) {
22
- var argLength = nodeBuilder.length;
23
-
24
- if (process.env.NODE_ENV !== "production") {
25
- var mockImpl = nodeBuilder;
26
-
27
- while (mockImpl && mockImpl._getMockImplementation) {
28
- mockImpl = mockImpl._getMockImplementation();
29
- }
30
-
31
- if (mockImpl) {
32
- argLength = mockImpl.length;
33
- }
34
- }
35
-
36
- return argLength > count;
37
- }
38
- /**
39
- * @internal
40
- *
41
- * Builds a static node representation using a supplied query or fragment
42
- * builder. This is used for routes, containers, and mutations.
43
- *
44
- * If the supplied fragment builder produces an invalid node (e.g. the wrong
45
- * node type), these will return `undefined`. This is not to be confused with
46
- * a return value of `null`, which may result from the lack of a node.
47
- */
48
-
49
-
50
- var buildRQL = {
51
- Fragment: function Fragment(fragmentBuilder, values) {
52
- var node = fragmentCache.get(fragmentBuilder);
53
-
54
- if (node) {
55
- return require("./QueryBuilder").getFragment(node);
56
- }
57
-
58
- var variables = toVariables(values);
59
- !!isDeprecatedCallWithArgCountGreaterThan(fragmentBuilder, 1) ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'Relay.QL: Deprecated usage detected. If you are trying to define a ' + 'fragment, use `variables => Relay.QL`.') : require("fbjs/lib/invariant")(false) : void 0;
60
- node = fragmentBuilder(variables);
61
- var fragment = node != null ? require("./QueryBuilder").getFragment(node) : null;
62
-
63
- if (!fragment) {
64
- return fragment;
65
- }
66
-
67
- fragmentCache.set(fragmentBuilder, fragment);
68
- return fragment;
69
- },
70
- Query: function Query(queryBuilder, Component, queryName, values) {
71
- var queryCacheEnabled = require("./RelayQueryCaching").getEnabled();
72
-
73
- var node;
74
-
75
- if (!queryCacheEnabled) {
76
- node = buildNode(queryBuilder, Component, queryName, values);
77
- } else {
78
- var componentCache = queryCache.get(queryBuilder);
79
-
80
- if (!componentCache) {
81
- componentCache = new Map();
82
- queryCache.set(queryBuilder, componentCache);
83
- } else {
84
- node = componentCache.get(Component);
85
- }
86
-
87
- if (!node) {
88
- node = buildNode(queryBuilder, Component, queryName, values);
89
- }
90
-
91
- componentCache.set(Component, node);
92
- }
93
-
94
- if (node) {
95
- return require("./QueryBuilder").getQuery(node) || undefined;
96
- }
97
-
98
- return null;
99
- }
100
- };
101
- /**
102
- * @internal
103
- */
104
-
105
- function buildNode(queryBuilder, Component, queryName, values) {
106
- var variables = toVariables(values);
107
- !!isDeprecatedCallWithArgCountGreaterThan(queryBuilder, 2) ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'Relay.QL: Deprecated usage detected. If you are trying to define a ' + 'query, use `(Component, variables) => Relay.QL`.') : require("fbjs/lib/invariant")(false) : void 0;
108
- var node;
109
-
110
- if (isDeprecatedCallWithArgCountGreaterThan(queryBuilder, 0)) {
111
- node = queryBuilder(Component, variables);
112
- } else {
113
- node = queryBuilder(Component, variables);
114
-
115
- var query = require("./QueryBuilder").getQuery(node);
116
-
117
- if (query) {
118
- var hasFragment = false;
119
- var hasScalarFieldsOnly = true;
120
-
121
- if (query.children) {
122
- query.children.forEach(function (child) {
123
- if (child) {
124
- hasFragment = hasFragment || child.kind === 'Fragment';
125
- hasScalarFieldsOnly = hasScalarFieldsOnly && child.kind === 'Field' && (!child.children || child.children.length === 0);
126
- }
127
- });
128
- }
129
-
130
- if (!hasFragment) {
131
- var children = query.children ? (0, _toConsumableArray2["default"])(query.children) : [];
132
- !hasScalarFieldsOnly ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'Relay.QL: Expected query `%s` to be empty. For example, use ' + '`node(id: $id)`, not `node(id: $id) { ... }`.', query.fieldName) : require("fbjs/lib/invariant")(false) : void 0;
133
-
134
- var fragmentVariables = require("fbjs/lib/filterObject")(variables, function (_, name) {
135
- return Component.hasVariable(name);
136
- });
137
-
138
- children.push(Component.getFragment(queryName, fragmentVariables));
139
- node = (0, _objectSpread2["default"])({}, query, {
140
- children: children
141
- });
142
- }
143
- }
144
- }
145
-
146
- return node;
147
- }
148
-
149
- function toVariables(variables) {
150
- return require("fbjs/lib/mapObject")(variables, function (_, name) {
151
- return require("./QueryBuilder").createCallVariable(name);
152
- });
153
- }
154
-
155
- require("relay-runtime").RelayProfiler.instrumentMethods(buildRQL, {
156
- Fragment: 'buildRQL.Fragment',
157
- Query: 'buildRQL.Query'
158
- });
159
-
160
- module.exports = buildRQL;
@@ -1,74 +0,0 @@
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
- *
8
- * @format
9
- */
10
- 'use strict';
11
-
12
- /**
13
- * @internal
14
- *
15
- * Convert from GraphQL call nodes to plain object `{name,value}` calls.
16
- */
17
- function callsFromGraphQL(concreteCalls, variables) {
18
- // $FlowIssue: ConcreteCall should flow into CallOrDirective
19
- var callsOrDirectives = concreteCalls;
20
- var orderedCalls = [];
21
-
22
- for (var ii = 0; ii < callsOrDirectives.length; ii++) {
23
- var callOrDirective = callsOrDirectives[ii];
24
- var value = callOrDirective.value;
25
-
26
- if (value != null) {
27
- if (Array.isArray(value)) {
28
- value = value.map(function (arg) {
29
- return getCallValue(arg, variables);
30
- });
31
- } else if (value.kind === 'BatchCallVariable') {
32
- // Batch calls are handled separately
33
- value = null;
34
- } else {
35
- value = getCallValue(value, variables);
36
- }
37
- }
38
-
39
- var metadata = callOrDirective.metadata,
40
- name = callOrDirective.name;
41
- var orderedCall = {
42
- name: name,
43
- value: value
44
- };
45
-
46
- if (metadata && metadata.type) {
47
- orderedCall.type = metadata.type;
48
- }
49
-
50
- orderedCalls.push(orderedCall);
51
- }
52
-
53
- return orderedCalls;
54
- }
55
-
56
- function getCallValue(concreteValue, variables) {
57
- var callValue;
58
-
59
- if (concreteValue.kind === 'CallValue') {
60
- callValue = concreteValue.callValue;
61
- } else {
62
- var variableName = concreteValue.callVariableName;
63
- !variables.hasOwnProperty(variableName) ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'callsFromGraphQL(): Expected a declared value for variable, `$%s`.', variableName) : require("fbjs/lib/invariant")(false) : void 0;
64
- callValue = variables[variableName];
65
- } // Perform a shallow check to ensure the value conforms to `CallValue` type:
66
- // For performance reasons, skip recursively testing array/object values.
67
-
68
-
69
- var valueType = typeof callValue;
70
- !(callValue == null || valueType === 'boolean' || valueType === 'number' || valueType === 'string' || valueType === 'object') ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'callsFromGraphQL(): Expected argument value `%s` to either be null or a ' + 'boolean, number, string, or array/object.', JSON.stringify(callValue)) : require("fbjs/lib/invariant")(false) : void 0;
71
- return callValue;
72
- }
73
-
74
- module.exports = callsFromGraphQL;
@@ -1,34 +0,0 @@
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
- */
10
- 'use strict';
11
-
12
- /**
13
- * @internal
14
- *
15
- * Convert from plain object `{name, value}` calls to GraphQL call nodes.
16
- */
17
- function callsToGraphQL(calls) {
18
- return calls.map(function (_ref) {
19
- var name = _ref.name,
20
- type = _ref.type,
21
- value = _ref.value;
22
- var concreteValue = null;
23
-
24
- if (Array.isArray(value)) {
25
- concreteValue = value.map(require("./QueryBuilder").createCallValue);
26
- } else if (value != null) {
27
- concreteValue = require("./QueryBuilder").createCallValue(value);
28
- }
29
-
30
- return require("./QueryBuilder").createCall(name, concreteValue, type);
31
- });
32
- }
33
-
34
- module.exports = callsToGraphQL;