@ardatan/relay-compiler 12.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (256) hide show
  1. package/LICENSE +21 -0
  2. package/bin/RelayCompilerBin.js.flow +169 -0
  3. package/bin/RelayCompilerMain.js.flow +515 -0
  4. package/bin/__fixtures__/plugin-module.js.flow +17 -0
  5. package/bin/relay-compiler +19066 -0
  6. package/codegen/CodegenDirectory.js.flow +375 -0
  7. package/codegen/CodegenRunner.js.flow +432 -0
  8. package/codegen/CodegenTypes.js.flow +28 -0
  9. package/codegen/CodegenWatcher.js.flow +254 -0
  10. package/codegen/NormalizationCodeGenerator.js.flow +566 -0
  11. package/codegen/ReaderCodeGenerator.js.flow +512 -0
  12. package/codegen/RelayCodeGenerator.js.flow +85 -0
  13. package/codegen/RelayFileWriter.js.flow +367 -0
  14. package/codegen/SourceControl.js.flow +58 -0
  15. package/codegen/compileRelayArtifacts.js.flow +182 -0
  16. package/codegen/createPrintRequireModuleDependency.js.flow +19 -0
  17. package/codegen/sortObjectByKey.js.flow +25 -0
  18. package/codegen/writeRelayGeneratedFile.js.flow +239 -0
  19. package/core/ASTCache.js.flow +74 -0
  20. package/core/ASTConvert.js.flow +233 -0
  21. package/core/CompilerContext.js.flow +191 -0
  22. package/core/CompilerError.js.flow +255 -0
  23. package/core/DotGraphQLParser.js.flow +39 -0
  24. package/core/GraphQLCompilerProfiler.js.flow +341 -0
  25. package/core/GraphQLDerivedFromMetadata.js.flow +36 -0
  26. package/core/GraphQLWatchmanClient.js.flow +111 -0
  27. package/core/IR.js.flow +326 -0
  28. package/core/IRPrinter.js.flow +478 -0
  29. package/core/IRTransformer.js.flow +377 -0
  30. package/core/IRValidator.js.flow +260 -0
  31. package/core/IRVisitor.js.flow +150 -0
  32. package/core/JSModuleParser.js.flow +24 -0
  33. package/core/RelayCompilerScope.js.flow +199 -0
  34. package/core/RelayFindGraphQLTags.js.flow +119 -0
  35. package/core/RelayGraphQLEnumsGenerator.js.flow +55 -0
  36. package/core/RelayIRTransforms.js.flow +138 -0
  37. package/core/RelayParser.js.flow +1734 -0
  38. package/core/RelaySourceModuleParser.js.flow +135 -0
  39. package/core/Schema.js.flow +2037 -0
  40. package/core/SchemaUtils.js.flow +120 -0
  41. package/core/filterContextForNode.js.flow +50 -0
  42. package/core/getFieldDefinition.js.flow +156 -0
  43. package/core/getIdentifierForArgumentValue.js.flow +49 -0
  44. package/core/getIdentifierForSelection.js.flow +69 -0
  45. package/core/getLiteralArgumentValues.js.flow +32 -0
  46. package/core/getNormalizationOperationName.js.flow +19 -0
  47. package/core/inferRootArgumentDefinitions.js.flow +323 -0
  48. package/index.js +10 -0
  49. package/index.js.flow +200 -0
  50. package/language/RelayLanguagePluginInterface.js.flow +283 -0
  51. package/language/javascript/FindGraphQLTags.js.flow +137 -0
  52. package/language/javascript/RelayFlowBabelFactories.js.flow +176 -0
  53. package/language/javascript/RelayFlowGenerator.js.flow +1100 -0
  54. package/language/javascript/RelayFlowTypeTransformers.js.flow +184 -0
  55. package/language/javascript/RelayLanguagePluginJavaScript.js.flow +34 -0
  56. package/language/javascript/formatGeneratedModule.js.flow +65 -0
  57. package/lib/bin/RelayCompilerBin.js +143 -0
  58. package/lib/bin/RelayCompilerMain.js +486 -0
  59. package/lib/bin/__fixtures__/plugin-module.js +16 -0
  60. package/lib/codegen/CodegenDirectory.js +336 -0
  61. package/lib/codegen/CodegenRunner.js +433 -0
  62. package/lib/codegen/CodegenTypes.js +11 -0
  63. package/lib/codegen/CodegenWatcher.js +271 -0
  64. package/lib/codegen/NormalizationCodeGenerator.js +480 -0
  65. package/lib/codegen/ReaderCodeGenerator.js +472 -0
  66. package/lib/codegen/RelayCodeGenerator.js +68 -0
  67. package/lib/codegen/RelayFileWriter.js +270 -0
  68. package/lib/codegen/SourceControl.js +60 -0
  69. package/lib/codegen/compileRelayArtifacts.js +157 -0
  70. package/lib/codegen/createPrintRequireModuleDependency.js +19 -0
  71. package/lib/codegen/sortObjectByKey.js +41 -0
  72. package/lib/codegen/writeRelayGeneratedFile.js +208 -0
  73. package/lib/core/ASTCache.js +70 -0
  74. package/lib/core/ASTConvert.js +198 -0
  75. package/lib/core/CompilerContext.js +165 -0
  76. package/lib/core/CompilerError.js +251 -0
  77. package/lib/core/DotGraphQLParser.js +40 -0
  78. package/lib/core/GraphQLCompilerProfiler.js +299 -0
  79. package/lib/core/GraphQLDerivedFromMetadata.js +31 -0
  80. package/lib/core/GraphQLWatchmanClient.js +150 -0
  81. package/lib/core/IR.js +11 -0
  82. package/lib/core/IRPrinter.js +389 -0
  83. package/lib/core/IRTransformer.js +345 -0
  84. package/lib/core/IRValidator.js +226 -0
  85. package/lib/core/IRVisitor.js +45 -0
  86. package/lib/core/JSModuleParser.js +18 -0
  87. package/lib/core/RelayCompilerScope.js +149 -0
  88. package/lib/core/RelayFindGraphQLTags.js +79 -0
  89. package/lib/core/RelayGraphQLEnumsGenerator.js +50 -0
  90. package/lib/core/RelayIRTransforms.js +109 -0
  91. package/lib/core/RelayParser.js +1382 -0
  92. package/lib/core/RelaySourceModuleParser.js +104 -0
  93. package/lib/core/Schema.js +1877 -0
  94. package/lib/core/SchemaUtils.js +98 -0
  95. package/lib/core/filterContextForNode.js +49 -0
  96. package/lib/core/getFieldDefinition.js +145 -0
  97. package/lib/core/getIdentifierForArgumentValue.js +53 -0
  98. package/lib/core/getIdentifierForSelection.js +48 -0
  99. package/lib/core/getLiteralArgumentValues.js +26 -0
  100. package/lib/core/getNormalizationOperationName.js +17 -0
  101. package/lib/core/inferRootArgumentDefinitions.js +351 -0
  102. package/lib/index.js +178 -0
  103. package/lib/language/RelayLanguagePluginInterface.js +14 -0
  104. package/lib/language/javascript/FindGraphQLTags.js +126 -0
  105. package/lib/language/javascript/RelayFlowBabelFactories.js +160 -0
  106. package/lib/language/javascript/RelayFlowGenerator.js +857 -0
  107. package/lib/language/javascript/RelayFlowTypeTransformers.js +119 -0
  108. package/lib/language/javascript/RelayLanguagePluginJavaScript.js +30 -0
  109. package/lib/language/javascript/formatGeneratedModule.js +36 -0
  110. package/lib/reporters/ConsoleReporter.js +61 -0
  111. package/lib/reporters/MultiReporter.js +45 -0
  112. package/lib/reporters/Reporter.js +11 -0
  113. package/lib/runner/Artifacts.js +323 -0
  114. package/lib/runner/BufferedFilesystem.js +261 -0
  115. package/lib/runner/GraphQLASTNodeGroup.js +256 -0
  116. package/lib/runner/GraphQLASTUtils.js +23 -0
  117. package/lib/runner/GraphQLNodeMap.js +81 -0
  118. package/lib/runner/Sources.js +271 -0
  119. package/lib/runner/StrictMap.js +134 -0
  120. package/lib/runner/compileArtifacts.js +39 -0
  121. package/lib/runner/extractAST.js +77 -0
  122. package/lib/runner/getChangedNodeNames.js +82 -0
  123. package/lib/runner/getSchemaInstance.js +30 -0
  124. package/lib/runner/types.js +12 -0
  125. package/lib/transforms/ApplyFragmentArgumentTransform.js +393 -0
  126. package/lib/transforms/ClientExtensionsTransform.js +222 -0
  127. package/lib/transforms/ConnectionTransform.js +643 -0
  128. package/lib/transforms/DeclarativeConnectionMutationTransform.js +221 -0
  129. package/lib/transforms/DeferStreamTransform.js +247 -0
  130. package/lib/transforms/DisallowIdAsAlias.js +41 -0
  131. package/lib/transforms/DisallowTypenameOnRoot.js +53 -0
  132. package/lib/transforms/FieldHandleTransform.js +81 -0
  133. package/lib/transforms/FilterCompilerDirectivesTransform.js +29 -0
  134. package/lib/transforms/FilterDirectivesTransform.js +41 -0
  135. package/lib/transforms/FlattenTransform.js +308 -0
  136. package/lib/transforms/GenerateIDFieldTransform.js +137 -0
  137. package/lib/transforms/GenerateTypeNameTransform.js +155 -0
  138. package/lib/transforms/InlineDataFragmentTransform.js +104 -0
  139. package/lib/transforms/InlineFragmentsTransform.js +63 -0
  140. package/lib/transforms/MaskTransform.js +121 -0
  141. package/lib/transforms/MatchTransform.js +438 -0
  142. package/lib/transforms/ReactFlightComponentTransform.js +161 -0
  143. package/lib/transforms/RefetchableFragmentTransform.js +249 -0
  144. package/lib/transforms/RelayDirectiveTransform.js +85 -0
  145. package/lib/transforms/RequiredFieldTransform.js +373 -0
  146. package/lib/transforms/SkipClientExtensionsTransform.js +49 -0
  147. package/lib/transforms/SkipHandleFieldTransform.js +45 -0
  148. package/lib/transforms/SkipRedundantNodesTransform.js +255 -0
  149. package/lib/transforms/SkipSplitOperationTransform.js +32 -0
  150. package/lib/transforms/SkipUnreachableNodeTransform.js +158 -0
  151. package/lib/transforms/SkipUnusedVariablesTransform.js +74 -0
  152. package/lib/transforms/SplitModuleImportTransform.js +85 -0
  153. package/lib/transforms/TestOperationTransform.js +145 -0
  154. package/lib/transforms/TransformUtils.js +21 -0
  155. package/lib/transforms/ValidateGlobalVariablesTransform.js +91 -0
  156. package/lib/transforms/ValidateRequiredArgumentsTransform.js +118 -0
  157. package/lib/transforms/ValidateServerOnlyDirectivesTransform.js +111 -0
  158. package/lib/transforms/ValidateUnusedVariablesTransform.js +96 -0
  159. package/lib/transforms/query-generators/FetchableQueryGenerator.js +157 -0
  160. package/lib/transforms/query-generators/NodeQueryGenerator.js +166 -0
  161. package/lib/transforms/query-generators/QueryQueryGenerator.js +48 -0
  162. package/lib/transforms/query-generators/ViewerQueryGenerator.js +77 -0
  163. package/lib/transforms/query-generators/index.js +60 -0
  164. package/lib/transforms/query-generators/utils.js +92 -0
  165. package/lib/util/CodeMarker.js +80 -0
  166. package/lib/util/DefaultHandleKey.js +15 -0
  167. package/lib/util/RelayCompilerCache.js +98 -0
  168. package/lib/util/Rollout.js +40 -0
  169. package/lib/util/TimeReporter.js +83 -0
  170. package/lib/util/areEqualArgValues.js +135 -0
  171. package/lib/util/argumentContainsVariables.js +37 -0
  172. package/lib/util/dedupeJSONStringify.js +160 -0
  173. package/lib/util/generateAbstractTypeRefinementKey.js +24 -0
  174. package/lib/util/getDefinitionNodeHash.js +22 -0
  175. package/lib/util/getModuleName.js +32 -0
  176. package/lib/util/joinArgumentDefinitions.js +66 -0
  177. package/lib/util/md5.js +17 -0
  178. package/lib/util/murmurHash.js +86 -0
  179. package/lib/util/nullthrowsOSS.js +23 -0
  180. package/lib/util/orList.js +36 -0
  181. package/lib/util/partitionArray.js +35 -0
  182. package/package.json +42 -0
  183. package/relay-compiler.js +17 -0
  184. package/relay-compiler.min.js +22 -0
  185. package/reporters/ConsoleReporter.js.flow +81 -0
  186. package/reporters/MultiReporter.js.flow +43 -0
  187. package/reporters/Reporter.js.flow +19 -0
  188. package/runner/Artifacts.js.flow +219 -0
  189. package/runner/BufferedFilesystem.js.flow +194 -0
  190. package/runner/GraphQLASTNodeGroup.js.flow +176 -0
  191. package/runner/GraphQLASTUtils.js.flow +26 -0
  192. package/runner/GraphQLNodeMap.js.flow +55 -0
  193. package/runner/Sources.js.flow +228 -0
  194. package/runner/StrictMap.js.flow +96 -0
  195. package/runner/compileArtifacts.js.flow +76 -0
  196. package/runner/extractAST.js.flow +100 -0
  197. package/runner/getChangedNodeNames.js.flow +48 -0
  198. package/runner/getSchemaInstance.js.flow +36 -0
  199. package/runner/types.js.flow +37 -0
  200. package/transforms/ApplyFragmentArgumentTransform.js.flow +526 -0
  201. package/transforms/ClientExtensionsTransform.js.flow +226 -0
  202. package/transforms/ConnectionTransform.js.flow +859 -0
  203. package/transforms/DeclarativeConnectionMutationTransform.js.flow +250 -0
  204. package/transforms/DeferStreamTransform.js.flow +266 -0
  205. package/transforms/DisallowIdAsAlias.js.flow +48 -0
  206. package/transforms/DisallowTypenameOnRoot.js.flow +45 -0
  207. package/transforms/FieldHandleTransform.js.flow +81 -0
  208. package/transforms/FilterCompilerDirectivesTransform.js.flow +33 -0
  209. package/transforms/FilterDirectivesTransform.js.flow +45 -0
  210. package/transforms/FlattenTransform.js.flow +462 -0
  211. package/transforms/GenerateIDFieldTransform.js.flow +154 -0
  212. package/transforms/GenerateTypeNameTransform.js.flow +167 -0
  213. package/transforms/InlineDataFragmentTransform.js.flow +129 -0
  214. package/transforms/InlineFragmentsTransform.js.flow +73 -0
  215. package/transforms/MaskTransform.js.flow +130 -0
  216. package/transforms/MatchTransform.js.flow +593 -0
  217. package/transforms/ReactFlightComponentTransform.js.flow +198 -0
  218. package/transforms/RefetchableFragmentTransform.js.flow +272 -0
  219. package/transforms/RelayDirectiveTransform.js.flow +99 -0
  220. package/transforms/RequiredFieldTransform.js.flow +419 -0
  221. package/transforms/SkipClientExtensionsTransform.js.flow +57 -0
  222. package/transforms/SkipHandleFieldTransform.js.flow +45 -0
  223. package/transforms/SkipRedundantNodesTransform.js.flow +259 -0
  224. package/transforms/SkipSplitOperationTransform.js.flow +37 -0
  225. package/transforms/SkipUnreachableNodeTransform.js.flow +149 -0
  226. package/transforms/SkipUnusedVariablesTransform.js.flow +59 -0
  227. package/transforms/SplitModuleImportTransform.js.flow +101 -0
  228. package/transforms/TestOperationTransform.js.flow +143 -0
  229. package/transforms/TransformUtils.js.flow +26 -0
  230. package/transforms/ValidateGlobalVariablesTransform.js.flow +81 -0
  231. package/transforms/ValidateRequiredArgumentsTransform.js.flow +131 -0
  232. package/transforms/ValidateServerOnlyDirectivesTransform.js.flow +115 -0
  233. package/transforms/ValidateUnusedVariablesTransform.js.flow +89 -0
  234. package/transforms/query-generators/FetchableQueryGenerator.js.flow +189 -0
  235. package/transforms/query-generators/NodeQueryGenerator.js.flow +219 -0
  236. package/transforms/query-generators/QueryQueryGenerator.js.flow +57 -0
  237. package/transforms/query-generators/ViewerQueryGenerator.js.flow +97 -0
  238. package/transforms/query-generators/index.js.flow +90 -0
  239. package/transforms/query-generators/utils.js.flow +76 -0
  240. package/util/CodeMarker.js.flow +79 -0
  241. package/util/DefaultHandleKey.js.flow +17 -0
  242. package/util/RelayCompilerCache.js.flow +88 -0
  243. package/util/Rollout.js.flow +39 -0
  244. package/util/TimeReporter.js.flow +79 -0
  245. package/util/areEqualArgValues.js.flow +126 -0
  246. package/util/argumentContainsVariables.js.flow +38 -0
  247. package/util/dedupeJSONStringify.js.flow +152 -0
  248. package/util/generateAbstractTypeRefinementKey.js.flow +29 -0
  249. package/util/getDefinitionNodeHash.js.flow +25 -0
  250. package/util/getModuleName.js.flow +39 -0
  251. package/util/joinArgumentDefinitions.js.flow +105 -0
  252. package/util/md5.js.flow +22 -0
  253. package/util/murmurHash.js.flow +94 -0
  254. package/util/nullthrowsOSS.js.flow +25 -0
  255. package/util/orList.js.flow +37 -0
  256. package/util/partitionArray.js.flow +37 -0
@@ -0,0 +1,643 @@
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
+ // flowlint ambiguous-object-type:error
11
+ 'use strict';
12
+
13
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
14
+
15
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
16
+
17
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
18
+
19
+ var IRTransformer = require('../core/IRTransformer');
20
+
21
+ var RelayParser = require('../core/RelayParser');
22
+
23
+ var SchemaUtils = require('../core/SchemaUtils');
24
+
25
+ var getLiteralArgumentValues = require('../core/getLiteralArgumentValues');
26
+
27
+ var _require = require('../core/CompilerError'),
28
+ createCompilerError = _require.createCompilerError,
29
+ createUserError = _require.createUserError;
30
+
31
+ var _require2 = require('graphql'),
32
+ parse = _require2.parse;
33
+
34
+ var _require3 = require('relay-runtime'),
35
+ ConnectionInterface = _require3.ConnectionInterface,
36
+ RelayFeatureFlags = _require3.RelayFeatureFlags;
37
+
38
+ var AFTER = 'after';
39
+ var BEFORE = 'before';
40
+ var FIRST = 'first';
41
+ var KEY = 'key';
42
+ var LAST = 'last';
43
+ var CONNECTION = 'connection';
44
+ var STREAM_CONNECTION = 'stream_connection';
45
+ var HANDLER = 'handler';
46
+ /**
47
+ * @public
48
+ *
49
+ * Transforms fields with the `@connection` directive:
50
+ * - Verifies that the field type is connection-like.
51
+ * - Adds a `handle` property to the field, either the user-provided `handle`
52
+ * argument or the default value "connection".
53
+ * - Inserts a sub-fragment on the field to ensure that standard connection
54
+ * fields are fetched (e.g. cursors, node ids, page info).
55
+ */
56
+
57
+ function connectionTransform(context) {
58
+ return IRTransformer.transform(context, {
59
+ Fragment: visitFragmentOrRoot,
60
+ LinkedField: visitLinkedField,
61
+ Root: visitFragmentOrRoot
62
+ }, function (node) {
63
+ return {
64
+ documentName: node.name,
65
+ path: [],
66
+ connectionMetadata: []
67
+ };
68
+ });
69
+ }
70
+
71
+ var SCHEMA_EXTENSION = "\n directive @connection(\n key: String!\n filters: [String]\n handler: String\n dynamicKey_UNSTABLE: String\n ) on FIELD\n\n directive @stream_connection(\n key: String!\n filters: [String]\n handler: String\n initial_count: Int!\n if: Boolean = true\n use_customized_batch: Boolean = false\n dynamicKey_UNSTABLE: String\n ) on FIELD\n";
72
+ /**
73
+ * @internal
74
+ */
75
+
76
+ function visitFragmentOrRoot(node, options) {
77
+ // $FlowFixMe[incompatible-use]
78
+ var transformedNode = this.traverse(node, options);
79
+ var connectionMetadata = options.connectionMetadata;
80
+
81
+ if (connectionMetadata.length) {
82
+ return (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, transformedNode), {}, {
83
+ metadata: (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, transformedNode.metadata), {}, {
84
+ connection: connectionMetadata
85
+ })
86
+ });
87
+ }
88
+
89
+ return transformedNode;
90
+ }
91
+ /**
92
+ * @internal
93
+ */
94
+
95
+
96
+ function visitLinkedField(field, options) {
97
+ var _connectionArguments$;
98
+
99
+ // $FlowFixMe[incompatible-use]
100
+ var context = this.getContext();
101
+ var schema = context.getSchema();
102
+ var nullableType = schema.getNullableType(field.type);
103
+ var isPlural = schema.isList(nullableType);
104
+ var path = options.path.concat(isPlural ? null : field.alias || field.name); // $FlowFixMe[incompatible-use]
105
+
106
+ var transformedField = this.traverse(field, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, options), {}, {
107
+ path: path
108
+ }));
109
+ var connectionDirective = field.directives.find(function (directive) {
110
+ return directive.name === CONNECTION || directive.name === STREAM_CONNECTION;
111
+ });
112
+
113
+ if (!connectionDirective) {
114
+ return transformedField;
115
+ }
116
+
117
+ if (!schema.isObject(nullableType) && !schema.isInterface(nullableType)) {
118
+ throw new createUserError("@".concat(connectionDirective.name, " used on invalid field '").concat(field.name, "'. ") + 'Expected the return type to be a non-plural interface or object, ' + "got '".concat(schema.getTypeString(field.type), "'."), [transformedField.loc]);
119
+ }
120
+
121
+ validateConnectionSelection(transformedField);
122
+ validateConnectionType(schema, transformedField, schema.assertCompositeType(nullableType), connectionDirective);
123
+ var connectionArguments = buildConnectionArguments(transformedField, connectionDirective);
124
+ var connectionMetadata = buildConnectionMetadata(transformedField, path, connectionArguments.stream != null);
125
+ options.connectionMetadata.push(connectionMetadata);
126
+ var handle = {
127
+ name: (_connectionArguments$ = connectionArguments.handler) !== null && _connectionArguments$ !== void 0 ? _connectionArguments$ : CONNECTION,
128
+ key: connectionArguments.key,
129
+ dynamicKey: connectionArguments.dynamicKey,
130
+ filters: connectionArguments.filters
131
+ };
132
+ var direction = connectionMetadata.direction;
133
+
134
+ if (direction != null) {
135
+ var selections = transformConnectionSelections( // $FlowFixMe[incompatible-use]
136
+ this.getContext(), transformedField, schema.assertCompositeType(nullableType), direction, connectionArguments, connectionDirective.loc, options.documentName);
137
+ transformedField = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, transformedField), {}, {
138
+ selections: selections
139
+ });
140
+ }
141
+
142
+ return (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, transformedField), {}, {
143
+ directives: transformedField.directives.filter(function (directive) {
144
+ return directive !== connectionDirective;
145
+ }),
146
+ connection: true,
147
+ handles: transformedField.handles ? [].concat((0, _toConsumableArray2["default"])(transformedField.handles), [handle]) : [handle]
148
+ });
149
+ }
150
+
151
+ function buildConnectionArguments(field, connectionDirective) {
152
+ var _getLiteralArgumentVa = getLiteralArgumentValues(connectionDirective.args),
153
+ handler = _getLiteralArgumentVa.handler,
154
+ key = _getLiteralArgumentVa.key,
155
+ label = _getLiteralArgumentVa.label,
156
+ literalFilters = _getLiteralArgumentVa.filters;
157
+
158
+ if (handler != null && typeof handler !== 'string') {
159
+ var _handleArg$value$loc, _handleArg$value;
160
+
161
+ var handleArg = connectionDirective.args.find(function (arg) {
162
+ return arg.name === 'handler';
163
+ });
164
+ throw createUserError("Expected the ".concat(HANDLER, " argument to @").concat(connectionDirective.name, " to ") + "be a string literal for field ".concat(field.name, "."), [(_handleArg$value$loc = handleArg === null || handleArg === void 0 ? void 0 : (_handleArg$value = handleArg.value) === null || _handleArg$value === void 0 ? void 0 : _handleArg$value.loc) !== null && _handleArg$value$loc !== void 0 ? _handleArg$value$loc : connectionDirective.loc]);
165
+ }
166
+
167
+ if (typeof key !== 'string') {
168
+ var _keyArg$value$loc, _keyArg$value;
169
+
170
+ var keyArg = connectionDirective.args.find(function (arg) {
171
+ return arg.name === 'key';
172
+ });
173
+ throw createUserError("Expected the ".concat(KEY, " argument to @").concat(connectionDirective.name, " to be a ") + "string literal for field ".concat(field.name, "."), [(_keyArg$value$loc = keyArg === null || keyArg === void 0 ? void 0 : (_keyArg$value = keyArg.value) === null || _keyArg$value === void 0 ? void 0 : _keyArg$value.loc) !== null && _keyArg$value$loc !== void 0 ? _keyArg$value$loc : connectionDirective.loc]);
174
+ }
175
+
176
+ var postfix = field.alias || field.name;
177
+
178
+ if (!key.endsWith('_' + postfix)) {
179
+ var _keyArg$value$loc2, _keyArg$value2;
180
+
181
+ var _keyArg = connectionDirective.args.find(function (arg) {
182
+ return arg.name === 'key';
183
+ });
184
+
185
+ throw createUserError("Expected the ".concat(KEY, " argument to @").concat(connectionDirective.name, " to be of ") + "form <SomeName>_".concat(postfix, ", got '").concat(key, "'. ") + 'For a detailed explanation, check out ' + 'https://relay.dev/docs/en/pagination-container#connection', [(_keyArg$value$loc2 = _keyArg === null || _keyArg === void 0 ? void 0 : (_keyArg$value2 = _keyArg.value) === null || _keyArg$value2 === void 0 ? void 0 : _keyArg$value2.loc) !== null && _keyArg$value$loc2 !== void 0 ? _keyArg$value$loc2 : connectionDirective.loc]);
186
+ }
187
+
188
+ if (literalFilters != null && (!Array.isArray(literalFilters) || literalFilters.some(function (filter) {
189
+ return typeof filter !== 'string';
190
+ }))) {
191
+ var _filtersArg$value$loc, _filtersArg$value;
192
+
193
+ var filtersArg = connectionDirective.args.find(function (arg) {
194
+ return arg.name === 'filters';
195
+ });
196
+ throw createUserError("Expected the 'filters' argument to @".concat(connectionDirective.name, " to be ") + 'a string literal.', [(_filtersArg$value$loc = filtersArg === null || filtersArg === void 0 ? void 0 : (_filtersArg$value = filtersArg.value) === null || _filtersArg$value === void 0 ? void 0 : _filtersArg$value.loc) !== null && _filtersArg$value$loc !== void 0 ? _filtersArg$value$loc : connectionDirective.loc]);
197
+ }
198
+
199
+ var filters = literalFilters;
200
+
201
+ if (filters == null) {
202
+ var generatedFilters = field.args.filter(function (arg) {
203
+ return !ConnectionInterface.isConnectionCall({
204
+ name: arg.name,
205
+ value: null
206
+ });
207
+ }).map(function (arg) {
208
+ return arg.name;
209
+ });
210
+ filters = generatedFilters.length !== 0 ? generatedFilters : null;
211
+ }
212
+
213
+ var stream = null;
214
+
215
+ if (connectionDirective.name === STREAM_CONNECTION) {
216
+ var initialCountArg = connectionDirective.args.find(function (arg) {
217
+ return arg.name === 'initial_count';
218
+ });
219
+ var useCustomizedBatchArg = connectionDirective.args.find(function (arg) {
220
+ return arg.name === 'use_customized_batch';
221
+ });
222
+ var ifArg = connectionDirective.args.find(function (arg) {
223
+ return arg.name === 'if';
224
+ });
225
+ stream = {
226
+ "if": ifArg,
227
+ initialCount: initialCountArg,
228
+ useCustomizedBatch: useCustomizedBatchArg,
229
+ label: key
230
+ };
231
+ }
232
+
233
+ var dynamicKeyArg = connectionDirective.args.find(function (arg) {
234
+ return arg.name === 'dynamicKey_UNSTABLE';
235
+ });
236
+ var dynamicKey = null;
237
+
238
+ if (dynamicKeyArg != null) {
239
+ if (RelayFeatureFlags.ENABLE_VARIABLE_CONNECTION_KEY && dynamicKeyArg.value.kind === 'Variable') {
240
+ dynamicKey = dynamicKeyArg.value;
241
+ } else {
242
+ throw createUserError("Unsupported 'dynamicKey_UNSTABLE' argument to @".concat(connectionDirective.name, ". This argument is only valid when the feature flag is enabled and ") + 'the variable must be a variable', [connectionDirective.loc]);
243
+ }
244
+ }
245
+
246
+ return {
247
+ handler: handler,
248
+ key: key,
249
+ dynamicKey: dynamicKey,
250
+ filters: filters,
251
+ stream: stream
252
+ };
253
+ }
254
+
255
+ function buildConnectionMetadata(field, path, stream) {
256
+ var pathHasPlural = path.includes(null);
257
+ var firstArg = findArg(field, FIRST);
258
+ var lastArg = findArg(field, LAST);
259
+ var direction = null;
260
+ var countArg = null;
261
+ var cursorArg = null;
262
+
263
+ if (firstArg && !lastArg) {
264
+ direction = 'forward';
265
+ countArg = firstArg;
266
+ cursorArg = findArg(field, AFTER);
267
+ } else if (lastArg && !firstArg) {
268
+ direction = 'backward';
269
+ countArg = lastArg;
270
+ cursorArg = findArg(field, BEFORE);
271
+ } else if (lastArg && firstArg) {
272
+ direction = 'bidirectional'; // TODO(T26511885) Maybe add connection metadata to this case
273
+ }
274
+
275
+ var countVariable = countArg && countArg.value.kind === 'Variable' ? countArg.value.variableName : null;
276
+ var cursorVariable = cursorArg && cursorArg.value.kind === 'Variable' ? cursorArg.value.variableName : null;
277
+
278
+ if (stream) {
279
+ return {
280
+ count: countVariable,
281
+ cursor: cursorVariable,
282
+ direction: direction,
283
+ path: pathHasPlural ? null : path,
284
+ stream: true
285
+ };
286
+ }
287
+
288
+ return {
289
+ count: countVariable,
290
+ cursor: cursorVariable,
291
+ direction: direction,
292
+ path: pathHasPlural ? null : path
293
+ };
294
+ }
295
+ /**
296
+ * @internal
297
+ *
298
+ * Transforms the selections on a connection field, generating fields necessary
299
+ * for pagination (edges.cursor, pageInfo, etc) and adding/merging them with
300
+ * existing selections.
301
+ */
302
+
303
+
304
+ function transformConnectionSelections(context, field, nullableType, direction, connectionArguments, directiveLocation, documentName) {
305
+ var schema = context.getSchema();
306
+ var derivedFieldLocation = {
307
+ kind: 'Derived',
308
+ source: field.loc
309
+ };
310
+ var derivedDirectiveLocation = {
311
+ kind: 'Derived',
312
+ source: directiveLocation
313
+ };
314
+
315
+ var _ConnectionInterface$ = ConnectionInterface.get(),
316
+ CURSOR = _ConnectionInterface$.CURSOR,
317
+ EDGES = _ConnectionInterface$.EDGES,
318
+ END_CURSOR = _ConnectionInterface$.END_CURSOR,
319
+ HAS_NEXT_PAGE = _ConnectionInterface$.HAS_NEXT_PAGE,
320
+ HAS_PREV_PAGE = _ConnectionInterface$.HAS_PREV_PAGE,
321
+ NODE = _ConnectionInterface$.NODE,
322
+ PAGE_INFO = _ConnectionInterface$.PAGE_INFO,
323
+ START_CURSOR = _ConnectionInterface$.START_CURSOR; // Find existing edges/pageInfo selections
324
+
325
+
326
+ var edgesSelection;
327
+ var pageInfoSelection;
328
+ field.selections.forEach(function (selection) {
329
+ if (selection.kind === 'LinkedField') {
330
+ if (selection.name === EDGES) {
331
+ if (edgesSelection != null) {
332
+ throw createCompilerError("ConnectionTransform: Unexpected duplicate field '".concat(EDGES, "'."), [edgesSelection.loc, selection.loc]);
333
+ }
334
+
335
+ edgesSelection = selection;
336
+ return;
337
+ } else if (selection.name === PAGE_INFO) {
338
+ if (pageInfoSelection != null) {
339
+ throw createCompilerError("ConnectionTransform: Unexpected duplicate field '".concat(PAGE_INFO, "'."), [pageInfoSelection.loc, selection.loc]);
340
+ }
341
+
342
+ pageInfoSelection = selection;
343
+ return;
344
+ }
345
+ }
346
+ }); // If streaming is enabled, construct directives to apply to the edges/
347
+ // pageInfo fields
348
+
349
+ var streamDirective;
350
+ var stream = connectionArguments.stream;
351
+
352
+ if (stream != null) {
353
+ streamDirective = {
354
+ args: [stream["if"], stream.initialCount, stream.useCustomizedBatch, {
355
+ kind: 'Argument',
356
+ loc: derivedDirectiveLocation,
357
+ name: 'label',
358
+ type: SchemaUtils.getNullableStringInput(schema),
359
+ value: {
360
+ kind: 'Literal',
361
+ loc: derivedDirectiveLocation,
362
+ value: stream.label
363
+ }
364
+ }].filter(Boolean),
365
+ kind: 'Directive',
366
+ loc: derivedDirectiveLocation,
367
+ name: 'stream'
368
+ };
369
+ } // For backwards compatibility with earlier versions of this transform,
370
+ // edges/pageInfo have to be generated as non-aliased fields (since product
371
+ // code may be accessing the non-aliased response keys). But for streaming
372
+ // mode we need to generate @stream/@defer directives on these fields *and*
373
+ // we prefer to avoid generating extra selections (we want one payload per
374
+ // item, not two as could happen with separate @stream directives on the
375
+ // aliased and non-aliased edges fields). So we keep things simple by
376
+ // disallowing aliases on edges/pageInfo in streaming mode.
377
+
378
+
379
+ if (edgesSelection && edgesSelection.alias !== edgesSelection.name) {
380
+ if (stream) {
381
+ throw createUserError("@stream_connection does not support aliasing the '".concat(EDGES, "' field."), [edgesSelection.loc]);
382
+ }
383
+
384
+ edgesSelection = null;
385
+ }
386
+
387
+ if (pageInfoSelection && pageInfoSelection.alias !== pageInfoSelection.name) {
388
+ if (stream) {
389
+ throw createUserError("@stream_connection does not support aliasing the '".concat(PAGE_INFO, "' field."), [pageInfoSelection.loc]);
390
+ }
391
+
392
+ pageInfoSelection = null;
393
+ } // Separately create transformed versions of edges/pageInfo so that we can
394
+ // later replace the originals at the same point within the selection array
395
+
396
+
397
+ var transformedEdgesSelection = edgesSelection;
398
+ var transformedPageInfoSelection = pageInfoSelection;
399
+ var edgesType = schema.getFieldConfig(schema.expectField(nullableType, EDGES)).type;
400
+ var pageInfoType = schema.getFieldConfig(schema.expectField(nullableType, PAGE_INFO)).type;
401
+
402
+ if (transformedEdgesSelection == null) {
403
+ transformedEdgesSelection = {
404
+ alias: EDGES,
405
+ args: [],
406
+ connection: false,
407
+ directives: [],
408
+ handles: null,
409
+ kind: 'LinkedField',
410
+ loc: derivedFieldLocation,
411
+ metadata: null,
412
+ name: EDGES,
413
+ selections: [],
414
+ type: schema.assertLinkedFieldType(edgesType)
415
+ };
416
+ }
417
+
418
+ if (transformedPageInfoSelection == null) {
419
+ transformedPageInfoSelection = {
420
+ alias: PAGE_INFO,
421
+ args: [],
422
+ connection: false,
423
+ directives: [],
424
+ handles: null,
425
+ kind: 'LinkedField',
426
+ loc: derivedFieldLocation,
427
+ metadata: null,
428
+ name: PAGE_INFO,
429
+ selections: [],
430
+ type: schema.assertLinkedFieldType(pageInfoType)
431
+ };
432
+ } // Generate (additional) fields on pageInfo and add to the transformed
433
+ // pageInfo field
434
+
435
+
436
+ var pageInfoRawType = schema.getRawType(pageInfoType);
437
+ var pageInfoText;
438
+
439
+ if (direction === 'forward') {
440
+ pageInfoText = "fragment PageInfo on ".concat(schema.getTypeString(pageInfoRawType), " {\n ").concat(END_CURSOR, "\n ").concat(HAS_NEXT_PAGE, "\n }");
441
+ } else if (direction === 'backward') {
442
+ pageInfoText = "fragment PageInfo on ".concat(schema.getTypeString(pageInfoRawType), " {\n ").concat(HAS_PREV_PAGE, "\n ").concat(START_CURSOR, "\n }");
443
+ } else {
444
+ pageInfoText = "fragment PageInfo on ".concat(schema.getTypeString(pageInfoRawType), " {\n ").concat(END_CURSOR, "\n ").concat(HAS_NEXT_PAGE, "\n ").concat(HAS_PREV_PAGE, "\n ").concat(START_CURSOR, "\n }");
445
+ }
446
+
447
+ var pageInfoAst = parse(pageInfoText);
448
+ var pageInfoFragment = RelayParser.transform(schema, [pageInfoAst.definitions[0]])[0];
449
+
450
+ if (transformedPageInfoSelection.kind !== 'LinkedField') {
451
+ throw createCompilerError('ConnectionTransform: Expected generated pageInfo selection to be ' + 'a LinkedField', [field.loc]);
452
+ }
453
+
454
+ transformedPageInfoSelection = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, transformedPageInfoSelection), {}, {
455
+ selections: [].concat((0, _toConsumableArray2["default"])(transformedPageInfoSelection.selections), [{
456
+ directives: [],
457
+ kind: 'InlineFragment',
458
+ loc: derivedFieldLocation,
459
+ metadata: null,
460
+ selections: pageInfoFragment.selections,
461
+ typeCondition: pageInfoFragment.type
462
+ }])
463
+ }); // When streaming the pageInfo field has to be deferred
464
+
465
+ if (stream != null) {
466
+ var _stream$if$value, _stream$if;
467
+
468
+ transformedPageInfoSelection = {
469
+ "if": (_stream$if$value = (_stream$if = stream["if"]) === null || _stream$if === void 0 ? void 0 : _stream$if.value) !== null && _stream$if$value !== void 0 ? _stream$if$value : null,
470
+ label: "".concat(documentName, "$defer$").concat(stream.label, "$").concat(PAGE_INFO),
471
+ kind: 'Defer',
472
+ loc: derivedFieldLocation,
473
+ selections: [transformedPageInfoSelection]
474
+ };
475
+ } // Generate additional fields on edges and append to the transformed edges
476
+ // selection
477
+
478
+
479
+ var edgeText = "\n fragment Edges on ".concat(schema.getTypeString(schema.getRawType(edgesType)), " {\n ").concat(CURSOR, "\n ").concat(NODE, " {\n __typename # rely on GenerateRequisiteFieldTransform to add \"id\"\n }\n }\n ");
480
+ var edgeAst = parse(edgeText);
481
+ var edgeFragment = RelayParser.transform(schema, [edgeAst.definitions[0]])[0]; // When streaming the edges field needs @stream
482
+
483
+ transformedEdgesSelection = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, transformedEdgesSelection), {}, {
484
+ directives: streamDirective != null ? [].concat((0, _toConsumableArray2["default"])(transformedEdgesSelection.directives), [streamDirective]) : transformedEdgesSelection.directives,
485
+ selections: [].concat((0, _toConsumableArray2["default"])(transformedEdgesSelection.selections), [{
486
+ directives: [],
487
+ kind: 'InlineFragment',
488
+ loc: derivedFieldLocation,
489
+ metadata: null,
490
+ selections: edgeFragment.selections,
491
+ typeCondition: edgeFragment.type
492
+ }])
493
+ }); // Copy the original selections, replacing edges/pageInfo (if present)
494
+ // with the generated locations. This is to maintain the original field
495
+ // ordering.
496
+
497
+ var selections = field.selections.map(function (selection) {
498
+ if (transformedEdgesSelection != null && edgesSelection != null && selection === edgesSelection) {
499
+ return transformedEdgesSelection;
500
+ } else if (transformedPageInfoSelection != null && pageInfoSelection != null && selection === pageInfoSelection) {
501
+ return transformedPageInfoSelection;
502
+ } else {
503
+ return selection;
504
+ }
505
+ }); // If edges/pageInfo were missing, append the generated versions instead.
506
+
507
+ if (edgesSelection == null && transformedEdgesSelection != null) {
508
+ selections.push(transformedEdgesSelection);
509
+ }
510
+
511
+ if (pageInfoSelection == null && transformedPageInfoSelection != null) {
512
+ selections.push(transformedPageInfoSelection);
513
+ }
514
+
515
+ return selections;
516
+ }
517
+
518
+ function findArg(field, argName) {
519
+ return field.args && field.args.find(function (arg) {
520
+ return arg.name === argName;
521
+ });
522
+ }
523
+ /**
524
+ * @internal
525
+ *
526
+ * Validates that the selection is a valid connection:
527
+ * - Specifies a first or last argument to prevent accidental, unconstrained
528
+ * data access.
529
+ * - Has an `edges` selection, otherwise there is nothing to paginate.
530
+ *
531
+ * TODO: This implementation requires the edges field to be a direct selection
532
+ * and not contained within an inline fragment or fragment spread. It's
533
+ * technically possible to remove this restriction if this pattern becomes
534
+ * common/necessary.
535
+ */
536
+
537
+
538
+ function validateConnectionSelection(field) {
539
+ var _ConnectionInterface$2 = ConnectionInterface.get(),
540
+ EDGES = _ConnectionInterface$2.EDGES;
541
+
542
+ if (!findArg(field, FIRST) && !findArg(field, LAST)) {
543
+ throw createUserError("Expected field '".concat(field.name, "' to have a '").concat(FIRST, "' or '").concat(LAST, "' ") + 'argument.', [field.loc]);
544
+ }
545
+
546
+ if (!field.selections.some(function (selection) {
547
+ return selection.kind === 'LinkedField' && selection.name === EDGES;
548
+ })) {
549
+ throw createUserError("Expected field '".concat(field.name, "' to have an '").concat(EDGES, "' selection."), [field.loc]);
550
+ }
551
+ }
552
+ /**
553
+ * @internal
554
+ *
555
+ * Validates that the type satisfies the Connection specification:
556
+ * - The type has an edges field, and edges have scalar `cursor` and object
557
+ * `node` fields.
558
+ * - The type has a page info field which is an object with the correct
559
+ * subfields.
560
+ */
561
+
562
+
563
+ function validateConnectionType(schema, field, nullableType, connectionDirective) {
564
+ var directiveName = connectionDirective.name;
565
+
566
+ var _ConnectionInterface$3 = ConnectionInterface.get(),
567
+ CURSOR = _ConnectionInterface$3.CURSOR,
568
+ EDGES = _ConnectionInterface$3.EDGES,
569
+ END_CURSOR = _ConnectionInterface$3.END_CURSOR,
570
+ HAS_NEXT_PAGE = _ConnectionInterface$3.HAS_NEXT_PAGE,
571
+ HAS_PREV_PAGE = _ConnectionInterface$3.HAS_PREV_PAGE,
572
+ NODE = _ConnectionInterface$3.NODE,
573
+ PAGE_INFO = _ConnectionInterface$3.PAGE_INFO,
574
+ START_CURSOR = _ConnectionInterface$3.START_CURSOR;
575
+
576
+ var typeName = schema.getTypeString(nullableType);
577
+
578
+ if (!schema.hasField(nullableType, EDGES)) {
579
+ throw createUserError("@".concat(directiveName, " used on invalid field '").concat(field.name, "'. Expected the ") + "field type '".concat(typeName, "' to have an '").concat(EDGES, "' field"), [field.loc]);
580
+ }
581
+
582
+ var edges = schema.getFieldConfig(schema.expectField(nullableType, EDGES));
583
+ var edgesType = schema.getNullableType(edges.type);
584
+
585
+ if (!schema.isList(edgesType)) {
586
+ throw createUserError("@".concat(directiveName, " used on invalid field '").concat(field.name, "'. Expected the ") + "field type '".concat(typeName, "' to have an '").concat(EDGES, "' field that returns ") + 'a list of objects.', [field.loc]);
587
+ }
588
+
589
+ var edgeType = schema.getNullableType(schema.getListItemType(edgesType));
590
+
591
+ if (!schema.isObject(edgeType) && !schema.isInterface(edgeType)) {
592
+ throw createUserError("@".concat(directiveName, " used on invalid field '").concat(field.name, "'. Expected the ") + "field type '".concat(typeName, "' to have an '").concat(EDGES, "' field that returns ") + 'a list of objects.', [field.loc]);
593
+ }
594
+
595
+ edgeType = schema.assertCompositeType(edgeType);
596
+
597
+ if (!schema.hasField(edgeType, NODE)) {
598
+ throw createUserError("@".concat(directiveName, " used on invalid field '").concat(field.name, "'. Expected the ") + "field type '".concat(typeName, "' to have an '").concat(EDGES, " { ").concat(NODE, " }' field ") + 'that returns an object, interface, or union.', [field.loc]);
599
+ }
600
+
601
+ var node = schema.getFieldConfig(schema.expectField(edgeType, NODE));
602
+ var nodeType = schema.getNullableType(node.type);
603
+
604
+ if (!(schema.isAbstractType(nodeType) || schema.isObject(nodeType))) {
605
+ throw createUserError("@".concat(directiveName, " used on invalid field '").concat(field.name, "'. Expected the ") + "field type '".concat(typeName, "' to have an '").concat(EDGES, " { ").concat(NODE, " }' field ") + 'that returns an object, interface, or union.', [field.loc]);
606
+ }
607
+
608
+ if (!schema.hasField(edgeType, CURSOR)) {
609
+ throw createUserError("@".concat(directiveName, " used on invalid field '").concat(field.name, "'. Expected the ") + "field type '".concat(typeName, "' to have an '").concat(EDGES, " { ").concat(CURSOR, " }' field ") + 'that returns a scalar value.', [field.loc]);
610
+ }
611
+
612
+ var cursor = schema.getFieldConfig(schema.expectField(edgeType, CURSOR));
613
+
614
+ if (!schema.isScalar(schema.getNullableType(cursor.type))) {
615
+ throw createUserError("@".concat(directiveName, " used on invalid field '").concat(field.name, "'. Expected the ") + "field type '".concat(typeName, "' to have an '").concat(EDGES, " { ").concat(CURSOR, " }' field ") + 'that returns a scalar value.', [field.loc]);
616
+ }
617
+
618
+ if (!schema.hasField(nullableType, PAGE_INFO)) {
619
+ throw createUserError("@".concat(directiveName, " used on invalid field '").concat(field.name, "'. Expected the ") + "field type '".concat(typeName, "' to have a '").concat(PAGE_INFO, "' field that returns ") + 'an object.', [field.loc]);
620
+ }
621
+
622
+ var pageInfo = schema.getFieldConfig(schema.expectField(nullableType, PAGE_INFO));
623
+ var pageInfoType = schema.getNullableType(pageInfo.type);
624
+
625
+ if (!schema.isObject(pageInfoType)) {
626
+ throw createUserError("@".concat(directiveName, " used on invalid field '").concat(field.name, "'. Expected the ") + "field type '".concat(typeName, "' to have a '").concat(PAGE_INFO, "' field that ") + 'returns an object.', [field.loc]);
627
+ }
628
+
629
+ [END_CURSOR, HAS_NEXT_PAGE, HAS_PREV_PAGE, START_CURSOR].forEach(function (fieldName) {
630
+ var pageInfoField = schema.getFieldConfig(schema.expectField(schema.assertObjectType(pageInfoType), fieldName));
631
+
632
+ if (!schema.isScalar(schema.getNullableType(pageInfoField.type))) {
633
+ throw createUserError("@".concat(directiveName, " used on invalid field '").concat(field.name, "'. Expected ") + "the field type '".concat(typeName, "' to have a '").concat(PAGE_INFO, " { ").concat(fieldName, " }' ") + 'field returns a scalar.', [field.loc]);
634
+ }
635
+ });
636
+ }
637
+
638
+ module.exports = {
639
+ buildConnectionMetadata: buildConnectionMetadata,
640
+ CONNECTION: CONNECTION,
641
+ SCHEMA_EXTENSION: SCHEMA_EXTENSION,
642
+ transform: connectionTransform
643
+ };