@graphitation/supermassive 2.6.1 → 3.0.0-alpha.3

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 (206) hide show
  1. package/.eslintcache +1 -1
  2. package/CHANGELOG.md +17 -1
  3. package/lib/__testUtils__/execute.d.ts +13 -0
  4. package/lib/__testUtils__/execute.d.ts.map +1 -0
  5. package/lib/__testUtils__/execute.js +196 -0
  6. package/lib/__testUtils__/execute.js.map +7 -0
  7. package/lib/__testUtils__/execute.mjs +174 -0
  8. package/lib/__testUtils__/execute.mjs.map +7 -0
  9. package/lib/benchmarks/index.js +11 -20
  10. package/lib/benchmarks/index.js.map +3 -3
  11. package/lib/benchmarks/index.mjs +12 -23
  12. package/lib/benchmarks/index.mjs.map +2 -2
  13. package/lib/benchmarks/swapi-schema/index.d.ts +4 -2
  14. package/lib/benchmarks/swapi-schema/index.d.ts.map +1 -1
  15. package/lib/benchmarks/swapi-schema/index.js +8 -2
  16. package/lib/benchmarks/swapi-schema/index.js.map +2 -2
  17. package/lib/benchmarks/swapi-schema/index.mjs +8 -2
  18. package/lib/benchmarks/swapi-schema/index.mjs.map +2 -2
  19. package/lib/benchmarks/swapi-schema/makeExecutableSchema.d.ts +7 -0
  20. package/lib/benchmarks/swapi-schema/makeExecutableSchema.d.ts.map +1 -0
  21. package/lib/benchmarks/swapi-schema/makeExecutableSchema.js +916 -0
  22. package/lib/benchmarks/swapi-schema/makeExecutableSchema.js.map +7 -0
  23. package/lib/benchmarks/swapi-schema/makeExecutableSchema.mjs +903 -0
  24. package/lib/benchmarks/swapi-schema/makeExecutableSchema.mjs.map +7 -0
  25. package/lib/benchmarks/swapi-schema/resolvers.d.ts.map +1 -1
  26. package/lib/benchmarks/swapi-schema/resolvers.js +53 -17
  27. package/lib/benchmarks/swapi-schema/resolvers.js.map +2 -2
  28. package/lib/benchmarks/swapi-schema/resolvers.mjs +54 -18
  29. package/lib/benchmarks/swapi-schema/resolvers.mjs.map +2 -2
  30. package/lib/collectFields.d.ts +27 -10
  31. package/lib/collectFields.d.ts.map +1 -1
  32. package/lib/collectFields.js +146 -80
  33. package/lib/collectFields.js.map +3 -3
  34. package/lib/collectFields.mjs +143 -81
  35. package/lib/collectFields.mjs.map +2 -2
  36. package/lib/executeWithSchema.d.ts +1 -1
  37. package/lib/executeWithSchema.d.ts.map +1 -1
  38. package/lib/executeWithSchema.js +7 -13
  39. package/lib/executeWithSchema.js.map +2 -2
  40. package/lib/executeWithSchema.mjs +9 -20
  41. package/lib/executeWithSchema.mjs.map +2 -2
  42. package/lib/executeWithoutSchema.d.ts +53 -16
  43. package/lib/executeWithoutSchema.d.ts.map +1 -1
  44. package/lib/executeWithoutSchema.js +1076 -274
  45. package/lib/executeWithoutSchema.js.map +3 -3
  46. package/lib/executeWithoutSchema.mjs +1092 -281
  47. package/lib/executeWithoutSchema.mjs.map +3 -3
  48. package/lib/index.d.ts +3 -9
  49. package/lib/index.d.ts.map +1 -1
  50. package/lib/index.js +3 -7
  51. package/lib/index.js.map +2 -2
  52. package/lib/index.mjs +3 -10
  53. package/lib/index.mjs.map +2 -2
  54. package/lib/jsutils/AccumulatorMap.d.ts +8 -0
  55. package/lib/jsutils/AccumulatorMap.d.ts.map +1 -0
  56. package/lib/jsutils/AccumulatorMap.js +36 -0
  57. package/lib/jsutils/AccumulatorMap.js.map +7 -0
  58. package/lib/jsutils/AccumulatorMap.mjs +17 -0
  59. package/lib/jsutils/AccumulatorMap.mjs.map +7 -0
  60. package/lib/jsutils/didYouMean.d.ts +1 -2
  61. package/lib/jsutils/didYouMean.d.ts.map +1 -1
  62. package/lib/jsutils/didYouMean.js.map +2 -2
  63. package/lib/jsutils/didYouMean.mjs.map +2 -2
  64. package/lib/jsutils/instanceOf.js.map +2 -2
  65. package/lib/jsutils/instanceOf.mjs.map +2 -2
  66. package/lib/schema/definition.d.ts +95 -0
  67. package/lib/schema/definition.d.ts.map +1 -0
  68. package/lib/schema/definition.js +77 -0
  69. package/lib/schema/definition.js.map +7 -0
  70. package/lib/schema/definition.mjs +58 -0
  71. package/lib/schema/definition.mjs.map +7 -0
  72. package/lib/schema/directives.d.ts +41 -0
  73. package/lib/schema/directives.d.ts.map +1 -0
  74. package/lib/schema/directives.js +82 -0
  75. package/lib/schema/directives.js.map +7 -0
  76. package/lib/schema/directives.mjs +65 -0
  77. package/lib/schema/directives.mjs.map +7 -0
  78. package/lib/schema/fragment.d.ts +41 -0
  79. package/lib/schema/fragment.d.ts.map +1 -0
  80. package/lib/schema/fragment.js +270 -0
  81. package/lib/schema/fragment.js.map +7 -0
  82. package/lib/schema/fragment.mjs +267 -0
  83. package/lib/schema/fragment.mjs.map +7 -0
  84. package/lib/schema/reference.d.ts +12 -0
  85. package/lib/schema/reference.d.ts.map +1 -0
  86. package/lib/schema/reference.js +137 -0
  87. package/lib/schema/reference.js.map +7 -0
  88. package/lib/schema/reference.mjs +118 -0
  89. package/lib/schema/reference.mjs.map +7 -0
  90. package/lib/schema/resolvers.d.ts +9 -0
  91. package/lib/schema/resolvers.d.ts.map +1 -0
  92. package/lib/schema/resolvers.js +47 -0
  93. package/lib/schema/resolvers.js.map +7 -0
  94. package/lib/schema/resolvers.mjs +35 -0
  95. package/lib/schema/resolvers.mjs.map +7 -0
  96. package/lib/subscribeWithSchema.d.ts +3 -2
  97. package/lib/subscribeWithSchema.d.ts.map +1 -1
  98. package/lib/subscribeWithSchema.js +7 -13
  99. package/lib/subscribeWithSchema.js.map +2 -2
  100. package/lib/subscribeWithSchema.mjs +9 -20
  101. package/lib/subscribeWithSchema.mjs.map +2 -2
  102. package/lib/subscribeWithoutSchema.d.ts +3 -35
  103. package/lib/subscribeWithoutSchema.d.ts.map +1 -1
  104. package/lib/subscribeWithoutSchema.js +1 -163
  105. package/lib/subscribeWithoutSchema.js.map +2 -2
  106. package/lib/subscribeWithoutSchema.mjs +2 -175
  107. package/lib/subscribeWithoutSchema.mjs.map +2 -2
  108. package/lib/types.d.ts +71 -29
  109. package/lib/types.d.ts.map +1 -1
  110. package/lib/types.js +14 -0
  111. package/lib/types.js.map +2 -2
  112. package/lib/types.mjs +11 -0
  113. package/lib/types.mjs.map +3 -3
  114. package/lib/utilities/addMinimalViableSchemaToRequestDocument.d.ts +9 -0
  115. package/lib/utilities/addMinimalViableSchemaToRequestDocument.d.ts.map +1 -0
  116. package/lib/utilities/addMinimalViableSchemaToRequestDocument.js +303 -0
  117. package/lib/utilities/addMinimalViableSchemaToRequestDocument.js.map +7 -0
  118. package/lib/utilities/addMinimalViableSchemaToRequestDocument.mjs +317 -0
  119. package/lib/utilities/addMinimalViableSchemaToRequestDocument.mjs.map +7 -0
  120. package/lib/utilities/annotateDocumentGraphQLTransform.d.ts +3 -0
  121. package/lib/utilities/annotateDocumentGraphQLTransform.d.ts.map +1 -0
  122. package/lib/utilities/annotateDocumentGraphQLTransform.js +34 -0
  123. package/lib/utilities/annotateDocumentGraphQLTransform.js.map +7 -0
  124. package/lib/utilities/annotateDocumentGraphQLTransform.mjs +17 -0
  125. package/lib/utilities/annotateDocumentGraphQLTransform.mjs.map +7 -0
  126. package/lib/utilities/coerceInputValue.d.ts +10 -0
  127. package/lib/utilities/coerceInputValue.d.ts.map +1 -0
  128. package/lib/utilities/coerceInputValue.js +181 -0
  129. package/lib/utilities/coerceInputValue.js.map +7 -0
  130. package/lib/utilities/coerceInputValue.mjs +167 -0
  131. package/lib/utilities/coerceInputValue.mjs.map +7 -0
  132. package/lib/utilities/decodeASTSchema.d.ts +7 -0
  133. package/lib/utilities/decodeASTSchema.d.ts.map +1 -0
  134. package/lib/utilities/decodeASTSchema.js +243 -0
  135. package/lib/utilities/decodeASTSchema.js.map +7 -0
  136. package/lib/utilities/decodeASTSchema.mjs +242 -0
  137. package/lib/utilities/decodeASTSchema.mjs.map +7 -0
  138. package/lib/utilities/encodeASTSchema.d.ts +4 -0
  139. package/lib/utilities/encodeASTSchema.d.ts.map +1 -0
  140. package/lib/utilities/encodeASTSchema.js +122 -0
  141. package/lib/utilities/encodeASTSchema.js.map +7 -0
  142. package/lib/utilities/encodeASTSchema.mjs +105 -0
  143. package/lib/utilities/encodeASTSchema.mjs.map +7 -0
  144. package/lib/utilities/getSchemaFragment.d.ts +4 -0
  145. package/lib/utilities/getSchemaFragment.d.ts.map +1 -0
  146. package/lib/utilities/getSchemaFragment.js +38 -0
  147. package/lib/utilities/getSchemaFragment.js.map +7 -0
  148. package/lib/utilities/getSchemaFragment.mjs +22 -0
  149. package/lib/utilities/getSchemaFragment.mjs.map +7 -0
  150. package/lib/utilities/makeReadableErrorPath.d.ts +3 -0
  151. package/lib/utilities/makeReadableErrorPath.d.ts.map +1 -0
  152. package/lib/utilities/makeReadableErrorPath.js +47 -0
  153. package/lib/utilities/makeReadableErrorPath.js.map +7 -0
  154. package/lib/utilities/makeReadableErrorPath.mjs +28 -0
  155. package/lib/utilities/makeReadableErrorPath.mjs.map +7 -0
  156. package/lib/utilities/mergeDefinitions.d.ts +8 -0
  157. package/lib/utilities/mergeDefinitions.d.ts.map +1 -0
  158. package/lib/utilities/mergeDefinitions.js +126 -0
  159. package/lib/utilities/mergeDefinitions.js.map +7 -0
  160. package/lib/utilities/mergeDefinitions.mjs +114 -0
  161. package/lib/utilities/mergeDefinitions.mjs.map +7 -0
  162. package/lib/utilities/mergeResolvers.d.ts +1 -1
  163. package/lib/utilities/mergeResolvers.d.ts.map +1 -1
  164. package/lib/utilities/mergeResolvers.js.map +2 -2
  165. package/lib/utilities/mergeResolvers.mjs.map +2 -2
  166. package/lib/utilities/typeNameFromAST.d.ts +1 -1
  167. package/lib/utilities/typeNameFromAST.d.ts.map +1 -1
  168. package/lib/utilities/typeNameFromAST.js.map +2 -2
  169. package/lib/utilities/typeNameFromAST.mjs.map +2 -2
  170. package/lib/utilities/valueFromAST.d.ts +27 -0
  171. package/lib/utilities/valueFromAST.d.ts.map +1 -0
  172. package/lib/utilities/valueFromAST.js +139 -0
  173. package/lib/utilities/valueFromAST.js.map +7 -0
  174. package/lib/utilities/valueFromAST.mjs +125 -0
  175. package/lib/utilities/valueFromAST.mjs.map +7 -0
  176. package/lib/utilities/valueFromASTUntyped.d.ts +21 -0
  177. package/lib/utilities/valueFromASTUntyped.d.ts.map +1 -0
  178. package/lib/utilities/valueFromASTUntyped.js +51 -0
  179. package/lib/utilities/valueFromASTUntyped.js.map +7 -0
  180. package/lib/utilities/valueFromASTUntyped.mjs +32 -0
  181. package/lib/utilities/valueFromASTUntyped.mjs.map +7 -0
  182. package/lib/values.d.ts +8 -13
  183. package/lib/values.d.ts.map +1 -1
  184. package/lib/values.js +83 -75
  185. package/lib/values.js.map +2 -2
  186. package/lib/values.mjs +85 -83
  187. package/lib/values.mjs.map +2 -2
  188. package/package.json +8 -9
  189. package/lib/definition.d.ts +0 -7
  190. package/lib/definition.d.ts.map +0 -1
  191. package/lib/definition.js +0 -59
  192. package/lib/definition.js.map +0 -7
  193. package/lib/definition.mjs +0 -40
  194. package/lib/definition.mjs.map +0 -7
  195. package/lib/directives.d.ts +0 -79
  196. package/lib/directives.d.ts.map +0 -1
  197. package/lib/directives.js +0 -160
  198. package/lib/directives.js.map +0 -7
  199. package/lib/directives.mjs +0 -146
  200. package/lib/directives.mjs.map +0 -7
  201. package/lib/extractImplicitTypesRuntime.d.ts +0 -4
  202. package/lib/extractImplicitTypesRuntime.d.ts.map +0 -1
  203. package/lib/extractImplicitTypesRuntime.js +0 -123
  204. package/lib/extractImplicitTypesRuntime.js.map +0 -7
  205. package/lib/extractImplicitTypesRuntime.mjs +0 -114
  206. package/lib/extractImplicitTypesRuntime.mjs.map +0 -7
@@ -0,0 +1,903 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+
21
+ // src/benchmarks/swapi-schema/makeExecutableSchema.ts
22
+ import {
23
+ GraphQLBoolean,
24
+ GraphQLDirective,
25
+ GraphQLEnumType,
26
+ GraphQLFloat,
27
+ GraphQLID,
28
+ GraphQLInputObjectType,
29
+ GraphQLInt,
30
+ GraphQLInterfaceType,
31
+ GraphQLList,
32
+ GraphQLNonNull,
33
+ GraphQLObjectType,
34
+ GraphQLScalarType,
35
+ GraphQLSchema,
36
+ GraphQLString,
37
+ GraphQLUnionType,
38
+ Kind,
39
+ buildASTSchema,
40
+ getNullableType,
41
+ isEnumType,
42
+ isInputObjectType,
43
+ isInterfaceType,
44
+ isLeafType,
45
+ isListType,
46
+ isNamedType,
47
+ isNonNullType,
48
+ isObjectType,
49
+ isScalarType,
50
+ isSpecifiedDirective,
51
+ isSpecifiedScalarType,
52
+ isUnionType
53
+ } from "graphql";
54
+ var makeExecutableSchema = ({
55
+ typeDefs,
56
+ resolvers
57
+ }) => {
58
+ const schema = buildASTSchema(typeDefs);
59
+ return createNewSchemaWithResolvers(schema, resolvers);
60
+ };
61
+ var createNewSchemaWithResolvers = (schema, resolvers) => {
62
+ schema = mapSchema(schema, {
63
+ ["MapperKind.SCALAR_TYPE" /* SCALAR_TYPE */]: (type) => {
64
+ var _a, _b, _c, _d, _e, _f;
65
+ const config = type.toConfig();
66
+ const resolverValue = resolvers[type.name];
67
+ if (!isSpecifiedScalarType(type) && resolverValue != null) {
68
+ for (const fieldName in resolverValue) {
69
+ if (fieldName.startsWith("__")) {
70
+ config[fieldName.substring(2)] = resolverValue[fieldName];
71
+ } else if (fieldName === "astNode" && config.astNode != null) {
72
+ config.astNode = __spreadProps(__spreadValues({}, config.astNode), {
73
+ description: (_b = (_a = resolverValue == null ? void 0 : resolverValue.astNode) == null ? void 0 : _a.description) != null ? _b : config.astNode.description,
74
+ directives: ((_c = config.astNode.directives) != null ? _c : []).concat(
75
+ (_e = (_d = resolverValue == null ? void 0 : resolverValue.astNode) == null ? void 0 : _d.directives) != null ? _e : []
76
+ )
77
+ });
78
+ } else if (fieldName === "extensionASTNodes" && config.extensionASTNodes != null) {
79
+ config.extensionASTNodes = config.extensionASTNodes.concat(
80
+ (_f = resolverValue == null ? void 0 : resolverValue.extensionASTNodes) != null ? _f : []
81
+ );
82
+ } else if (fieldName === "extensions" && config.extensions != null && resolverValue.extensions != null) {
83
+ config.extensions = Object.assign(
84
+ /* @__PURE__ */ Object.create(null),
85
+ type.extensions,
86
+ resolverValue.extensions
87
+ );
88
+ } else {
89
+ config[fieldName] = resolverValue[fieldName];
90
+ }
91
+ }
92
+ return new GraphQLScalarType(config);
93
+ }
94
+ },
95
+ ["MapperKind.ENUM_TYPE" /* ENUM_TYPE */]: (type) => {
96
+ var _a, _b, _c, _d, _e, _f;
97
+ const resolverValue = resolvers[type.name];
98
+ const config = type.toConfig();
99
+ const enumValueConfigMap = config.values;
100
+ if (resolverValue != null) {
101
+ for (const fieldName in resolverValue) {
102
+ if (fieldName.startsWith("__")) {
103
+ config[fieldName.substring(2)] = resolverValue[fieldName];
104
+ } else if (fieldName === "astNode" && config.astNode != null) {
105
+ config.astNode = __spreadProps(__spreadValues({}, config.astNode), {
106
+ description: (_b = (_a = resolverValue == null ? void 0 : resolverValue.astNode) == null ? void 0 : _a.description) != null ? _b : config.astNode.description,
107
+ directives: ((_c = config.astNode.directives) != null ? _c : []).concat(
108
+ (_e = (_d = resolverValue == null ? void 0 : resolverValue.astNode) == null ? void 0 : _d.directives) != null ? _e : []
109
+ )
110
+ });
111
+ } else if (fieldName === "extensionASTNodes" && config.extensionASTNodes != null) {
112
+ config.extensionASTNodes = config.extensionASTNodes.concat(
113
+ (_f = resolverValue == null ? void 0 : resolverValue.extensionASTNodes) != null ? _f : []
114
+ );
115
+ } else if (fieldName === "extensions" && config.extensions != null && resolverValue.extensions != null) {
116
+ config.extensions = Object.assign(
117
+ /* @__PURE__ */ Object.create(null),
118
+ type.extensions,
119
+ resolverValue.extensions
120
+ );
121
+ } else if (enumValueConfigMap[fieldName]) {
122
+ enumValueConfigMap[fieldName].value = resolverValue[fieldName];
123
+ }
124
+ }
125
+ return new GraphQLEnumType(config);
126
+ }
127
+ },
128
+ ["MapperKind.UNION_TYPE" /* UNION_TYPE */]: (type) => {
129
+ const resolverValue = resolvers[type.name];
130
+ if (resolverValue != null) {
131
+ const config = type.toConfig();
132
+ if (resolverValue["__resolveType"]) {
133
+ config.resolveType = resolverValue["__resolveType"];
134
+ }
135
+ return new GraphQLUnionType(config);
136
+ }
137
+ },
138
+ ["MapperKind.OBJECT_TYPE" /* OBJECT_TYPE */]: (type) => {
139
+ const resolverValue = resolvers[type.name];
140
+ if (resolverValue != null) {
141
+ const config = type.toConfig();
142
+ if (resolverValue["__isTypeOf"]) {
143
+ config.isTypeOf = resolverValue["__isTypeOf"];
144
+ }
145
+ return new GraphQLObjectType(config);
146
+ }
147
+ },
148
+ ["MapperKind.INTERFACE_TYPE" /* INTERFACE_TYPE */]: (type) => {
149
+ const resolverValue = resolvers[type.name];
150
+ if (resolverValue != null) {
151
+ const config = type.toConfig();
152
+ if (resolverValue["__resolveType"]) {
153
+ config.resolveType = resolverValue["__resolveType"];
154
+ }
155
+ return new GraphQLInterfaceType(config);
156
+ }
157
+ },
158
+ ["MapperKind.COMPOSITE_FIELD" /* COMPOSITE_FIELD */]: (fieldConfig, fieldName, typeName) => {
159
+ const resolverValue = resolvers[typeName];
160
+ if (resolverValue != null) {
161
+ const fieldResolve = resolverValue[fieldName];
162
+ if (fieldResolve != null) {
163
+ const newFieldConfig = __spreadValues({}, fieldConfig);
164
+ if (typeof fieldResolve === "function") {
165
+ newFieldConfig.resolve = fieldResolve.bind(resolverValue);
166
+ } else {
167
+ setFieldProperties(newFieldConfig, fieldResolve);
168
+ }
169
+ return newFieldConfig;
170
+ }
171
+ }
172
+ }
173
+ });
174
+ function setFieldProperties(field, propertiesObj) {
175
+ for (const propertyName in propertiesObj) {
176
+ field[propertyName] = propertiesObj[propertyName];
177
+ }
178
+ }
179
+ return schema;
180
+ };
181
+ function mapSchema(schema, schemaMapper = {}) {
182
+ const newTypeMap = mapArguments(
183
+ mapFields(
184
+ mapTypes(
185
+ mapDefaultValues(
186
+ mapEnumValues(
187
+ mapTypes(
188
+ mapDefaultValues(
189
+ schema.getTypeMap(),
190
+ schema,
191
+ serializeInputValue
192
+ ),
193
+ schema,
194
+ schemaMapper,
195
+ (type) => isLeafType(type)
196
+ ),
197
+ schema,
198
+ schemaMapper
199
+ ),
200
+ schema,
201
+ parseInputValue
202
+ ),
203
+ schema,
204
+ schemaMapper,
205
+ (type) => !isLeafType(type)
206
+ ),
207
+ schema,
208
+ schemaMapper
209
+ ),
210
+ schema,
211
+ schemaMapper
212
+ );
213
+ const originalDirectives = schema.getDirectives();
214
+ const newDirectives = mapDirectives(originalDirectives, schema, schemaMapper);
215
+ const { typeMap, directives } = rewireTypes(newTypeMap, newDirectives);
216
+ return new GraphQLSchema(__spreadProps(__spreadValues({}, schema.toConfig()), {
217
+ query: getObjectTypeFromTypeMap(
218
+ typeMap,
219
+ getObjectTypeFromTypeMap(newTypeMap, schema.getQueryType())
220
+ ),
221
+ mutation: getObjectTypeFromTypeMap(
222
+ typeMap,
223
+ getObjectTypeFromTypeMap(newTypeMap, schema.getMutationType())
224
+ ),
225
+ subscription: getObjectTypeFromTypeMap(
226
+ typeMap,
227
+ getObjectTypeFromTypeMap(newTypeMap, schema.getSubscriptionType())
228
+ ),
229
+ types: Object.values(typeMap),
230
+ directives
231
+ }));
232
+ }
233
+ function mapTypes(originalTypeMap, schema, schemaMapper, testFn = () => true) {
234
+ const newTypeMap = {};
235
+ for (const typeName in originalTypeMap) {
236
+ if (!typeName.startsWith("__")) {
237
+ const originalType = originalTypeMap[typeName];
238
+ if (originalType == null || !testFn(originalType)) {
239
+ newTypeMap[typeName] = originalType;
240
+ continue;
241
+ }
242
+ const typeMapper = getTypeMapper(schema, schemaMapper, typeName);
243
+ if (typeMapper == null) {
244
+ newTypeMap[typeName] = originalType;
245
+ continue;
246
+ }
247
+ const maybeNewType = typeMapper(originalType, schema);
248
+ if (maybeNewType === void 0) {
249
+ newTypeMap[typeName] = originalType;
250
+ continue;
251
+ }
252
+ newTypeMap[typeName] = maybeNewType;
253
+ }
254
+ }
255
+ return newTypeMap;
256
+ }
257
+ function mapEnumValues(originalTypeMap, schema, schemaMapper) {
258
+ const enumValueMapper = getEnumValueMapper(schemaMapper);
259
+ if (!enumValueMapper) {
260
+ return originalTypeMap;
261
+ }
262
+ return mapTypes(
263
+ originalTypeMap,
264
+ schema,
265
+ {
266
+ ["MapperKind.ENUM_TYPE" /* ENUM_TYPE */]: (type) => {
267
+ const config = type.toConfig();
268
+ const originalEnumValueConfigMap = config.values;
269
+ const newEnumValueConfigMap = {};
270
+ for (const externalValue in originalEnumValueConfigMap) {
271
+ const originalEnumValueConfig = originalEnumValueConfigMap[externalValue];
272
+ const mappedEnumValue = enumValueMapper(
273
+ originalEnumValueConfig,
274
+ type.name,
275
+ schema,
276
+ externalValue
277
+ );
278
+ if (mappedEnumValue === void 0) {
279
+ newEnumValueConfigMap[externalValue] = originalEnumValueConfig;
280
+ } else if (Array.isArray(mappedEnumValue)) {
281
+ const [newExternalValue, newEnumValueConfig] = mappedEnumValue;
282
+ newEnumValueConfigMap[newExternalValue] = newEnumValueConfig === void 0 ? originalEnumValueConfig : newEnumValueConfig;
283
+ } else if (mappedEnumValue !== null) {
284
+ newEnumValueConfigMap[externalValue] = mappedEnumValue;
285
+ }
286
+ }
287
+ return correctASTNodes(
288
+ new GraphQLEnumType(__spreadProps(__spreadValues({}, config), {
289
+ values: newEnumValueConfigMap
290
+ }))
291
+ );
292
+ }
293
+ },
294
+ (type) => isEnumType(type)
295
+ );
296
+ }
297
+ function mapDefaultValues(originalTypeMap, schema, fn) {
298
+ const newTypeMap = mapArguments(originalTypeMap, schema, {
299
+ ["MapperKind.ARGUMENT" /* ARGUMENT */]: (argumentConfig) => {
300
+ if (argumentConfig.defaultValue === void 0) {
301
+ return argumentConfig;
302
+ }
303
+ const maybeNewType = getNewType(originalTypeMap, argumentConfig.type);
304
+ if (maybeNewType != null) {
305
+ return __spreadProps(__spreadValues({}, argumentConfig), {
306
+ defaultValue: fn(maybeNewType, argumentConfig.defaultValue)
307
+ });
308
+ }
309
+ }
310
+ });
311
+ return mapFields(newTypeMap, schema, {
312
+ ["MapperKind.INPUT_OBJECT_FIELD" /* INPUT_OBJECT_FIELD */]: (inputFieldConfig) => {
313
+ if (inputFieldConfig.defaultValue === void 0) {
314
+ return inputFieldConfig;
315
+ }
316
+ const maybeNewType = getNewType(newTypeMap, inputFieldConfig.type);
317
+ if (maybeNewType != null) {
318
+ return __spreadProps(__spreadValues({}, inputFieldConfig), {
319
+ defaultValue: fn(maybeNewType, inputFieldConfig.defaultValue)
320
+ });
321
+ }
322
+ }
323
+ });
324
+ }
325
+ function getNewType(newTypeMap, type) {
326
+ if (isListType(type)) {
327
+ const newType = getNewType(newTypeMap, type.ofType);
328
+ return newType != null ? new GraphQLList(newType) : null;
329
+ } else if (isNonNullType(type)) {
330
+ const newType = getNewType(newTypeMap, type.ofType);
331
+ return newType != null ? new GraphQLNonNull(newType) : null;
332
+ } else if (isNamedType(type)) {
333
+ const newType = newTypeMap[type.name];
334
+ return newType != null ? newType : null;
335
+ }
336
+ return null;
337
+ }
338
+ function mapFields(originalTypeMap, schema, schemaMapper) {
339
+ const newTypeMap = {};
340
+ for (const typeName in originalTypeMap) {
341
+ if (!typeName.startsWith("__")) {
342
+ const originalType = originalTypeMap[typeName];
343
+ if (!isObjectType(originalType) && !isInterfaceType(originalType) && !isInputObjectType(originalType)) {
344
+ newTypeMap[typeName] = originalType;
345
+ continue;
346
+ }
347
+ const fieldMapper = getFieldMapper(schema, schemaMapper, typeName);
348
+ if (fieldMapper == null) {
349
+ newTypeMap[typeName] = originalType;
350
+ continue;
351
+ }
352
+ const config = originalType.toConfig();
353
+ const originalFieldConfigMap = config.fields;
354
+ const newFieldConfigMap = {};
355
+ for (const fieldName in originalFieldConfigMap) {
356
+ const originalFieldConfig = originalFieldConfigMap[fieldName];
357
+ const mappedField = fieldMapper(
358
+ originalFieldConfig,
359
+ fieldName,
360
+ typeName,
361
+ schema
362
+ );
363
+ if (mappedField === void 0) {
364
+ newFieldConfigMap[fieldName] = originalFieldConfig;
365
+ } else if (Array.isArray(mappedField)) {
366
+ const [newFieldName, newFieldConfig] = mappedField;
367
+ if (newFieldConfig.astNode != null) {
368
+ newFieldConfig.astNode = __spreadProps(__spreadValues({}, newFieldConfig.astNode), {
369
+ name: __spreadProps(__spreadValues({}, newFieldConfig.astNode.name), {
370
+ value: newFieldName
371
+ })
372
+ });
373
+ }
374
+ newFieldConfigMap[newFieldName] = newFieldConfig === void 0 ? originalFieldConfig : newFieldConfig;
375
+ } else if (mappedField !== null) {
376
+ newFieldConfigMap[fieldName] = mappedField;
377
+ }
378
+ }
379
+ if (isObjectType(originalType)) {
380
+ newTypeMap[typeName] = correctASTNodes(
381
+ new GraphQLObjectType(__spreadProps(__spreadValues({}, config), {
382
+ fields: newFieldConfigMap
383
+ }))
384
+ );
385
+ } else if (isInterfaceType(originalType)) {
386
+ newTypeMap[typeName] = correctASTNodes(
387
+ new GraphQLInterfaceType(__spreadProps(__spreadValues({}, config), {
388
+ fields: newFieldConfigMap
389
+ }))
390
+ );
391
+ } else {
392
+ newTypeMap[typeName] = correctASTNodes(
393
+ new GraphQLInputObjectType(__spreadProps(__spreadValues({}, config), {
394
+ fields: newFieldConfigMap
395
+ }))
396
+ );
397
+ }
398
+ }
399
+ }
400
+ return newTypeMap;
401
+ }
402
+ function mapArguments(originalTypeMap, schema, schemaMapper) {
403
+ const newTypeMap = {};
404
+ for (const typeName in originalTypeMap) {
405
+ if (!typeName.startsWith("__")) {
406
+ const originalType = originalTypeMap[typeName];
407
+ if (!isObjectType(originalType) && !isInterfaceType(originalType)) {
408
+ newTypeMap[typeName] = originalType;
409
+ continue;
410
+ }
411
+ const argumentMapper = getArgumentMapper(schemaMapper);
412
+ if (argumentMapper == null) {
413
+ newTypeMap[typeName] = originalType;
414
+ continue;
415
+ }
416
+ const config = originalType.toConfig();
417
+ const originalFieldConfigMap = config.fields;
418
+ const newFieldConfigMap = {};
419
+ for (const fieldName in originalFieldConfigMap) {
420
+ const originalFieldConfig = originalFieldConfigMap[fieldName];
421
+ const originalArgumentConfigMap = originalFieldConfig.args;
422
+ if (originalArgumentConfigMap == null) {
423
+ newFieldConfigMap[fieldName] = originalFieldConfig;
424
+ continue;
425
+ }
426
+ const argumentNames = Object.keys(originalArgumentConfigMap);
427
+ if (!argumentNames.length) {
428
+ newFieldConfigMap[fieldName] = originalFieldConfig;
429
+ continue;
430
+ }
431
+ const newArgumentConfigMap = {};
432
+ for (const argumentName of argumentNames) {
433
+ const originalArgumentConfig = originalArgumentConfigMap[argumentName];
434
+ const mappedArgument = argumentMapper(
435
+ originalArgumentConfig,
436
+ fieldName,
437
+ typeName,
438
+ schema
439
+ );
440
+ if (mappedArgument === void 0) {
441
+ newArgumentConfigMap[argumentName] = originalArgumentConfig;
442
+ } else if (Array.isArray(mappedArgument)) {
443
+ const [newArgumentName, newArgumentConfig] = mappedArgument;
444
+ newArgumentConfigMap[newArgumentName] = newArgumentConfig;
445
+ } else if (mappedArgument !== null) {
446
+ newArgumentConfigMap[argumentName] = mappedArgument;
447
+ }
448
+ }
449
+ newFieldConfigMap[fieldName] = __spreadProps(__spreadValues({}, originalFieldConfig), {
450
+ args: newArgumentConfigMap
451
+ });
452
+ }
453
+ if (isObjectType(originalType)) {
454
+ newTypeMap[typeName] = new GraphQLObjectType(__spreadProps(__spreadValues({}, config), {
455
+ fields: newFieldConfigMap
456
+ }));
457
+ } else if (isInterfaceType(originalType)) {
458
+ newTypeMap[typeName] = new GraphQLInterfaceType(__spreadProps(__spreadValues({}, config), {
459
+ fields: newFieldConfigMap
460
+ }));
461
+ } else {
462
+ newTypeMap[typeName] = new GraphQLInputObjectType(__spreadProps(__spreadValues({}, config), {
463
+ fields: newFieldConfigMap
464
+ }));
465
+ }
466
+ }
467
+ }
468
+ return newTypeMap;
469
+ }
470
+ function mapDirectives(originalDirectives, schema, schemaMapper) {
471
+ const directiveMapper = getDirectiveMapper(schemaMapper);
472
+ if (directiveMapper == null) {
473
+ return originalDirectives.slice();
474
+ }
475
+ const newDirectives = [];
476
+ for (const directive of originalDirectives) {
477
+ const mappedDirective = directiveMapper(directive, schema);
478
+ if (mappedDirective === void 0) {
479
+ newDirectives.push(directive);
480
+ } else if (mappedDirective !== null) {
481
+ newDirectives.push(mappedDirective);
482
+ }
483
+ }
484
+ return newDirectives;
485
+ }
486
+ function getTypeSpecifiers(schema, typeName) {
487
+ var _a, _b, _c;
488
+ const type = schema.getType(typeName);
489
+ const specifiers = ["MapperKind.TYPE" /* TYPE */];
490
+ if (isObjectType(type)) {
491
+ specifiers.push("MapperKind.COMPOSITE_TYPE" /* COMPOSITE_TYPE */, "MapperKind.OBJECT_TYPE" /* OBJECT_TYPE */);
492
+ if (typeName === ((_a = schema.getQueryType()) == null ? void 0 : _a.name)) {
493
+ specifiers.push("MapperKind.ROOT_OBJECT" /* ROOT_OBJECT */, "MapperKind.QUERY" /* QUERY */);
494
+ } else if (typeName === ((_b = schema.getMutationType()) == null ? void 0 : _b.name)) {
495
+ specifiers.push("MapperKind.ROOT_OBJECT" /* ROOT_OBJECT */, "MapperKind.MUTATION" /* MUTATION */);
496
+ } else if (typeName === ((_c = schema.getSubscriptionType()) == null ? void 0 : _c.name)) {
497
+ specifiers.push("MapperKind.ROOT_OBJECT" /* ROOT_OBJECT */, "MapperKind.SUBSCRIPTION" /* SUBSCRIPTION */);
498
+ }
499
+ } else if (isInputObjectType(type)) {
500
+ specifiers.push("MapperKind.INPUT_OBJECT_TYPE" /* INPUT_OBJECT_TYPE */);
501
+ } else if (isInterfaceType(type)) {
502
+ specifiers.push(
503
+ "MapperKind.COMPOSITE_TYPE" /* COMPOSITE_TYPE */,
504
+ "MapperKind.ABSTRACT_TYPE" /* ABSTRACT_TYPE */,
505
+ "MapperKind.INTERFACE_TYPE" /* INTERFACE_TYPE */
506
+ );
507
+ } else if (isUnionType(type)) {
508
+ specifiers.push(
509
+ "MapperKind.COMPOSITE_TYPE" /* COMPOSITE_TYPE */,
510
+ "MapperKind.ABSTRACT_TYPE" /* ABSTRACT_TYPE */,
511
+ "MapperKind.UNION_TYPE" /* UNION_TYPE */
512
+ );
513
+ } else if (isEnumType(type)) {
514
+ specifiers.push("MapperKind.ENUM_TYPE" /* ENUM_TYPE */);
515
+ } else if (isScalarType(type)) {
516
+ specifiers.push("MapperKind.SCALAR_TYPE" /* SCALAR_TYPE */);
517
+ }
518
+ return specifiers;
519
+ }
520
+ function getTypeMapper(schema, schemaMapper, typeName) {
521
+ const specifiers = getTypeSpecifiers(schema, typeName);
522
+ let typeMapper;
523
+ const stack = [...specifiers];
524
+ while (!typeMapper && stack.length > 0) {
525
+ const next = stack.pop();
526
+ typeMapper = schemaMapper[next];
527
+ }
528
+ return typeMapper != null ? typeMapper : null;
529
+ }
530
+ function getFieldSpecifiers(schema, typeName) {
531
+ var _a, _b, _c;
532
+ const type = schema.getType(typeName);
533
+ const specifiers = ["MapperKind.FIELD" /* FIELD */];
534
+ if (isObjectType(type)) {
535
+ specifiers.push("MapperKind.COMPOSITE_FIELD" /* COMPOSITE_FIELD */, "MapperKind.OBJECT_FIELD" /* OBJECT_FIELD */);
536
+ if (typeName === ((_a = schema.getQueryType()) == null ? void 0 : _a.name)) {
537
+ specifiers.push("MapperKind.ROOT_FIELD" /* ROOT_FIELD */, "MapperKind.QUERY_ROOT_FIELD" /* QUERY_ROOT_FIELD */);
538
+ } else if (typeName === ((_b = schema.getMutationType()) == null ? void 0 : _b.name)) {
539
+ specifiers.push("MapperKind.ROOT_FIELD" /* ROOT_FIELD */, "MapperKind.MUTATION_ROOT_FIELD" /* MUTATION_ROOT_FIELD */);
540
+ } else if (typeName === ((_c = schema.getSubscriptionType()) == null ? void 0 : _c.name)) {
541
+ specifiers.push(
542
+ "MapperKind.ROOT_FIELD" /* ROOT_FIELD */,
543
+ "MapperKind.SUBSCRIPTION_ROOT_FIELD" /* SUBSCRIPTION_ROOT_FIELD */
544
+ );
545
+ }
546
+ } else if (isInterfaceType(type)) {
547
+ specifiers.push("MapperKind.COMPOSITE_FIELD" /* COMPOSITE_FIELD */, "MapperKind.INTERFACE_FIELD" /* INTERFACE_FIELD */);
548
+ } else if (isInputObjectType(type)) {
549
+ specifiers.push("MapperKind.INPUT_OBJECT_FIELD" /* INPUT_OBJECT_FIELD */);
550
+ }
551
+ return specifiers;
552
+ }
553
+ function getFieldMapper(schema, schemaMapper, typeName) {
554
+ const specifiers = getFieldSpecifiers(schema, typeName);
555
+ let fieldMapper;
556
+ const stack = [...specifiers];
557
+ while (!fieldMapper && stack.length > 0) {
558
+ const next = stack.pop();
559
+ fieldMapper = schemaMapper[next];
560
+ }
561
+ return fieldMapper != null ? fieldMapper : null;
562
+ }
563
+ function getArgumentMapper(schemaMapper) {
564
+ const argumentMapper = schemaMapper["MapperKind.ARGUMENT" /* ARGUMENT */];
565
+ return argumentMapper != null ? argumentMapper : null;
566
+ }
567
+ function getDirectiveMapper(schemaMapper) {
568
+ const directiveMapper = schemaMapper["MapperKind.DIRECTIVE" /* DIRECTIVE */];
569
+ return directiveMapper != null ? directiveMapper : null;
570
+ }
571
+ function getEnumValueMapper(schemaMapper) {
572
+ const enumValueMapper = schemaMapper["MapperKind.ENUM_VALUE" /* ENUM_VALUE */];
573
+ return enumValueMapper != null ? enumValueMapper : null;
574
+ }
575
+ function correctASTNodes(type) {
576
+ if (isObjectType(type)) {
577
+ const config = type.toConfig();
578
+ if (config.astNode != null) {
579
+ const fields = [];
580
+ for (const fieldName in config.fields) {
581
+ const fieldConfig = config.fields[fieldName];
582
+ if (fieldConfig.astNode != null) {
583
+ fields.push(fieldConfig.astNode);
584
+ }
585
+ }
586
+ config.astNode = __spreadProps(__spreadValues({}, config.astNode), {
587
+ kind: Kind.OBJECT_TYPE_DEFINITION,
588
+ fields
589
+ });
590
+ }
591
+ if (config.extensionASTNodes != null) {
592
+ config.extensionASTNodes = config.extensionASTNodes.map((node) => __spreadProps(__spreadValues({}, node), {
593
+ kind: Kind.OBJECT_TYPE_EXTENSION,
594
+ fields: void 0
595
+ }));
596
+ }
597
+ return new GraphQLObjectType(config);
598
+ } else if (isInterfaceType(type)) {
599
+ const config = type.toConfig();
600
+ if (config.astNode != null) {
601
+ const fields = [];
602
+ for (const fieldName in config.fields) {
603
+ const fieldConfig = config.fields[fieldName];
604
+ if (fieldConfig.astNode != null) {
605
+ fields.push(fieldConfig.astNode);
606
+ }
607
+ }
608
+ config.astNode = __spreadProps(__spreadValues({}, config.astNode), {
609
+ kind: Kind.INTERFACE_TYPE_DEFINITION,
610
+ fields
611
+ });
612
+ }
613
+ if (config.extensionASTNodes != null) {
614
+ config.extensionASTNodes = config.extensionASTNodes.map((node) => __spreadProps(__spreadValues({}, node), {
615
+ kind: Kind.INTERFACE_TYPE_EXTENSION,
616
+ fields: void 0
617
+ }));
618
+ }
619
+ return new GraphQLInterfaceType(config);
620
+ } else if (isInputObjectType(type)) {
621
+ const config = type.toConfig();
622
+ if (config.astNode != null) {
623
+ const fields = [];
624
+ for (const fieldName in config.fields) {
625
+ const fieldConfig = config.fields[fieldName];
626
+ if (fieldConfig.astNode != null) {
627
+ fields.push(fieldConfig.astNode);
628
+ }
629
+ }
630
+ config.astNode = __spreadProps(__spreadValues({}, config.astNode), {
631
+ kind: Kind.INPUT_OBJECT_TYPE_DEFINITION,
632
+ fields
633
+ });
634
+ }
635
+ if (config.extensionASTNodes != null) {
636
+ config.extensionASTNodes = config.extensionASTNodes.map((node) => __spreadProps(__spreadValues({}, node), {
637
+ kind: Kind.INPUT_OBJECT_TYPE_EXTENSION,
638
+ fields: void 0
639
+ }));
640
+ }
641
+ return new GraphQLInputObjectType(config);
642
+ } else if (isEnumType(type)) {
643
+ const config = type.toConfig();
644
+ if (config.astNode != null) {
645
+ const values = [];
646
+ for (const enumKey in config.values) {
647
+ const enumValueConfig = config.values[enumKey];
648
+ if (enumValueConfig.astNode != null) {
649
+ values.push(enumValueConfig.astNode);
650
+ }
651
+ }
652
+ config.astNode = __spreadProps(__spreadValues({}, config.astNode), {
653
+ values
654
+ });
655
+ }
656
+ if (config.extensionASTNodes != null) {
657
+ config.extensionASTNodes = config.extensionASTNodes.map((node) => __spreadProps(__spreadValues({}, node), {
658
+ values: void 0
659
+ }));
660
+ }
661
+ return new GraphQLEnumType(config);
662
+ } else {
663
+ return type;
664
+ }
665
+ }
666
+ function getObjectTypeFromTypeMap(typeMap, type) {
667
+ if (type) {
668
+ const maybeObjectType = typeMap[type.name];
669
+ if (isObjectType(maybeObjectType)) {
670
+ return maybeObjectType;
671
+ }
672
+ }
673
+ }
674
+ function rewireTypes(originalTypeMap, directives) {
675
+ const referenceTypeMap = /* @__PURE__ */ Object.create(null);
676
+ for (const typeName in originalTypeMap) {
677
+ referenceTypeMap[typeName] = originalTypeMap[typeName];
678
+ }
679
+ const newTypeMap = /* @__PURE__ */ Object.create(null);
680
+ for (const typeName in referenceTypeMap) {
681
+ const namedType = referenceTypeMap[typeName];
682
+ if (namedType == null || typeName.startsWith("__")) {
683
+ continue;
684
+ }
685
+ const newName = namedType.name;
686
+ if (newName.startsWith("__")) {
687
+ continue;
688
+ }
689
+ if (newTypeMap[newName] != null) {
690
+ console.warn(
691
+ `Duplicate schema type name ${newName} found; keeping the existing one found in the schema`
692
+ );
693
+ continue;
694
+ }
695
+ newTypeMap[newName] = namedType;
696
+ }
697
+ for (const typeName in newTypeMap) {
698
+ newTypeMap[typeName] = rewireNamedType(newTypeMap[typeName]);
699
+ }
700
+ const newDirectives = directives.map(
701
+ (directive) => rewireDirective(directive)
702
+ );
703
+ return {
704
+ typeMap: newTypeMap,
705
+ directives: newDirectives
706
+ };
707
+ function rewireDirective(directive) {
708
+ if (isSpecifiedDirective(directive)) {
709
+ return directive;
710
+ }
711
+ const directiveConfig = directive.toConfig();
712
+ directiveConfig.args = rewireArgs(directiveConfig.args);
713
+ return new GraphQLDirective(directiveConfig);
714
+ }
715
+ function rewireArgs(args) {
716
+ const rewiredArgs = {};
717
+ for (const argName in args) {
718
+ const arg = args[argName];
719
+ const rewiredArgType = rewireType(arg.type);
720
+ if (rewiredArgType != null) {
721
+ arg.type = rewiredArgType;
722
+ rewiredArgs[argName] = arg;
723
+ }
724
+ }
725
+ return rewiredArgs;
726
+ }
727
+ function rewireNamedType(type) {
728
+ if (isObjectType(type)) {
729
+ const config = type.toConfig();
730
+ const newConfig = __spreadProps(__spreadValues({}, config), {
731
+ fields: () => rewireFields(config.fields),
732
+ interfaces: () => rewireNamedTypes(config.interfaces)
733
+ });
734
+ return new GraphQLObjectType(newConfig);
735
+ } else if (isInterfaceType(type)) {
736
+ const config = type.toConfig();
737
+ const newConfig = __spreadProps(__spreadValues({}, config), {
738
+ fields: () => rewireFields(config.fields)
739
+ });
740
+ if ("interfaces" in newConfig) {
741
+ newConfig.interfaces = () => rewireNamedTypes(
742
+ config.interfaces
743
+ );
744
+ }
745
+ return new GraphQLInterfaceType(newConfig);
746
+ } else if (isUnionType(type)) {
747
+ const config = type.toConfig();
748
+ const newConfig = __spreadProps(__spreadValues({}, config), {
749
+ types: () => rewireNamedTypes(config.types)
750
+ });
751
+ return new GraphQLUnionType(newConfig);
752
+ } else if (isInputObjectType(type)) {
753
+ const config = type.toConfig();
754
+ const newConfig = __spreadProps(__spreadValues({}, config), {
755
+ fields: () => rewireInputFields(config.fields)
756
+ });
757
+ return new GraphQLInputObjectType(newConfig);
758
+ } else if (isEnumType(type)) {
759
+ const enumConfig = type.toConfig();
760
+ return new GraphQLEnumType(enumConfig);
761
+ } else if (isScalarType(type)) {
762
+ if (isSpecifiedScalarType(type)) {
763
+ return type;
764
+ }
765
+ const scalarConfig = type.toConfig();
766
+ return new GraphQLScalarType(scalarConfig);
767
+ }
768
+ throw new Error(`Unexpected schema type: ${type}`);
769
+ }
770
+ function rewireFields(fields) {
771
+ const rewiredFields = {};
772
+ for (const fieldName in fields) {
773
+ const field = fields[fieldName];
774
+ const rewiredFieldType = rewireType(field.type);
775
+ if (rewiredFieldType != null && field.args) {
776
+ field.type = rewiredFieldType;
777
+ field.args = rewireArgs(field.args);
778
+ rewiredFields[fieldName] = field;
779
+ }
780
+ }
781
+ return rewiredFields;
782
+ }
783
+ function rewireInputFields(fields) {
784
+ const rewiredFields = {};
785
+ for (const fieldName in fields) {
786
+ const field = fields[fieldName];
787
+ const rewiredFieldType = rewireType(field.type);
788
+ if (rewiredFieldType != null) {
789
+ field.type = rewiredFieldType;
790
+ rewiredFields[fieldName] = field;
791
+ }
792
+ }
793
+ return rewiredFields;
794
+ }
795
+ function rewireNamedTypes(namedTypes) {
796
+ const rewiredTypes = [];
797
+ for (const namedType of namedTypes) {
798
+ const rewiredType = rewireType(namedType);
799
+ if (rewiredType != null) {
800
+ rewiredTypes.push(rewiredType);
801
+ }
802
+ }
803
+ return rewiredTypes;
804
+ }
805
+ function rewireType(type) {
806
+ if (isListType(type)) {
807
+ const rewiredType = rewireType(type.ofType);
808
+ return rewiredType != null ? new GraphQLList(rewiredType) : null;
809
+ } else if (isNonNullType(type)) {
810
+ const rewiredType = rewireType(type.ofType);
811
+ return rewiredType != null ? new GraphQLNonNull(rewiredType) : null;
812
+ } else if (isNamedType(type)) {
813
+ let rewiredType = referenceTypeMap[type.name];
814
+ if (rewiredType === void 0) {
815
+ rewiredType = isNamedStub(type) ? getBuiltInForStub(type) : rewireNamedType(type);
816
+ newTypeMap[rewiredType.name] = referenceTypeMap[type.name] = rewiredType;
817
+ }
818
+ return rewiredType != null ? newTypeMap[rewiredType.name] : null;
819
+ }
820
+ return null;
821
+ }
822
+ }
823
+ function isNamedStub(type) {
824
+ if ("getFields" in type) {
825
+ const fields = type.getFields();
826
+ for (const fieldName in fields) {
827
+ const field = fields[fieldName];
828
+ return field.name === "_fake";
829
+ }
830
+ }
831
+ return false;
832
+ }
833
+ function getBuiltInForStub(type) {
834
+ switch (type.name) {
835
+ case GraphQLInt.name:
836
+ return GraphQLInt;
837
+ case GraphQLFloat.name:
838
+ return GraphQLFloat;
839
+ case GraphQLString.name:
840
+ return GraphQLString;
841
+ case GraphQLBoolean.name:
842
+ return GraphQLBoolean;
843
+ case GraphQLID.name:
844
+ return GraphQLID;
845
+ default:
846
+ return type;
847
+ }
848
+ }
849
+ function transformInputValue(type, value, inputLeafValueTransformer = null, inputObjectValueTransformer = null) {
850
+ if (value == null) {
851
+ return value;
852
+ }
853
+ const nullableType = getNullableType(type);
854
+ if (isLeafType(nullableType)) {
855
+ return inputLeafValueTransformer != null ? inputLeafValueTransformer(nullableType, value) : value;
856
+ } else if (isListType(nullableType)) {
857
+ return asArray(value).map(
858
+ (listMember) => transformInputValue(
859
+ nullableType.ofType,
860
+ listMember,
861
+ inputLeafValueTransformer,
862
+ inputObjectValueTransformer
863
+ )
864
+ );
865
+ } else if (isInputObjectType(nullableType)) {
866
+ const fields = nullableType.getFields();
867
+ const newValue = {};
868
+ for (const key in value) {
869
+ const field = fields[key];
870
+ if (field != null) {
871
+ newValue[key] = transformInputValue(
872
+ field.type,
873
+ value[key],
874
+ inputLeafValueTransformer,
875
+ inputObjectValueTransformer
876
+ );
877
+ }
878
+ }
879
+ return inputObjectValueTransformer != null ? inputObjectValueTransformer(nullableType, newValue) : newValue;
880
+ }
881
+ }
882
+ function serializeInputValue(type, value) {
883
+ return transformInputValue(type, value, (t, v) => {
884
+ try {
885
+ return t.serialize(v);
886
+ } catch (e) {
887
+ return v;
888
+ }
889
+ });
890
+ }
891
+ function parseInputValue(type, value) {
892
+ return transformInputValue(type, value, (t, v) => {
893
+ try {
894
+ return t.parseValue(v);
895
+ } catch (e) {
896
+ return v;
897
+ }
898
+ });
899
+ }
900
+ var asArray = (fns) => Array.isArray(fns) ? fns : fns ? [fns] : [];
901
+ export {
902
+ makeExecutableSchema
903
+ };