relay-runtime 13.0.0-rc.1 → 13.0.2

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 (216) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +64 -0
  3. package/handlers/RelayDefaultHandlerProvider.js.flow +1 -1
  4. package/handlers/connection/ConnectionHandler.js.flow +1 -1
  5. package/handlers/connection/ConnectionInterface.js.flow +1 -1
  6. package/handlers/connection/MutationHandlers.js.flow +1 -1
  7. package/index.js +2 -2
  8. package/index.js.flow +5 -1
  9. package/lib/handlers/RelayDefaultHandlerProvider.js +1 -1
  10. package/lib/handlers/connection/ConnectionHandler.js +1 -1
  11. package/lib/handlers/connection/ConnectionInterface.js +1 -1
  12. package/lib/handlers/connection/MutationHandlers.js +1 -1
  13. package/lib/index.js +8 -2
  14. package/lib/multi-actor-environment/ActorIdentifier.js +1 -1
  15. package/lib/multi-actor-environment/ActorSpecificEnvironment.js +1 -1
  16. package/lib/multi-actor-environment/ActorUtils.js +1 -1
  17. package/lib/multi-actor-environment/MultiActorEnvironment.js +1 -1
  18. package/lib/multi-actor-environment/MultiActorEnvironmentTypes.js +1 -1
  19. package/lib/multi-actor-environment/index.js +1 -1
  20. package/lib/mutations/RelayDeclarativeMutationConfig.js +1 -1
  21. package/lib/mutations/RelayRecordProxy.js +1 -1
  22. package/lib/mutations/RelayRecordSourceMutator.js +1 -1
  23. package/lib/mutations/RelayRecordSourceProxy.js +1 -1
  24. package/lib/mutations/RelayRecordSourceSelectorProxy.js +1 -1
  25. package/lib/mutations/applyOptimisticMutation.js +1 -1
  26. package/lib/mutations/commitLocalUpdate.js +1 -1
  27. package/lib/mutations/commitMutation.js +1 -1
  28. package/lib/mutations/readUpdatableQuery_EXPERIMENTAL.js +27 -18
  29. package/lib/mutations/validateMutation.js +1 -1
  30. package/lib/network/ConvertToExecuteFunction.js +1 -1
  31. package/lib/network/RelayNetwork.js +8 -4
  32. package/lib/network/RelayNetworkTypes.js +1 -1
  33. package/lib/network/RelayObservable.js +1 -1
  34. package/lib/network/RelayQueryResponseCache.js +1 -1
  35. package/lib/network/wrapNetworkWithLogObserver.js +1 -1
  36. package/lib/query/GraphQLTag.js +1 -1
  37. package/lib/query/PreloadableQueryRegistry.js +1 -1
  38. package/lib/query/fetchQuery.js +4 -1
  39. package/lib/query/fetchQueryInternal.js +1 -1
  40. package/lib/query/fetchQuery_DEPRECATED.js +1 -1
  41. package/lib/store/ClientID.js +1 -1
  42. package/lib/store/DataChecker.js +1 -1
  43. package/lib/store/OperationExecutor.js +1 -1
  44. package/lib/store/RelayConcreteVariables.js +13 -4
  45. package/lib/store/RelayExperimentalGraphResponseHandler.js +3 -3
  46. package/lib/store/RelayExperimentalGraphResponseTransform.js +54 -22
  47. package/lib/store/RelayModernEnvironment.js +1 -1
  48. package/lib/store/RelayModernFragmentSpecResolver.js +1 -1
  49. package/lib/store/RelayModernOperationDescriptor.js +2 -2
  50. package/lib/store/RelayModernRecord.js +1 -1
  51. package/lib/store/RelayModernSelector.js +1 -1
  52. package/lib/store/RelayModernStore.js +1 -1
  53. package/lib/store/RelayOperationTracker.js +1 -1
  54. package/lib/store/RelayOptimisticRecordSource.js +1 -1
  55. package/lib/store/RelayPublishQueue.js +5 -3
  56. package/lib/store/RelayReader.js +56 -16
  57. package/lib/store/RelayRecordSource.js +1 -1
  58. package/lib/store/RelayRecordState.js +1 -1
  59. package/lib/store/RelayReferenceMarker.js +1 -1
  60. package/lib/store/RelayResponseNormalizer.js +1 -1
  61. package/lib/store/RelayStoreReactFlightUtils.js +1 -1
  62. package/lib/store/RelayStoreSubscriptions.js +1 -1
  63. package/lib/store/RelayStoreTypes.js +1 -1
  64. package/lib/store/RelayStoreUtils.js +2 -1
  65. package/lib/store/ResolverCache.js +11 -3
  66. package/lib/store/ResolverFragments.js +3 -3
  67. package/lib/store/StoreInspector.js +1 -1
  68. package/lib/store/TypeID.js +1 -1
  69. package/lib/store/ViewerPattern.js +1 -1
  70. package/lib/store/cloneRelayHandleSourceField.js +1 -1
  71. package/lib/store/cloneRelayScalarHandleSourceField.js +1 -1
  72. package/lib/store/createFragmentSpecResolver.js +1 -1
  73. package/lib/store/createRelayContext.js +1 -1
  74. package/lib/store/defaultGetDataID.js +1 -1
  75. package/lib/store/defaultRequiredFieldLogger.js +1 -1
  76. package/lib/store/hasOverlappingIDs.js +1 -1
  77. package/lib/store/isRelayModernEnvironment.js +1 -1
  78. package/lib/store/normalizeRelayPayload.js +1 -1
  79. package/lib/store/readInlineData.js +1 -1
  80. package/lib/subscription/requestSubscription.js +1 -3
  81. package/lib/util/JSResourceTypes.flow.js +1 -1
  82. package/lib/util/NormalizationNode.js +1 -1
  83. package/lib/util/ReaderNode.js +1 -1
  84. package/lib/util/RelayConcreteNode.js +1 -1
  85. package/lib/util/RelayDefaultHandleKey.js +1 -1
  86. package/lib/util/RelayError.js +1 -1
  87. package/lib/util/RelayFeatureFlags.js +1 -2
  88. package/lib/util/RelayProfiler.js +1 -1
  89. package/lib/util/RelayReplaySubject.js +1 -1
  90. package/lib/util/RelayRuntimeTypes.js +1 -1
  91. package/lib/util/StringInterner.js +1 -1
  92. package/lib/util/createPayloadFor3DField.js +1 -1
  93. package/lib/util/deepFreeze.js +1 -1
  94. package/lib/util/generateID.js +1 -1
  95. package/lib/util/getFragmentIdentifier.js +1 -1
  96. package/lib/util/getOperation.js +1 -1
  97. package/lib/util/getPaginationMetadata.js +1 -1
  98. package/lib/util/getPaginationVariables.js +1 -1
  99. package/lib/util/getPendingOperationsForFragment.js +1 -1
  100. package/lib/util/getRefetchMetadata.js +1 -1
  101. package/lib/util/getRelayHandleKey.js +1 -1
  102. package/lib/util/getRequestIdentifier.js +1 -1
  103. package/lib/util/getValueAtPath.js +1 -1
  104. package/lib/util/isEmptyObject.js +1 -1
  105. package/lib/util/isPromise.js +1 -1
  106. package/lib/util/isScalarAndEqual.js +1 -1
  107. package/lib/util/recycleNodesInto.js +1 -1
  108. package/lib/util/registerEnvironmentWithDevTools.js +1 -1
  109. package/lib/util/reportMissingRequiredFields.js +1 -1
  110. package/lib/util/resolveImmediate.js +1 -1
  111. package/lib/util/stableCopy.js +1 -1
  112. package/lib/util/withDuration.js +1 -1
  113. package/lib/util/withProvidedVariables.js +49 -0
  114. package/multi-actor-environment/ActorIdentifier.js.flow +1 -1
  115. package/multi-actor-environment/ActorSpecificEnvironment.js.flow +1 -1
  116. package/multi-actor-environment/ActorUtils.js.flow +1 -1
  117. package/multi-actor-environment/MultiActorEnvironment.js.flow +1 -1
  118. package/multi-actor-environment/MultiActorEnvironmentTypes.js.flow +1 -1
  119. package/multi-actor-environment/index.js.flow +1 -1
  120. package/mutations/RelayDeclarativeMutationConfig.js.flow +1 -2
  121. package/mutations/RelayRecordProxy.js.flow +1 -1
  122. package/mutations/RelayRecordSourceMutator.js.flow +1 -1
  123. package/mutations/RelayRecordSourceProxy.js.flow +1 -1
  124. package/mutations/RelayRecordSourceSelectorProxy.js.flow +1 -1
  125. package/mutations/applyOptimisticMutation.js.flow +1 -1
  126. package/mutations/commitLocalUpdate.js.flow +1 -1
  127. package/mutations/commitMutation.js.flow +9 -20
  128. package/mutations/readUpdatableQuery_EXPERIMENTAL.js.flow +57 -50
  129. package/mutations/validateMutation.js.flow +1 -1
  130. package/network/ConvertToExecuteFunction.js.flow +1 -1
  131. package/network/RelayNetwork.js.flow +11 -4
  132. package/network/RelayNetworkTypes.js.flow +2 -2
  133. package/network/RelayObservable.js.flow +1 -1
  134. package/network/RelayQueryResponseCache.js.flow +1 -1
  135. package/network/wrapNetworkWithLogObserver.js.flow +2 -3
  136. package/package.json +2 -2
  137. package/query/GraphQLTag.js.flow +2 -2
  138. package/query/PreloadableQueryRegistry.js.flow +3 -2
  139. package/query/fetchQuery.js.flow +16 -12
  140. package/query/fetchQueryInternal.js.flow +1 -1
  141. package/query/fetchQuery_DEPRECATED.js.flow +1 -1
  142. package/relay-runtime.js +2 -2
  143. package/relay-runtime.min.js +3 -3
  144. package/store/ClientID.js.flow +1 -1
  145. package/store/DataChecker.js.flow +1 -1
  146. package/store/OperationExecutor.js.flow +1 -1
  147. package/store/RelayConcreteVariables.js.flow +13 -3
  148. package/store/RelayExperimentalGraphResponseHandler.js.flow +3 -6
  149. package/store/RelayExperimentalGraphResponseTransform.js.flow +51 -22
  150. package/store/RelayModernEnvironment.js.flow +1 -1
  151. package/store/RelayModernFragmentSpecResolver.js.flow +1 -1
  152. package/store/RelayModernOperationDescriptor.js.flow +6 -2
  153. package/store/RelayModernRecord.js.flow +1 -1
  154. package/store/RelayModernSelector.js.flow +1 -1
  155. package/store/RelayModernStore.js.flow +1 -2
  156. package/store/RelayOperationTracker.js.flow +1 -1
  157. package/store/RelayOptimisticRecordSource.js.flow +1 -1
  158. package/store/RelayPublishQueue.js.flow +9 -2
  159. package/store/RelayReader.js.flow +79 -39
  160. package/store/RelayRecordSource.js.flow +1 -1
  161. package/store/RelayRecordState.js.flow +1 -1
  162. package/store/RelayReferenceMarker.js.flow +1 -1
  163. package/store/RelayResponseNormalizer.js.flow +1 -1
  164. package/store/RelayStoreReactFlightUtils.js.flow +1 -1
  165. package/store/RelayStoreSubscriptions.js.flow +1 -1
  166. package/store/RelayStoreTypes.js.flow +4 -3
  167. package/store/RelayStoreUtils.js.flow +2 -1
  168. package/store/ResolverCache.js.flow +19 -6
  169. package/store/ResolverFragments.js.flow +3 -3
  170. package/store/StoreInspector.js.flow +1 -1
  171. package/store/TypeID.js.flow +1 -1
  172. package/store/ViewerPattern.js.flow +1 -1
  173. package/store/cloneRelayHandleSourceField.js.flow +1 -1
  174. package/store/cloneRelayScalarHandleSourceField.js.flow +1 -1
  175. package/store/createFragmentSpecResolver.js.flow +1 -1
  176. package/store/createRelayContext.js.flow +1 -1
  177. package/store/defaultGetDataID.js.flow +1 -1
  178. package/store/defaultRequiredFieldLogger.js.flow +1 -1
  179. package/store/hasOverlappingIDs.js.flow +1 -1
  180. package/store/isRelayModernEnvironment.js.flow +1 -1
  181. package/store/normalizeRelayPayload.js.flow +1 -1
  182. package/store/readInlineData.js.flow +1 -1
  183. package/subscription/requestSubscription.js.flow +8 -14
  184. package/util/JSResourceTypes.flow.js.flow +1 -1
  185. package/util/NormalizationNode.js.flow +1 -1
  186. package/util/ReaderNode.js.flow +1 -1
  187. package/util/RelayConcreteNode.js.flow +5 -3
  188. package/util/RelayDefaultHandleKey.js.flow +1 -1
  189. package/util/RelayError.js.flow +1 -1
  190. package/util/RelayFeatureFlags.js.flow +1 -3
  191. package/util/RelayProfiler.js.flow +1 -1
  192. package/util/RelayReplaySubject.js.flow +1 -1
  193. package/util/RelayRuntimeTypes.js.flow +1 -1
  194. package/util/StringInterner.js.flow +1 -1
  195. package/util/createPayloadFor3DField.js.flow +1 -1
  196. package/util/deepFreeze.js.flow +1 -1
  197. package/util/generateID.js.flow +1 -1
  198. package/util/getFragmentIdentifier.js.flow +1 -1
  199. package/util/getOperation.js.flow +1 -1
  200. package/util/getPaginationMetadata.js.flow +3 -6
  201. package/util/getPaginationVariables.js.flow +1 -1
  202. package/util/getPendingOperationsForFragment.js.flow +1 -1
  203. package/util/getRefetchMetadata.js.flow +3 -6
  204. package/util/getRelayHandleKey.js.flow +1 -1
  205. package/util/getRequestIdentifier.js.flow +1 -1
  206. package/util/getValueAtPath.js.flow +1 -1
  207. package/util/isEmptyObject.js.flow +1 -1
  208. package/util/isPromise.js.flow +1 -1
  209. package/util/isScalarAndEqual.js.flow +1 -1
  210. package/util/recycleNodesInto.js.flow +1 -1
  211. package/util/registerEnvironmentWithDevTools.js.flow +1 -1
  212. package/util/reportMissingRequiredFields.js.flow +1 -1
  213. package/util/resolveImmediate.js.flow +1 -1
  214. package/util/stableCopy.js.flow +1 -1
  215. package/util/withDuration.js.flow +1 -1
  216. package/util/withProvidedVariables.js.flow +64 -0
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and 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.
@@ -68,13 +68,15 @@ function getFragmentVariables(fragment, rootVariables, argumentVariables) {
68
68
  }
69
69
  /**
70
70
  * Determines the variables that are in scope for a given operation given values
71
- * for some/all of its arguments. Extraneous input variables are filtered from
72
- * the output, and missing variables are set to default values (if given in the
71
+ * for some/all of its arguments.
72
+ * - extraneous input variables are filtered from the output
73
+ * - missing variables are set to default values (if given in the
73
74
  * operation's definition).
75
+ * - variables with provider modules are added
74
76
  */
75
77
 
76
78
 
77
- function getOperationVariables(operation, variables) {
79
+ function getOperationVariables(operation, providedVariables, variables) {
78
80
  var operationVariables = {};
79
81
  operation.argumentDefinitions.forEach(function (def) {
80
82
  var value = def.defaultValue;
@@ -85,6 +87,13 @@ function getOperationVariables(operation, variables) {
85
87
 
86
88
  operationVariables[def.name] = value;
87
89
  });
90
+
91
+ if (providedVariables != null) {
92
+ Object.keys(providedVariables).forEach(function (varName) {
93
+ operationVariables[varName] = providedVariables[varName].get();
94
+ });
95
+ }
96
+
88
97
  return operationVariables;
89
98
  }
90
99
 
@@ -10,7 +10,7 @@ exports.handleGraphModeResponse = handleGraphModeResponse;
10
10
  var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
11
11
 
12
12
  /**
13
- * Copyright (c) Facebook, Inc. and its affiliates.
13
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
@@ -19,9 +19,9 @@ var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime
19
19
  *
20
20
  * @format
21
21
  */
22
- var invariant = require('invariant');
22
+ var RelayModernRecord = require('./RelayModernRecord');
23
23
 
24
- var RelayModernRecord = require('relay-runtime/store/RelayModernRecord');
24
+ var invariant = require('invariant');
25
25
  /**
26
26
  * Given a stream of GraphMode chunks, populate a MutableRecordSource.
27
27
  */
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.normalizeResponse = normalizeResponse;
9
+ exports.normalizeResponseWithMetadata = normalizeResponseWithMetadata;
10
+ exports.GraphModeNormalizer = void 0;
9
11
 
10
12
  var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
11
13
 
@@ -14,7 +16,7 @@ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/obje
14
16
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
15
17
 
16
18
  /**
17
- * Copyright (c) Facebook, Inc. and its affiliates.
19
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
18
20
  *
19
21
  * This source code is licensed under the MIT license found in the
20
22
  * LICENSE file in the root directory of this source tree.
@@ -23,30 +25,32 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
23
25
  *
24
26
  * @format
25
27
  */
26
- var _require = require('./RelayConcreteVariables'),
27
- getLocalVariables = _require.getLocalVariables;
28
-
29
- var _require2 = require('./RelayModernSelector'),
30
- createNormalizationSelector = _require2.createNormalizationSelector;
31
-
32
- var invariant = require('invariant');
33
-
34
- var _require3 = require('relay-runtime'),
35
- generateClientID = _require3.generateClientID;
36
-
37
- var _require4 = require('relay-runtime/store/RelayStoreUtils'),
28
+ var _require = require('../util/RelayConcreteNode'),
29
+ CLIENT_EXTENSION = _require.CLIENT_EXTENSION,
30
+ CONDITION = _require.CONDITION,
31
+ DEFER = _require.DEFER,
32
+ FRAGMENT_SPREAD = _require.FRAGMENT_SPREAD,
33
+ INLINE_FRAGMENT = _require.INLINE_FRAGMENT,
34
+ LINKED_FIELD = _require.LINKED_FIELD,
35
+ LINKED_HANDLE = _require.LINKED_HANDLE,
36
+ SCALAR_FIELD = _require.SCALAR_FIELD,
37
+ SCALAR_HANDLE = _require.SCALAR_HANDLE;
38
+
39
+ var _require2 = require('./RelayConcreteVariables'),
40
+ getLocalVariables = _require2.getLocalVariables;
41
+
42
+ var _require3 = require('./RelayModernSelector'),
43
+ createNormalizationSelector = _require3.createNormalizationSelector;
44
+
45
+ var _require4 = require('./RelayStoreUtils'),
38
46
  ROOT_TYPE = _require4.ROOT_TYPE,
39
47
  TYPENAME_KEY = _require4.TYPENAME_KEY,
40
48
  getStorageKey = _require4.getStorageKey;
41
49
 
42
- var _require5 = require('relay-runtime/util/RelayConcreteNode'),
43
- CLIENT_EXTENSION = _require5.CLIENT_EXTENSION,
44
- CONDITION = _require5.CONDITION,
45
- DEFER = _require5.DEFER,
46
- FRAGMENT_SPREAD = _require5.FRAGMENT_SPREAD,
47
- INLINE_FRAGMENT = _require5.INLINE_FRAGMENT,
48
- LINKED_FIELD = _require5.LINKED_FIELD,
49
- SCALAR_FIELD = _require5.SCALAR_FIELD;
50
+ var invariant = require('invariant');
51
+
52
+ var _require5 = require('relay-runtime'),
53
+ generateClientID = _require5.generateClientID;
50
54
  /**
51
55
  * This module is an experiment to explore a proposal normalized response format for GraphQL.
52
56
  * See the Quip document: Canonical Normalized Response Format (“GraphMode”) Proposal
@@ -96,6 +100,17 @@ function normalizeResponse(response, selector, options) {
96
100
  return normalizer.normalizeResponse(node, dataID, response);
97
101
  }
98
102
 
103
+ function normalizeResponseWithMetadata(response, selector, options) {
104
+ var node = selector.node,
105
+ variables = selector.variables,
106
+ dataID = selector.dataID;
107
+ var normalizer = new GraphModeNormalizer(variables, options);
108
+ var chunks = Array.from(normalizer.normalizeResponse(node, dataID, response));
109
+ return [chunks, {
110
+ duplicateFieldsAvoided: normalizer.duplicateFieldsAvoided
111
+ }];
112
+ }
113
+
99
114
  var GraphModeNormalizer = /*#__PURE__*/function () {
100
115
  function GraphModeNormalizer(variables, options) {
101
116
  this._actorIdentifier = options.actorIdentifier;
@@ -105,6 +120,7 @@ var GraphModeNormalizer = /*#__PURE__*/function () {
105
120
  this._sentFields = new Map();
106
121
  this._nextStreamID = 0;
107
122
  this._variables = variables;
123
+ this.duplicateFieldsAvoided = 0;
108
124
  }
109
125
 
110
126
  var _proto = GraphModeNormalizer.prototype;
@@ -218,6 +234,7 @@ var GraphModeNormalizer = /*#__PURE__*/function () {
218
234
 
219
235
 
220
236
  if (sentFields.has(storageKey)) {
237
+ this.duplicateFieldsAvoided++;
221
238
  break;
222
239
  }
223
240
 
@@ -237,6 +254,7 @@ var GraphModeNormalizer = /*#__PURE__*/function () {
237
254
 
238
255
 
239
256
  if (sentFields.has(_storageKey)) {
257
+ this.duplicateFieldsAvoided++;
240
258
  break;
241
259
  }
242
260
 
@@ -310,6 +328,18 @@ var GraphModeNormalizer = /*#__PURE__*/function () {
310
328
  // over client extensions.
311
329
  break;
312
330
 
331
+ case SCALAR_HANDLE:
332
+ case LINKED_HANDLE:
333
+ // Handles allow us to record information that will be needed to
334
+ // perform additional process when we insert data into the store. For
335
+ // example, connection edges need to be prepended/appended to the
336
+ // pre-existing values.
337
+ //
338
+ // GraphMode will eventually need some replacement for this, but it is
339
+ // not nessesary in order to measure things like response size, so we
340
+ // can ignore these for now.
341
+ break;
342
+
313
343
  default:
314
344
  throw new Error("Unexpected selection type: ".concat(selection.kind));
315
345
  }
@@ -388,4 +418,6 @@ var GraphModeNormalizer = /*#__PURE__*/function () {
388
418
  };
389
419
 
390
420
  return GraphModeNormalizer;
391
- }();
421
+ }();
422
+
423
+ exports.GraphModeNormalizer = GraphModeNormalizer;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and 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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and 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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and 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.
@@ -34,7 +34,7 @@ var _require3 = require('./RelayStoreUtils'),
34
34
  function createOperationDescriptor(request, variables, cacheConfig) {
35
35
  var dataID = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : ROOT_ID;
36
36
  var operation = request.operation;
37
- var operationVariables = getOperationVariables(operation, variables);
37
+ var operationVariables = getOperationVariables(operation, request.params.providedVariables, variables);
38
38
  var requestDescriptor = createRequestDescriptor(request, operationVariables, cacheConfig);
39
39
  var operationDescriptor = {
40
40
  fragment: createReaderSelector(request.fragment, dataID, operationVariables, requestDescriptor),
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and 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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and 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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and 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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and 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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and 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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and 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.
@@ -10,7 +10,7 @@
10
10
  // flowlint ambiguous-object-type:error
11
11
  'use strict';
12
12
 
13
- var _global$ErrorUtils$ap, _global, _global$ErrorUtils;
13
+ var _global$ErrorUtils$ap, _global$ErrorUtils;
14
14
 
15
15
  var RelayRecordSourceMutator = require('../mutations/RelayRecordSourceMutator');
16
16
 
@@ -26,7 +26,9 @@ var invariant = require('invariant');
26
26
 
27
27
  var warning = require("fbjs/lib/warning");
28
28
 
29
- var applyWithGuard = (_global$ErrorUtils$ap = (_global = global) === null || _global === void 0 ? void 0 : (_global$ErrorUtils = _global.ErrorUtils) === null || _global$ErrorUtils === void 0 ? void 0 : _global$ErrorUtils.applyWithGuard) !== null && _global$ErrorUtils$ap !== void 0 ? _global$ErrorUtils$ap : function (callback, context, args, onError, name) {
29
+ var _global = typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : undefined;
30
+
31
+ var applyWithGuard = (_global$ErrorUtils$ap = _global === null || _global === void 0 ? void 0 : (_global$ErrorUtils = _global.ErrorUtils) === null || _global$ErrorUtils === void 0 ? void 0 : _global$ErrorUtils.applyWithGuard) !== null && _global$ErrorUtils$ap !== void 0 ? _global$ErrorUtils$ap : function (callback, context, args, onError, name) {
30
32
  return callback.apply(context, args);
31
33
  };
32
34
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and 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.
@@ -90,6 +90,7 @@ var RelayReader = /*#__PURE__*/function () {
90
90
  this._selector = selector;
91
91
  this._variables = selector.variables;
92
92
  this._resolverCache = resolverCache;
93
+ this._fragmentName = selector.node.name;
93
94
  }
94
95
 
95
96
  var _proto = RelayReader.prototype;
@@ -219,7 +220,7 @@ var RelayReader = /*#__PURE__*/function () {
219
220
  return;
220
221
  }
221
222
 
222
- var owner = this._selector.node.name;
223
+ var owner = this._fragmentName;
223
224
 
224
225
  switch (action) {
225
226
  case 'THROW':
@@ -236,15 +237,21 @@ var RelayReader = /*#__PURE__*/function () {
236
237
  if (this._missingRequiredFields == null) {
237
238
  this._missingRequiredFields = {
238
239
  action: action,
239
- fields: []
240
+ fields: [{
241
+ path: fieldPath,
242
+ owner: owner
243
+ }]
244
+ };
245
+ } else {
246
+ this._missingRequiredFields = {
247
+ action: action,
248
+ fields: [].concat((0, _toConsumableArray2["default"])(this._missingRequiredFields.fields), [{
249
+ path: fieldPath,
250
+ owner: owner
251
+ }])
240
252
  };
241
253
  }
242
254
 
243
- this._missingRequiredFields.fields.push({
244
- path: fieldPath,
245
- owner: owner
246
- });
247
-
248
255
  return;
249
256
 
250
257
  default:
@@ -260,8 +267,6 @@ var RelayReader = /*#__PURE__*/function () {
260
267
 
261
268
  switch (selection.kind) {
262
269
  case REQUIRED_FIELD:
263
- !RelayFeatureFlags.ENABLE_REQUIRED_DIRECTIVES ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayReader(): Encountered a `@required` directive at path "%s" in `%s` without the `ENABLE_REQUIRED_DIRECTIVES` feature flag enabled.', selection.path, this._selector.node.name) : invariant(false) : void 0;
264
-
265
270
  var fieldValue = this._readRequiredField(selection, record, data);
266
271
 
267
272
  if (fieldValue == null) {
@@ -468,9 +473,7 @@ var RelayReader = /*#__PURE__*/function () {
468
473
  throw new Error('Relay Resolver fields are not yet supported.');
469
474
  }
470
475
 
471
- this._readResolverField(selection.field, record, data);
472
-
473
- break;
476
+ return this._readResolverField(selection.field, record, data);
474
477
 
475
478
  default:
476
479
  selection.field.kind;
@@ -492,6 +495,8 @@ var RelayReader = /*#__PURE__*/function () {
492
495
 
493
496
  var fragmentValue;
494
497
  var fragmentReaderSelector;
498
+ var fragmentMissingRequiredFields;
499
+ var previousMissingRequriedFields;
495
500
  var fragmentSeenRecordIDs = new Set();
496
501
 
497
502
  var getDataForResolverFragment = function getDataForResolverFragment(singularReaderSelector) {
@@ -510,14 +515,18 @@ var RelayReader = /*#__PURE__*/function () {
510
515
 
511
516
  _this._seenRecords = fragmentSeenRecordIDs;
512
517
  var resolverFragmentData = {};
518
+ previousMissingRequriedFields = _this._missingRequiredFields;
519
+ _this._missingRequiredFields = null;
513
520
 
514
521
  _this._createInlineDataOrResolverFragmentPointer(singularReaderSelector.node, record, resolverFragmentData);
515
522
 
523
+ fragmentMissingRequiredFields = _this._missingRequiredFields;
516
524
  fragmentValue = (_resolverFragmentData = resolverFragmentData[FRAGMENTS_KEY]) === null || _resolverFragmentData === void 0 ? void 0 : _resolverFragmentData[fragment.name];
517
525
  !(typeof fragmentValue === 'object' && fragmentValue !== null) ? process.env.NODE_ENV !== "production" ? invariant(false, "Expected reader data to contain a __fragments property with a property for the fragment named ".concat(fragment.name, ", but it is missing.")) : invariant(false) : void 0;
518
526
  return fragmentValue;
519
527
  } finally {
520
528
  _this._seenRecords = existingSeenRecords;
529
+ _this._missingRequiredFields = previousMissingRequriedFields;
521
530
  }
522
531
  };
523
532
 
@@ -539,12 +548,18 @@ var RelayReader = /*#__PURE__*/function () {
539
548
  fragmentValue: fragmentValue,
540
549
  resolverID: resolverID,
541
550
  seenRecordIDs: fragmentSeenRecordIDs,
542
- readerSelector: fragmentReaderSelector
551
+ readerSelector: fragmentReaderSelector,
552
+ missingRequiredFields: fragmentMissingRequiredFields
543
553
  };
544
554
  });
545
555
  }, getDataForResolverFragment),
546
556
  result = _this$_resolverCache$[0],
547
- seenRecord = _this$_resolverCache$[1];
557
+ seenRecord = _this$_resolverCache$[1],
558
+ missingRequiredFields = _this$_resolverCache$[2];
559
+
560
+ if (missingRequiredFields != null) {
561
+ this._addMissingRequiredFields(missingRequiredFields);
562
+ }
548
563
 
549
564
  if (seenRecord != null) {
550
565
  this._seenRecords.add(seenRecord);
@@ -552,6 +567,7 @@ var RelayReader = /*#__PURE__*/function () {
552
567
 
553
568
  var applicationName = (_field$alias = field.alias) !== null && _field$alias !== void 0 ? _field$alias : field.name;
554
569
  data[applicationName] = result;
570
+ return result;
555
571
  };
556
572
 
557
573
  _proto._readClientEdge = function _readClientEdge(field, record, data) {
@@ -818,13 +834,37 @@ var RelayReader = /*#__PURE__*/function () {
818
834
  }
819
835
 
820
836
  var inlineData = {};
837
+ var parentFragmentName = this._fragmentName;
838
+ this._fragmentName = fragmentSpreadOrFragment.name;
821
839
 
822
- this._traverseSelections(fragmentSpreadOrFragment.selections, record, inlineData); // $FlowFixMe[cannot-write] - writing into read-only field
840
+ this._traverseSelections(fragmentSpreadOrFragment.selections, record, inlineData);
823
841
 
842
+ this._fragmentName = parentFragmentName; // $FlowFixMe[cannot-write] - writing into read-only field
824
843
 
825
844
  fragmentPointers[fragmentSpreadOrFragment.name] = inlineData;
826
845
  };
827
846
 
847
+ _proto._addMissingRequiredFields = function _addMissingRequiredFields(additional) {
848
+ if (this._missingRequiredFields == null) {
849
+ this._missingRequiredFields = additional;
850
+ return;
851
+ }
852
+
853
+ if (this._missingRequiredFields.action === 'THROW') {
854
+ return;
855
+ }
856
+
857
+ if (additional.action === 'THROW') {
858
+ this._missingRequiredFields = additional;
859
+ return;
860
+ }
861
+
862
+ this._missingRequiredFields = {
863
+ action: 'LOG',
864
+ fields: [].concat((0, _toConsumableArray2["default"])(this._missingRequiredFields.fields), (0, _toConsumableArray2["default"])(additional.fields))
865
+ };
866
+ };
867
+
828
868
  return RelayReader;
829
869
  }();
830
870
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and 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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and 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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and 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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and 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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and 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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and 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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and 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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and 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.
@@ -211,6 +211,7 @@ var RelayStoreUtils = {
211
211
  RELAY_RESOLVER_INVALIDATION_KEY: '__resolverValueMayBeInvalid',
212
212
  RELAY_RESOLVER_INPUTS_KEY: '__resolverInputValues',
213
213
  RELAY_RESOLVER_READER_SELECTOR_KEY: '__resolverReaderSelector',
214
+ RELAY_RESOLVER_MISSING_REQUIRED_FIELDS_KEY: '__resolverMissingRequiredFields',
214
215
  formatStorageKey: formatStorageKey,
215
216
  getArgumentValue: getArgumentValue,
216
217
  getArgumentValues: getArgumentValues,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and 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.
@@ -24,6 +24,7 @@ var RelayModernRecord = require('./RelayModernRecord');
24
24
  var _require2 = require('./RelayStoreUtils'),
25
25
  RELAY_RESOLVER_INPUTS_KEY = _require2.RELAY_RESOLVER_INPUTS_KEY,
26
26
  RELAY_RESOLVER_INVALIDATION_KEY = _require2.RELAY_RESOLVER_INVALIDATION_KEY,
27
+ RELAY_RESOLVER_MISSING_REQUIRED_FIELDS_KEY = _require2.RELAY_RESOLVER_MISSING_REQUIRED_FIELDS_KEY,
27
28
  RELAY_RESOLVER_READER_SELECTOR_KEY = _require2.RELAY_RESOLVER_READER_SELECTOR_KEY,
28
29
  RELAY_RESOLVER_VALUE_KEY = _require2.RELAY_RESOLVER_VALUE_KEY,
29
30
  getStorageKey = _require2.getStorageKey;
@@ -39,7 +40,11 @@ var NoopResolverCache = /*#__PURE__*/function () {
39
40
  var _proto = NoopResolverCache.prototype;
40
41
 
41
42
  _proto.readFromCacheOrEvaluate = function readFromCacheOrEvaluate(record, field, variables, evaluate, getDataForResolverFragment) {
42
- return [evaluate().resolverResult, undefined];
43
+ var _evaluate = evaluate(),
44
+ resolverResult = _evaluate.resolverResult,
45
+ missingRequiredFields = _evaluate.missingRequiredFields;
46
+
47
+ return [resolverResult, undefined, missingRequiredFields];
43
48
  };
44
49
 
45
50
  _proto.invalidateDataIDs = function invalidateDataIDs(updatedDataIDs) {};
@@ -85,6 +90,7 @@ var RecordResolverCache = /*#__PURE__*/function () {
85
90
  RelayModernRecord.setValue(linkedRecord, RELAY_RESOLVER_VALUE_KEY, evaluationResult.resolverResult);
86
91
  RelayModernRecord.setValue(linkedRecord, RELAY_RESOLVER_INPUTS_KEY, evaluationResult.fragmentValue);
87
92
  RelayModernRecord.setValue(linkedRecord, RELAY_RESOLVER_READER_SELECTOR_KEY, evaluationResult.readerSelector);
93
+ RelayModernRecord.setValue(linkedRecord, RELAY_RESOLVER_MISSING_REQUIRED_FIELDS_KEY, evaluationResult.missingRequiredFields);
88
94
  recordSource.set(linkedID, linkedRecord); // Link the resolver value record to the resolver field of the record being read:
89
95
 
90
96
  var nextRecord = RelayModernRecord.clone(record);
@@ -112,7 +118,9 @@ var RecordResolverCache = /*#__PURE__*/function () {
112
118
 
113
119
 
114
120
  var answer = linkedRecord[RELAY_RESOLVER_VALUE_KEY];
115
- return [answer, linkedID];
121
+ var missingRequiredFields = // $FlowFixMe[incompatible-type] - casting mixed
122
+ linkedRecord[RELAY_RESOLVER_MISSING_REQUIRED_FIELDS_KEY];
123
+ return [answer, linkedID, missingRequiredFields];
116
124
  };
117
125
 
118
126
  _proto2.invalidateDataIDs = function invalidateDataIDs(updatedDataIDs) {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and 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.
@@ -37,9 +37,9 @@ function withResolverContext(context, cb) {
37
37
  // The declarations ensure that the type of the returned data is:
38
38
  // - non-nullable if the provided ref type is non-nullable
39
39
  // - nullable if the provided ref type is nullable
40
- // - array of non-nullable if the privoided ref type is an array of
40
+ // - array of non-nullable if the provided ref type is an array of
41
41
  // non-nullable refs
42
- // - array of nullable if the privoided ref type is an array of nullable refs
42
+ // - array of nullable if the provided ref type is an array of nullable refs
43
43
 
44
44
 
45
45
  function readFragment(fragmentInput, fragmentKey) {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and 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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and 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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and 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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and 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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and 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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and 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.