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