@depup/graphql-tools__wrap 11.1.12-depup.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -0
- package/changes.json +10 -0
- package/dist/index.cjs +2393 -0
- package/dist/index.d.cts +419 -0
- package/dist/index.d.ts +419 -0
- package/dist/index.js +2356 -0
- package/package.json +73 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2393 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var delegate = require('@graphql-tools/delegate');
|
|
4
|
+
var utils = require('@graphql-tools/utils');
|
|
5
|
+
var graphql = require('graphql');
|
|
6
|
+
var promiseHelpers = require('@whatwg-node/promise-helpers');
|
|
7
|
+
|
|
8
|
+
function generateProxyingResolvers(subschemaConfig) {
|
|
9
|
+
const targetSchema = subschemaConfig.schema;
|
|
10
|
+
const createProxyingResolver = subschemaConfig.createProxyingResolver ?? defaultCreateProxyingResolver;
|
|
11
|
+
const rootTypeMap = utils.getRootTypeMap(targetSchema);
|
|
12
|
+
const resolvers = {};
|
|
13
|
+
for (const [operation, rootType] of rootTypeMap.entries()) {
|
|
14
|
+
const typeName = rootType.name;
|
|
15
|
+
const fields = rootType.getFields();
|
|
16
|
+
resolvers[typeName] = {};
|
|
17
|
+
for (const fieldName in fields) {
|
|
18
|
+
const proxyingResolver = createProxyingResolver({
|
|
19
|
+
subschemaConfig,
|
|
20
|
+
operation,
|
|
21
|
+
fieldName
|
|
22
|
+
});
|
|
23
|
+
const finalResolver = createPossiblyNestedProxyingResolver(
|
|
24
|
+
subschemaConfig,
|
|
25
|
+
proxyingResolver
|
|
26
|
+
);
|
|
27
|
+
if (operation === "subscription") {
|
|
28
|
+
resolvers[typeName][fieldName] = {
|
|
29
|
+
subscribe: finalResolver,
|
|
30
|
+
resolve: identical
|
|
31
|
+
};
|
|
32
|
+
} else {
|
|
33
|
+
resolvers[typeName][fieldName] = {
|
|
34
|
+
resolve: finalResolver
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return resolvers;
|
|
40
|
+
}
|
|
41
|
+
function identical(value) {
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
function createPossiblyNestedProxyingResolver(subschemaConfig, proxyingResolver) {
|
|
45
|
+
return function possiblyNestedProxyingResolver(parent, args, context, info) {
|
|
46
|
+
if (parent != null) {
|
|
47
|
+
const responseKey = utils.getResponseKeyFromInfo(info);
|
|
48
|
+
if (delegate.isExternalObject(parent)) {
|
|
49
|
+
const unpathedErrors = delegate.getUnpathedErrors(parent);
|
|
50
|
+
const subschema = delegate.getSubschema(parent, responseKey);
|
|
51
|
+
if (subschemaConfig === subschema && parent[responseKey] !== void 0) {
|
|
52
|
+
return delegate.resolveExternalValue(
|
|
53
|
+
parent[responseKey],
|
|
54
|
+
unpathedErrors,
|
|
55
|
+
subschema,
|
|
56
|
+
context,
|
|
57
|
+
info
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return proxyingResolver(parent, args, context, info);
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function defaultCreateProxyingResolver({
|
|
66
|
+
subschemaConfig,
|
|
67
|
+
operation
|
|
68
|
+
}) {
|
|
69
|
+
return function proxyingResolver(rootValue, args, context, info) {
|
|
70
|
+
return delegate.delegateToSchema({
|
|
71
|
+
schema: subschemaConfig,
|
|
72
|
+
operation,
|
|
73
|
+
rootValue,
|
|
74
|
+
args,
|
|
75
|
+
context,
|
|
76
|
+
info
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const wrapSchema = utils.memoize1(function wrapSchema2(subschemaConfig) {
|
|
82
|
+
const targetSchema = subschemaConfig.schema;
|
|
83
|
+
const proxyingResolvers = generateProxyingResolvers(subschemaConfig);
|
|
84
|
+
const schema = createWrappingSchema(targetSchema, proxyingResolvers);
|
|
85
|
+
const transformed = delegate.applySchemaTransforms(schema, subschemaConfig);
|
|
86
|
+
return transformed;
|
|
87
|
+
});
|
|
88
|
+
function createWrappingSchema(schema, proxyingResolvers) {
|
|
89
|
+
return utils.mapSchema(schema, {
|
|
90
|
+
[utils.MapperKind.ROOT_FIELD]: (fieldConfig, fieldName, typeName) => {
|
|
91
|
+
return {
|
|
92
|
+
...fieldConfig,
|
|
93
|
+
...proxyingResolvers[typeName]?.[fieldName]
|
|
94
|
+
};
|
|
95
|
+
},
|
|
96
|
+
[utils.MapperKind.OBJECT_FIELD]: (fieldConfig) => {
|
|
97
|
+
return {
|
|
98
|
+
...fieldConfig,
|
|
99
|
+
resolve: delegate.defaultMergedResolver,
|
|
100
|
+
subscribe: void 0
|
|
101
|
+
};
|
|
102
|
+
},
|
|
103
|
+
[utils.MapperKind.OBJECT_TYPE]: (type) => {
|
|
104
|
+
const config = type.toConfig();
|
|
105
|
+
return new graphql.GraphQLObjectType({
|
|
106
|
+
...config,
|
|
107
|
+
isTypeOf: void 0
|
|
108
|
+
});
|
|
109
|
+
},
|
|
110
|
+
[utils.MapperKind.INTERFACE_TYPE]: (type) => {
|
|
111
|
+
const config = type.toConfig();
|
|
112
|
+
return new graphql.GraphQLInterfaceType({
|
|
113
|
+
...config,
|
|
114
|
+
resolveType: void 0
|
|
115
|
+
});
|
|
116
|
+
},
|
|
117
|
+
[utils.MapperKind.UNION_TYPE]: (type) => {
|
|
118
|
+
const config = type.toConfig();
|
|
119
|
+
return new graphql.GraphQLUnionType({
|
|
120
|
+
...config,
|
|
121
|
+
resolveType: void 0
|
|
122
|
+
});
|
|
123
|
+
},
|
|
124
|
+
[utils.MapperKind.ENUM_VALUE]: (valueConfig) => {
|
|
125
|
+
return {
|
|
126
|
+
...valueConfig,
|
|
127
|
+
value: void 0
|
|
128
|
+
};
|
|
129
|
+
},
|
|
130
|
+
[utils.MapperKind.SCALAR_TYPE]: (type) => {
|
|
131
|
+
if (graphql.isSpecifiedScalarType(type)) {
|
|
132
|
+
return type;
|
|
133
|
+
}
|
|
134
|
+
return new graphql.GraphQLScalarType({
|
|
135
|
+
...type.toConfig(),
|
|
136
|
+
serialize: void 0,
|
|
137
|
+
parseValue: void 0,
|
|
138
|
+
parseLiteral: void 0
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
class RenameTypes {
|
|
145
|
+
renamer;
|
|
146
|
+
map;
|
|
147
|
+
reverseMap;
|
|
148
|
+
renameBuiltins;
|
|
149
|
+
renameScalars;
|
|
150
|
+
constructor(renamer, options) {
|
|
151
|
+
this.renamer = renamer;
|
|
152
|
+
this.map = /* @__PURE__ */ Object.create(null);
|
|
153
|
+
this.reverseMap = /* @__PURE__ */ Object.create(null);
|
|
154
|
+
const { renameBuiltins = false, renameScalars = true } = options != null ? options : {};
|
|
155
|
+
this.renameBuiltins = renameBuiltins;
|
|
156
|
+
this.renameScalars = renameScalars;
|
|
157
|
+
}
|
|
158
|
+
transformSchema(originalWrappingSchema, _subschemaConfig) {
|
|
159
|
+
const typeNames = new Set(
|
|
160
|
+
Object.keys(originalWrappingSchema.getTypeMap())
|
|
161
|
+
);
|
|
162
|
+
return utils.mapSchema(originalWrappingSchema, {
|
|
163
|
+
[utils.MapperKind.TYPE]: (type) => {
|
|
164
|
+
if (graphql.isSpecifiedScalarType(type) && !this.renameBuiltins) {
|
|
165
|
+
return void 0;
|
|
166
|
+
}
|
|
167
|
+
if (graphql.isScalarType(type) && !this.renameScalars) {
|
|
168
|
+
return void 0;
|
|
169
|
+
}
|
|
170
|
+
const oldName = type.name;
|
|
171
|
+
const newName = this.renamer(oldName);
|
|
172
|
+
if (newName !== void 0 && newName !== oldName) {
|
|
173
|
+
if (typeNames.has(newName)) {
|
|
174
|
+
console.warn(
|
|
175
|
+
`New type name ${newName} for ${oldName} already exists in the schema. Skip renaming.`
|
|
176
|
+
);
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
this.map[oldName] = newName;
|
|
180
|
+
this.reverseMap[newName] = oldName;
|
|
181
|
+
typeNames.delete(oldName);
|
|
182
|
+
typeNames.add(newName);
|
|
183
|
+
return utils.renameType(type, newName);
|
|
184
|
+
}
|
|
185
|
+
return void 0;
|
|
186
|
+
},
|
|
187
|
+
[utils.MapperKind.ROOT_OBJECT]() {
|
|
188
|
+
return void 0;
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
transformRequest(originalRequest, _delegationContext, _transformationContext) {
|
|
193
|
+
const document = graphql.visit(originalRequest.document, {
|
|
194
|
+
[graphql.Kind.NAMED_TYPE]: (node) => {
|
|
195
|
+
const name = node.name.value;
|
|
196
|
+
if (name in this.reverseMap) {
|
|
197
|
+
return {
|
|
198
|
+
...node,
|
|
199
|
+
name: {
|
|
200
|
+
kind: graphql.Kind.NAME,
|
|
201
|
+
value: this.reverseMap[name]
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
return void 0;
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
return {
|
|
209
|
+
...originalRequest,
|
|
210
|
+
document
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
transformResult(originalResult, _delegationContext, _transformationContext) {
|
|
214
|
+
return {
|
|
215
|
+
...originalResult,
|
|
216
|
+
data: utils.visitData(originalResult.data, (object) => {
|
|
217
|
+
const typeName = object?.__typename;
|
|
218
|
+
if (typeName != null && typeName in this.map) {
|
|
219
|
+
object.__typename = this.map[typeName];
|
|
220
|
+
}
|
|
221
|
+
return object;
|
|
222
|
+
})
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
class FilterTypes {
|
|
228
|
+
filter;
|
|
229
|
+
constructor(filter) {
|
|
230
|
+
this.filter = filter;
|
|
231
|
+
}
|
|
232
|
+
transformSchema(originalWrappingSchema, _subschemaConfig) {
|
|
233
|
+
return utils.mapSchema(originalWrappingSchema, {
|
|
234
|
+
[utils.MapperKind.TYPE]: (type) => {
|
|
235
|
+
if (this.filter(type)) {
|
|
236
|
+
return void 0;
|
|
237
|
+
}
|
|
238
|
+
return null;
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
class RenameRootTypes {
|
|
245
|
+
renamer;
|
|
246
|
+
map;
|
|
247
|
+
reverseMap;
|
|
248
|
+
constructor(renamer) {
|
|
249
|
+
this.renamer = renamer;
|
|
250
|
+
this.map = /* @__PURE__ */ Object.create(null);
|
|
251
|
+
this.reverseMap = /* @__PURE__ */ Object.create(null);
|
|
252
|
+
}
|
|
253
|
+
transformSchema(originalWrappingSchema, _subschemaConfig) {
|
|
254
|
+
return utils.mapSchema(originalWrappingSchema, {
|
|
255
|
+
[utils.MapperKind.ROOT_OBJECT]: (type) => {
|
|
256
|
+
const oldName = type.name;
|
|
257
|
+
const newName = this.renamer(oldName);
|
|
258
|
+
if (newName !== void 0 && newName !== oldName) {
|
|
259
|
+
this.map[oldName] = newName;
|
|
260
|
+
this.reverseMap[newName] = oldName;
|
|
261
|
+
return utils.renameType(type, newName);
|
|
262
|
+
}
|
|
263
|
+
return void 0;
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
transformRequest(originalRequest, _delegationContext, _transformationContext) {
|
|
268
|
+
const document = graphql.visit(originalRequest.document, {
|
|
269
|
+
[graphql.Kind.NAMED_TYPE]: (node) => {
|
|
270
|
+
const name = node.name.value;
|
|
271
|
+
if (name in this.reverseMap) {
|
|
272
|
+
return {
|
|
273
|
+
...node,
|
|
274
|
+
name: {
|
|
275
|
+
kind: graphql.Kind.NAME,
|
|
276
|
+
value: this.reverseMap[name]
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
return void 0;
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
return {
|
|
284
|
+
...originalRequest,
|
|
285
|
+
document
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
transformResult(originalResult, _delegationContext, _transformationContext) {
|
|
289
|
+
return {
|
|
290
|
+
...originalResult,
|
|
291
|
+
data: utils.visitData(originalResult.data, (object) => {
|
|
292
|
+
const typeName = object?.__typename;
|
|
293
|
+
if (typeName != null && typeName in this.map) {
|
|
294
|
+
object.__typename = this.map[typeName];
|
|
295
|
+
}
|
|
296
|
+
return object;
|
|
297
|
+
})
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
class TransformCompositeFields {
|
|
303
|
+
fieldTransformer;
|
|
304
|
+
fieldNodeTransformer;
|
|
305
|
+
dataTransformer;
|
|
306
|
+
errorsTransformer;
|
|
307
|
+
transformedSchema;
|
|
308
|
+
typeInfo;
|
|
309
|
+
mapping;
|
|
310
|
+
subscriptionTypeName;
|
|
311
|
+
constructor(fieldTransformer, fieldNodeTransformer, dataTransformer, errorsTransformer) {
|
|
312
|
+
this.fieldTransformer = fieldTransformer;
|
|
313
|
+
this.fieldNodeTransformer = fieldNodeTransformer;
|
|
314
|
+
this.dataTransformer = dataTransformer;
|
|
315
|
+
this.errorsTransformer = errorsTransformer;
|
|
316
|
+
this.mapping = {};
|
|
317
|
+
}
|
|
318
|
+
_getTypeInfo() {
|
|
319
|
+
const typeInfo = this.typeInfo;
|
|
320
|
+
if (typeInfo === void 0) {
|
|
321
|
+
throw new Error(
|
|
322
|
+
`The TransformCompositeFields transform's "transformRequest" and "transformResult" methods cannot be used without first calling "transformSchema".`
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
return typeInfo;
|
|
326
|
+
}
|
|
327
|
+
transformSchema(originalWrappingSchema, _subschemaConfig) {
|
|
328
|
+
this.transformedSchema = utils.mapSchema(originalWrappingSchema, {
|
|
329
|
+
[utils.MapperKind.COMPOSITE_FIELD]: (fieldConfig, fieldName, typeName) => {
|
|
330
|
+
const transformedField = this.fieldTransformer(
|
|
331
|
+
typeName,
|
|
332
|
+
fieldName,
|
|
333
|
+
fieldConfig
|
|
334
|
+
);
|
|
335
|
+
if (Array.isArray(transformedField)) {
|
|
336
|
+
const newFieldName = transformedField[0];
|
|
337
|
+
if (newFieldName !== fieldName) {
|
|
338
|
+
if (!this.mapping[typeName]) {
|
|
339
|
+
this.mapping[typeName] = {};
|
|
340
|
+
}
|
|
341
|
+
this.mapping[typeName][newFieldName] = fieldName;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
return transformedField;
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
this.typeInfo = delegate.getTypeInfo(this.transformedSchema);
|
|
348
|
+
this.subscriptionTypeName = originalWrappingSchema.getSubscriptionType()?.name;
|
|
349
|
+
return this.transformedSchema;
|
|
350
|
+
}
|
|
351
|
+
transformRequest(originalRequest, _delegationContext, transformationContext) {
|
|
352
|
+
const document = originalRequest.document;
|
|
353
|
+
return {
|
|
354
|
+
...originalRequest,
|
|
355
|
+
document: this.transformDocument(document, transformationContext)
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
transformResult(result, _delegationContext, transformationContext) {
|
|
359
|
+
const dataTransformer = this.dataTransformer;
|
|
360
|
+
if (dataTransformer != null) {
|
|
361
|
+
result.data = utils.visitData(
|
|
362
|
+
result.data,
|
|
363
|
+
(value) => dataTransformer(value, transformationContext)
|
|
364
|
+
);
|
|
365
|
+
}
|
|
366
|
+
if (this.errorsTransformer != null && Array.isArray(result.errors)) {
|
|
367
|
+
result.errors = this.errorsTransformer(
|
|
368
|
+
result.errors,
|
|
369
|
+
transformationContext
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
return result;
|
|
373
|
+
}
|
|
374
|
+
transformDocument(document, transformationContext) {
|
|
375
|
+
const fragments = /* @__PURE__ */ Object.create(null);
|
|
376
|
+
for (const def of document.definitions) {
|
|
377
|
+
if (def.kind === graphql.Kind.FRAGMENT_DEFINITION) {
|
|
378
|
+
fragments[def.name.value] = def;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
return graphql.visit(
|
|
382
|
+
document,
|
|
383
|
+
graphql.visitWithTypeInfo(this._getTypeInfo(), {
|
|
384
|
+
[graphql.Kind.SELECTION_SET]: {
|
|
385
|
+
leave: (node) => this.transformSelectionSet(
|
|
386
|
+
node,
|
|
387
|
+
this._getTypeInfo(),
|
|
388
|
+
fragments,
|
|
389
|
+
transformationContext
|
|
390
|
+
)
|
|
391
|
+
}
|
|
392
|
+
})
|
|
393
|
+
);
|
|
394
|
+
}
|
|
395
|
+
transformSelectionSet(node, typeInfo, fragments, transformationContext) {
|
|
396
|
+
const parentType = typeInfo.getParentType();
|
|
397
|
+
if (parentType == null) {
|
|
398
|
+
return void 0;
|
|
399
|
+
}
|
|
400
|
+
const parentTypeName = parentType.name;
|
|
401
|
+
let newSelections = [];
|
|
402
|
+
let isTypenameSelected = false;
|
|
403
|
+
for (const selection of node.selections) {
|
|
404
|
+
if (selection.kind !== graphql.Kind.FIELD) {
|
|
405
|
+
newSelections.push(selection);
|
|
406
|
+
continue;
|
|
407
|
+
}
|
|
408
|
+
if (selection.name.value === "__typename" && (!selection.alias || selection.alias.value === "__typename")) {
|
|
409
|
+
isTypenameSelected = true;
|
|
410
|
+
}
|
|
411
|
+
const newName = selection.name.value;
|
|
412
|
+
let transformedSelection;
|
|
413
|
+
if (this.fieldNodeTransformer == null) {
|
|
414
|
+
transformedSelection = selection;
|
|
415
|
+
} else {
|
|
416
|
+
transformedSelection = this.fieldNodeTransformer(
|
|
417
|
+
parentTypeName,
|
|
418
|
+
newName,
|
|
419
|
+
selection,
|
|
420
|
+
fragments,
|
|
421
|
+
transformationContext
|
|
422
|
+
);
|
|
423
|
+
transformedSelection = transformedSelection === void 0 ? selection : transformedSelection;
|
|
424
|
+
}
|
|
425
|
+
if (transformedSelection == null) {
|
|
426
|
+
continue;
|
|
427
|
+
} else if (Array.isArray(transformedSelection)) {
|
|
428
|
+
newSelections = newSelections.concat(transformedSelection);
|
|
429
|
+
continue;
|
|
430
|
+
} else if (transformedSelection.kind !== graphql.Kind.FIELD) {
|
|
431
|
+
newSelections.push(transformedSelection);
|
|
432
|
+
continue;
|
|
433
|
+
}
|
|
434
|
+
const typeMapping = this.mapping[parentTypeName];
|
|
435
|
+
if (typeMapping == null) {
|
|
436
|
+
newSelections.push(transformedSelection);
|
|
437
|
+
continue;
|
|
438
|
+
}
|
|
439
|
+
const oldName = this.mapping[parentTypeName][newName];
|
|
440
|
+
if (oldName == null) {
|
|
441
|
+
newSelections.push(transformedSelection);
|
|
442
|
+
continue;
|
|
443
|
+
}
|
|
444
|
+
newSelections.push({
|
|
445
|
+
...transformedSelection,
|
|
446
|
+
name: {
|
|
447
|
+
kind: graphql.Kind.NAME,
|
|
448
|
+
value: oldName
|
|
449
|
+
},
|
|
450
|
+
alias: {
|
|
451
|
+
kind: graphql.Kind.NAME,
|
|
452
|
+
value: transformedSelection.alias?.value ?? newName
|
|
453
|
+
}
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
if (!isTypenameSelected && (this.dataTransformer != null || this.errorsTransformer != null) && (this.subscriptionTypeName == null || parentTypeName !== this.subscriptionTypeName)) {
|
|
457
|
+
newSelections.push({
|
|
458
|
+
kind: graphql.Kind.FIELD,
|
|
459
|
+
name: {
|
|
460
|
+
kind: graphql.Kind.NAME,
|
|
461
|
+
value: "__typename"
|
|
462
|
+
}
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
return {
|
|
466
|
+
...node,
|
|
467
|
+
selections: newSelections
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
class TransformObjectFields {
|
|
473
|
+
objectFieldTransformer;
|
|
474
|
+
fieldNodeTransformer;
|
|
475
|
+
transformer;
|
|
476
|
+
constructor(objectFieldTransformer, fieldNodeTransformer) {
|
|
477
|
+
this.objectFieldTransformer = objectFieldTransformer;
|
|
478
|
+
this.fieldNodeTransformer = fieldNodeTransformer;
|
|
479
|
+
}
|
|
480
|
+
_getTransformer() {
|
|
481
|
+
const transformer = this.transformer;
|
|
482
|
+
if (transformer === void 0) {
|
|
483
|
+
throw new Error(
|
|
484
|
+
`The TransformObjectFields transform's "transformRequest" and "transformResult" methods cannot be used without first calling "transformSchema".`
|
|
485
|
+
);
|
|
486
|
+
}
|
|
487
|
+
return transformer;
|
|
488
|
+
}
|
|
489
|
+
transformSchema(originalWrappingSchema, subschemaConfig) {
|
|
490
|
+
const compositeToObjectFieldTransformer = (typeName, fieldName, fieldConfig) => {
|
|
491
|
+
if (graphql.isObjectType(originalWrappingSchema.getType(typeName))) {
|
|
492
|
+
return this.objectFieldTransformer(typeName, fieldName, fieldConfig);
|
|
493
|
+
}
|
|
494
|
+
return void 0;
|
|
495
|
+
};
|
|
496
|
+
this.transformer = new TransformCompositeFields(
|
|
497
|
+
compositeToObjectFieldTransformer,
|
|
498
|
+
this.fieldNodeTransformer
|
|
499
|
+
);
|
|
500
|
+
return this.transformer.transformSchema(
|
|
501
|
+
originalWrappingSchema,
|
|
502
|
+
subschemaConfig
|
|
503
|
+
);
|
|
504
|
+
}
|
|
505
|
+
transformRequest(originalRequest, delegationContext, transformationContext) {
|
|
506
|
+
return this._getTransformer().transformRequest(
|
|
507
|
+
originalRequest,
|
|
508
|
+
delegationContext,
|
|
509
|
+
transformationContext
|
|
510
|
+
);
|
|
511
|
+
}
|
|
512
|
+
transformResult(originalResult, delegationContext, transformationContext) {
|
|
513
|
+
return this._getTransformer().transformResult(
|
|
514
|
+
originalResult,
|
|
515
|
+
delegationContext,
|
|
516
|
+
transformationContext
|
|
517
|
+
);
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
class TransformRootFields {
|
|
522
|
+
rootFieldTransformer;
|
|
523
|
+
fieldNodeTransformer;
|
|
524
|
+
transformer;
|
|
525
|
+
constructor(rootFieldTransformer, fieldNodeTransformer) {
|
|
526
|
+
this.rootFieldTransformer = rootFieldTransformer;
|
|
527
|
+
this.fieldNodeTransformer = fieldNodeTransformer;
|
|
528
|
+
}
|
|
529
|
+
_getTransformer() {
|
|
530
|
+
const transformer = this.transformer;
|
|
531
|
+
if (transformer === void 0) {
|
|
532
|
+
throw new Error(
|
|
533
|
+
`The TransformRootFields transform's "transformRequest" and "transformResult" methods cannot be used without first calling "transformSchema".`
|
|
534
|
+
);
|
|
535
|
+
}
|
|
536
|
+
return transformer;
|
|
537
|
+
}
|
|
538
|
+
transformSchema(originalWrappingSchema, subschemaConfig) {
|
|
539
|
+
const rootToObjectFieldTransformer = (typeName, fieldName, fieldConfig) => {
|
|
540
|
+
if (typeName === originalWrappingSchema.getQueryType()?.name) {
|
|
541
|
+
return this.rootFieldTransformer("Query", fieldName, fieldConfig);
|
|
542
|
+
}
|
|
543
|
+
if (typeName === originalWrappingSchema.getMutationType()?.name) {
|
|
544
|
+
return this.rootFieldTransformer("Mutation", fieldName, fieldConfig);
|
|
545
|
+
}
|
|
546
|
+
if (typeName === originalWrappingSchema.getSubscriptionType()?.name) {
|
|
547
|
+
return this.rootFieldTransformer(
|
|
548
|
+
"Subscription",
|
|
549
|
+
fieldName,
|
|
550
|
+
fieldConfig
|
|
551
|
+
);
|
|
552
|
+
}
|
|
553
|
+
return void 0;
|
|
554
|
+
};
|
|
555
|
+
this.transformer = new TransformObjectFields(
|
|
556
|
+
rootToObjectFieldTransformer,
|
|
557
|
+
this.fieldNodeTransformer
|
|
558
|
+
);
|
|
559
|
+
return this.transformer.transformSchema(
|
|
560
|
+
originalWrappingSchema,
|
|
561
|
+
subschemaConfig
|
|
562
|
+
);
|
|
563
|
+
}
|
|
564
|
+
transformRequest(originalRequest, delegationContext, transformationContext) {
|
|
565
|
+
return this._getTransformer().transformRequest(
|
|
566
|
+
originalRequest,
|
|
567
|
+
delegationContext,
|
|
568
|
+
transformationContext
|
|
569
|
+
);
|
|
570
|
+
}
|
|
571
|
+
transformResult(originalResult, delegationContext, transformationContext) {
|
|
572
|
+
return this._getTransformer().transformResult(
|
|
573
|
+
originalResult,
|
|
574
|
+
delegationContext,
|
|
575
|
+
transformationContext
|
|
576
|
+
);
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
class RenameRootFields {
|
|
581
|
+
transformer;
|
|
582
|
+
constructor(renamer) {
|
|
583
|
+
this.transformer = new TransformRootFields(
|
|
584
|
+
(operation, fieldName, fieldConfig) => [renamer(operation, fieldName, fieldConfig), fieldConfig]
|
|
585
|
+
);
|
|
586
|
+
}
|
|
587
|
+
transformSchema(originalWrappingSchema, subschemaConfig) {
|
|
588
|
+
return this.transformer.transformSchema(
|
|
589
|
+
originalWrappingSchema,
|
|
590
|
+
subschemaConfig
|
|
591
|
+
);
|
|
592
|
+
}
|
|
593
|
+
transformRequest(originalRequest, delegationContext, transformationContext) {
|
|
594
|
+
return this.transformer.transformRequest(
|
|
595
|
+
originalRequest,
|
|
596
|
+
delegationContext,
|
|
597
|
+
transformationContext
|
|
598
|
+
);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
class FilterRootFields {
|
|
603
|
+
transformer;
|
|
604
|
+
constructor(filter) {
|
|
605
|
+
this.transformer = new TransformRootFields(
|
|
606
|
+
(operation, fieldName, fieldConfig) => {
|
|
607
|
+
if (filter(operation, fieldName, fieldConfig)) {
|
|
608
|
+
return void 0;
|
|
609
|
+
}
|
|
610
|
+
return null;
|
|
611
|
+
}
|
|
612
|
+
);
|
|
613
|
+
}
|
|
614
|
+
transformSchema(originalWrappingSchema, subschemaConfig) {
|
|
615
|
+
return this.transformer.transformSchema(
|
|
616
|
+
originalWrappingSchema,
|
|
617
|
+
subschemaConfig
|
|
618
|
+
);
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
class RenameObjectFields {
|
|
623
|
+
transformer;
|
|
624
|
+
constructor(renamer) {
|
|
625
|
+
this.transformer = new TransformObjectFields(
|
|
626
|
+
(typeName, fieldName, fieldConfig) => [renamer(typeName, fieldName, fieldConfig), fieldConfig]
|
|
627
|
+
);
|
|
628
|
+
}
|
|
629
|
+
transformSchema(originalWrappingSchema, subschemaConfig) {
|
|
630
|
+
return this.transformer.transformSchema(
|
|
631
|
+
originalWrappingSchema,
|
|
632
|
+
subschemaConfig
|
|
633
|
+
);
|
|
634
|
+
}
|
|
635
|
+
transformRequest(originalRequest, delegationContext, transformationContext) {
|
|
636
|
+
return this.transformer.transformRequest(
|
|
637
|
+
originalRequest,
|
|
638
|
+
delegationContext,
|
|
639
|
+
transformationContext
|
|
640
|
+
);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
class RenameObjectFieldArguments {
|
|
645
|
+
renamer;
|
|
646
|
+
transformer;
|
|
647
|
+
reverseMap;
|
|
648
|
+
transformedSchema;
|
|
649
|
+
constructor(renamer) {
|
|
650
|
+
this.renamer = renamer;
|
|
651
|
+
this.transformer = new TransformObjectFields(
|
|
652
|
+
(typeName, fieldName, fieldConfig) => {
|
|
653
|
+
const argsConfig = Object.fromEntries(
|
|
654
|
+
Object.entries(fieldConfig.args || []).map(([argName, conf]) => {
|
|
655
|
+
const newName = renamer(typeName, fieldName, argName);
|
|
656
|
+
if (newName !== void 0 && newName !== argName) {
|
|
657
|
+
if (newName != null) {
|
|
658
|
+
return [newName, conf];
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
return [argName, conf];
|
|
662
|
+
})
|
|
663
|
+
);
|
|
664
|
+
return [fieldName, { ...fieldConfig, args: argsConfig }];
|
|
665
|
+
},
|
|
666
|
+
(typeName, fieldName, inputFieldNode) => {
|
|
667
|
+
if (!(typeName in this.reverseMap)) {
|
|
668
|
+
return inputFieldNode;
|
|
669
|
+
}
|
|
670
|
+
if (!(fieldName in this.reverseMap[typeName])) {
|
|
671
|
+
return inputFieldNode;
|
|
672
|
+
}
|
|
673
|
+
const fieldNameMap = this.reverseMap[typeName][fieldName];
|
|
674
|
+
return {
|
|
675
|
+
...inputFieldNode,
|
|
676
|
+
arguments: (inputFieldNode.arguments || []).map((argNode) => {
|
|
677
|
+
return argNode.name.value in fieldNameMap ? {
|
|
678
|
+
...argNode,
|
|
679
|
+
name: {
|
|
680
|
+
...argNode.name,
|
|
681
|
+
value: fieldNameMap[argNode.name.value]
|
|
682
|
+
}
|
|
683
|
+
} : argNode;
|
|
684
|
+
})
|
|
685
|
+
};
|
|
686
|
+
}
|
|
687
|
+
);
|
|
688
|
+
this.reverseMap = /* @__PURE__ */ Object.create(null);
|
|
689
|
+
}
|
|
690
|
+
transformSchema(originalWrappingSchema, subschemaConfig) {
|
|
691
|
+
utils.mapSchema(originalWrappingSchema, {
|
|
692
|
+
[utils.MapperKind.OBJECT_FIELD]: (fieldConfig, fieldName, typeName) => {
|
|
693
|
+
Object.entries(fieldConfig.args || {}).forEach(([argName]) => {
|
|
694
|
+
const newName = this.renamer(typeName, fieldName, argName);
|
|
695
|
+
if (newName !== void 0 && newName !== fieldName) {
|
|
696
|
+
if (this.reverseMap[typeName] == null) {
|
|
697
|
+
this.reverseMap[typeName] = /* @__PURE__ */ Object.create(null);
|
|
698
|
+
}
|
|
699
|
+
if (this.reverseMap[typeName][fieldName] == null) {
|
|
700
|
+
this.reverseMap[typeName][fieldName] = /* @__PURE__ */ Object.create(null);
|
|
701
|
+
}
|
|
702
|
+
this.reverseMap[typeName][fieldName][newName] = argName;
|
|
703
|
+
}
|
|
704
|
+
});
|
|
705
|
+
return void 0;
|
|
706
|
+
},
|
|
707
|
+
[utils.MapperKind.ROOT_OBJECT]() {
|
|
708
|
+
return void 0;
|
|
709
|
+
}
|
|
710
|
+
});
|
|
711
|
+
this.transformedSchema = this.transformer.transformSchema(
|
|
712
|
+
originalWrappingSchema,
|
|
713
|
+
subschemaConfig
|
|
714
|
+
);
|
|
715
|
+
return this.transformedSchema;
|
|
716
|
+
}
|
|
717
|
+
transformRequest(originalRequest, delegationContext, transformationContext) {
|
|
718
|
+
return this.transformer.transformRequest(
|
|
719
|
+
originalRequest,
|
|
720
|
+
delegationContext,
|
|
721
|
+
transformationContext
|
|
722
|
+
);
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
class FilterObjectFields {
|
|
727
|
+
transformer;
|
|
728
|
+
constructor(filter) {
|
|
729
|
+
this.transformer = new TransformObjectFields(
|
|
730
|
+
(typeName, fieldName, fieldConfig) => filter(typeName, fieldName, fieldConfig) ? void 0 : null
|
|
731
|
+
);
|
|
732
|
+
}
|
|
733
|
+
transformSchema(originalWrappingSchema, subschemaConfig) {
|
|
734
|
+
return this.transformer.transformSchema(
|
|
735
|
+
originalWrappingSchema,
|
|
736
|
+
subschemaConfig
|
|
737
|
+
);
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
class TransformInterfaceFields {
|
|
742
|
+
interfaceFieldTransformer;
|
|
743
|
+
fieldNodeTransformer;
|
|
744
|
+
transformer;
|
|
745
|
+
constructor(interfaceFieldTransformer, fieldNodeTransformer) {
|
|
746
|
+
this.interfaceFieldTransformer = interfaceFieldTransformer;
|
|
747
|
+
this.fieldNodeTransformer = fieldNodeTransformer;
|
|
748
|
+
}
|
|
749
|
+
_getTransformer() {
|
|
750
|
+
const transformer = this.transformer;
|
|
751
|
+
if (transformer === void 0) {
|
|
752
|
+
throw new Error(
|
|
753
|
+
`The TransformInterfaceFields transform's "transformRequest" and "transformResult" methods cannot be used without first calling "transformSchema".`
|
|
754
|
+
);
|
|
755
|
+
}
|
|
756
|
+
return transformer;
|
|
757
|
+
}
|
|
758
|
+
transformSchema(originalWrappingSchema, subschemaConfig) {
|
|
759
|
+
const compositeToObjectFieldTransformer = (typeName, fieldName, fieldConfig) => {
|
|
760
|
+
if (graphql.isInterfaceType(originalWrappingSchema.getType(typeName))) {
|
|
761
|
+
return this.interfaceFieldTransformer(typeName, fieldName, fieldConfig);
|
|
762
|
+
}
|
|
763
|
+
return void 0;
|
|
764
|
+
};
|
|
765
|
+
this.transformer = new TransformCompositeFields(
|
|
766
|
+
compositeToObjectFieldTransformer,
|
|
767
|
+
this.fieldNodeTransformer
|
|
768
|
+
);
|
|
769
|
+
return this.transformer.transformSchema(
|
|
770
|
+
originalWrappingSchema,
|
|
771
|
+
subschemaConfig
|
|
772
|
+
);
|
|
773
|
+
}
|
|
774
|
+
transformRequest(originalRequest, delegationContext, transformationContext) {
|
|
775
|
+
return this._getTransformer().transformRequest(
|
|
776
|
+
originalRequest,
|
|
777
|
+
delegationContext,
|
|
778
|
+
transformationContext
|
|
779
|
+
);
|
|
780
|
+
}
|
|
781
|
+
transformResult(originalResult, delegationContext, transformationContext) {
|
|
782
|
+
return this._getTransformer().transformResult(
|
|
783
|
+
originalResult,
|
|
784
|
+
delegationContext,
|
|
785
|
+
transformationContext
|
|
786
|
+
);
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
class RenameInterfaceFields {
|
|
791
|
+
transformer;
|
|
792
|
+
constructor(renamer) {
|
|
793
|
+
this.transformer = new TransformInterfaceFields(
|
|
794
|
+
(typeName, fieldName, fieldConfig) => [renamer(typeName, fieldName, fieldConfig), fieldConfig]
|
|
795
|
+
);
|
|
796
|
+
}
|
|
797
|
+
transformSchema(originalWrappingSchema, subschemaConfig) {
|
|
798
|
+
return this.transformer.transformSchema(
|
|
799
|
+
originalWrappingSchema,
|
|
800
|
+
subschemaConfig
|
|
801
|
+
);
|
|
802
|
+
}
|
|
803
|
+
transformRequest(originalRequest, delegationContext, transformationContext) {
|
|
804
|
+
return this.transformer.transformRequest(
|
|
805
|
+
originalRequest,
|
|
806
|
+
delegationContext,
|
|
807
|
+
transformationContext
|
|
808
|
+
);
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
class FilterInterfaceFields {
|
|
813
|
+
transformer;
|
|
814
|
+
constructor(filter) {
|
|
815
|
+
this.transformer = new TransformInterfaceFields(
|
|
816
|
+
(typeName, fieldName, fieldConfig) => filter(typeName, fieldName, fieldConfig) ? void 0 : null
|
|
817
|
+
);
|
|
818
|
+
}
|
|
819
|
+
transformSchema(originalWrappingSchema, subschemaConfig) {
|
|
820
|
+
return this.transformer.transformSchema(
|
|
821
|
+
originalWrappingSchema,
|
|
822
|
+
subschemaConfig
|
|
823
|
+
);
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
class TransformInputObjectFields {
|
|
828
|
+
inputFieldTransformer;
|
|
829
|
+
inputFieldNodeTransformer;
|
|
830
|
+
inputObjectNodeTransformer;
|
|
831
|
+
transformedSchema;
|
|
832
|
+
mapping;
|
|
833
|
+
constructor(inputFieldTransformer, inputFieldNodeTransformer, inputObjectNodeTransformer) {
|
|
834
|
+
this.inputFieldTransformer = inputFieldTransformer;
|
|
835
|
+
this.inputFieldNodeTransformer = inputFieldNodeTransformer;
|
|
836
|
+
this.inputObjectNodeTransformer = inputObjectNodeTransformer;
|
|
837
|
+
this.mapping = {};
|
|
838
|
+
}
|
|
839
|
+
_getTransformedSchema() {
|
|
840
|
+
const transformedSchema = this.transformedSchema;
|
|
841
|
+
if (transformedSchema === void 0) {
|
|
842
|
+
throw new Error(
|
|
843
|
+
`The TransformInputObjectFields transform's "transformRequest" and "transformResult" methods cannot be used without first calling "transformSchema".`
|
|
844
|
+
);
|
|
845
|
+
}
|
|
846
|
+
return transformedSchema;
|
|
847
|
+
}
|
|
848
|
+
transformSchema(originalWrappingSchema, _subschemaConfig) {
|
|
849
|
+
this.transformedSchema = utils.mapSchema(originalWrappingSchema, {
|
|
850
|
+
[utils.MapperKind.INPUT_OBJECT_FIELD]: (inputFieldConfig, fieldName, typeName) => {
|
|
851
|
+
const transformedInputField = this.inputFieldTransformer(
|
|
852
|
+
typeName,
|
|
853
|
+
fieldName,
|
|
854
|
+
inputFieldConfig
|
|
855
|
+
);
|
|
856
|
+
if (Array.isArray(transformedInputField)) {
|
|
857
|
+
const newFieldName = transformedInputField[0];
|
|
858
|
+
if (newFieldName !== fieldName) {
|
|
859
|
+
if (!this.mapping[typeName]) {
|
|
860
|
+
this.mapping[typeName] = {};
|
|
861
|
+
}
|
|
862
|
+
this.mapping[typeName][newFieldName] = fieldName;
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
return transformedInputField;
|
|
866
|
+
}
|
|
867
|
+
});
|
|
868
|
+
return this.transformedSchema;
|
|
869
|
+
}
|
|
870
|
+
transformRequest(originalRequest, _delegationContext, _transformationContext) {
|
|
871
|
+
const variableValues = originalRequest.variables ?? {};
|
|
872
|
+
const fragments = /* @__PURE__ */ Object.create(null);
|
|
873
|
+
const operations = [];
|
|
874
|
+
for (const def of originalRequest.document.definitions) {
|
|
875
|
+
if (def.kind === graphql.Kind.OPERATION_DEFINITION) {
|
|
876
|
+
operations.push(def);
|
|
877
|
+
} else if (def.kind === graphql.Kind.FRAGMENT_DEFINITION) {
|
|
878
|
+
fragments[def.name.value] = def;
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
for (const def of operations) {
|
|
882
|
+
const variableDefs = def.variableDefinitions;
|
|
883
|
+
if (variableDefs != null) {
|
|
884
|
+
for (const variableDef of variableDefs) {
|
|
885
|
+
const varName = variableDef.variable.name.value;
|
|
886
|
+
if (!this.transformedSchema) {
|
|
887
|
+
continue;
|
|
888
|
+
}
|
|
889
|
+
const varType = graphql.typeFromAST(
|
|
890
|
+
this.transformedSchema,
|
|
891
|
+
variableDef.type
|
|
892
|
+
);
|
|
893
|
+
if (!graphql.isInputType(varType)) {
|
|
894
|
+
continue;
|
|
895
|
+
}
|
|
896
|
+
variableValues[varName] = utils.transformInputValue(
|
|
897
|
+
varType,
|
|
898
|
+
variableValues[varName],
|
|
899
|
+
void 0,
|
|
900
|
+
(type, originalValue) => {
|
|
901
|
+
const newValue = /* @__PURE__ */ Object.create(null);
|
|
902
|
+
const fields = type.getFields();
|
|
903
|
+
for (const key in originalValue) {
|
|
904
|
+
const field = fields[key];
|
|
905
|
+
if (field != null) {
|
|
906
|
+
const newFieldName = this.mapping[type.name]?.[field.name];
|
|
907
|
+
if (newFieldName != null) {
|
|
908
|
+
newValue[newFieldName] = originalValue[field.name];
|
|
909
|
+
} else {
|
|
910
|
+
newValue[field.name] = originalValue[field.name];
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
return newValue;
|
|
915
|
+
}
|
|
916
|
+
);
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
for (const def of originalRequest.document.definitions.filter(
|
|
921
|
+
(def2) => def2.kind === graphql.Kind.FRAGMENT_DEFINITION
|
|
922
|
+
)) {
|
|
923
|
+
fragments[def.name.value] = def;
|
|
924
|
+
}
|
|
925
|
+
const document = this.transformDocument(
|
|
926
|
+
originalRequest.document,
|
|
927
|
+
this.mapping,
|
|
928
|
+
this.inputFieldNodeTransformer,
|
|
929
|
+
this.inputObjectNodeTransformer,
|
|
930
|
+
originalRequest
|
|
931
|
+
);
|
|
932
|
+
return {
|
|
933
|
+
...originalRequest,
|
|
934
|
+
document,
|
|
935
|
+
variables: variableValues
|
|
936
|
+
};
|
|
937
|
+
}
|
|
938
|
+
transformDocument(document, mapping, inputFieldNodeTransformer, inputObjectNodeTransformer, request) {
|
|
939
|
+
const typeInfo = delegate.getTypeInfo(this._getTransformedSchema());
|
|
940
|
+
const newDocument = graphql.visit(
|
|
941
|
+
document,
|
|
942
|
+
graphql.visitWithTypeInfo(typeInfo, {
|
|
943
|
+
[graphql.Kind.OBJECT]: {
|
|
944
|
+
leave: (node) => {
|
|
945
|
+
const parentType = typeInfo.getInputType();
|
|
946
|
+
if (parentType != null) {
|
|
947
|
+
const parentTypeName = graphql.getNamedType(parentType).name;
|
|
948
|
+
const newInputFields = [];
|
|
949
|
+
for (const inputField of node.fields) {
|
|
950
|
+
const newName = inputField.name.value;
|
|
951
|
+
const transformedInputField = inputFieldNodeTransformer != null ? inputFieldNodeTransformer(
|
|
952
|
+
parentTypeName,
|
|
953
|
+
newName,
|
|
954
|
+
inputField,
|
|
955
|
+
request
|
|
956
|
+
) : inputField;
|
|
957
|
+
if (Array.isArray(transformedInputField)) {
|
|
958
|
+
for (const individualTransformedInputField of transformedInputField) {
|
|
959
|
+
const typeMapping2 = mapping[parentTypeName];
|
|
960
|
+
if (typeMapping2 == null) {
|
|
961
|
+
newInputFields.push(individualTransformedInputField);
|
|
962
|
+
continue;
|
|
963
|
+
}
|
|
964
|
+
const oldName2 = typeMapping2[newName];
|
|
965
|
+
if (oldName2 == null) {
|
|
966
|
+
newInputFields.push(individualTransformedInputField);
|
|
967
|
+
continue;
|
|
968
|
+
}
|
|
969
|
+
newInputFields.push({
|
|
970
|
+
...individualTransformedInputField,
|
|
971
|
+
name: {
|
|
972
|
+
...individualTransformedInputField.name,
|
|
973
|
+
value: oldName2
|
|
974
|
+
}
|
|
975
|
+
});
|
|
976
|
+
}
|
|
977
|
+
continue;
|
|
978
|
+
}
|
|
979
|
+
const typeMapping = mapping[parentTypeName];
|
|
980
|
+
if (typeMapping == null) {
|
|
981
|
+
newInputFields.push(transformedInputField);
|
|
982
|
+
continue;
|
|
983
|
+
}
|
|
984
|
+
const oldName = typeMapping[newName];
|
|
985
|
+
if (oldName == null) {
|
|
986
|
+
newInputFields.push(transformedInputField);
|
|
987
|
+
continue;
|
|
988
|
+
}
|
|
989
|
+
newInputFields.push({
|
|
990
|
+
...transformedInputField,
|
|
991
|
+
name: {
|
|
992
|
+
...transformedInputField.name,
|
|
993
|
+
value: oldName
|
|
994
|
+
}
|
|
995
|
+
});
|
|
996
|
+
}
|
|
997
|
+
const newNode = {
|
|
998
|
+
...node,
|
|
999
|
+
fields: newInputFields
|
|
1000
|
+
};
|
|
1001
|
+
return inputObjectNodeTransformer != null ? inputObjectNodeTransformer(parentTypeName, newNode, request) : newNode;
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
})
|
|
1006
|
+
);
|
|
1007
|
+
return newDocument;
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
class RenameInputObjectFields {
|
|
1012
|
+
renamer;
|
|
1013
|
+
transformer;
|
|
1014
|
+
reverseMap;
|
|
1015
|
+
constructor(renamer) {
|
|
1016
|
+
this.renamer = renamer;
|
|
1017
|
+
this.transformer = new TransformInputObjectFields(
|
|
1018
|
+
(typeName, inputFieldName, inputFieldConfig) => {
|
|
1019
|
+
const newName = renamer(typeName, inputFieldName, inputFieldConfig);
|
|
1020
|
+
if (newName !== void 0 && newName !== inputFieldName) {
|
|
1021
|
+
const value = renamer(typeName, inputFieldName, inputFieldConfig);
|
|
1022
|
+
if (value != null) {
|
|
1023
|
+
return [value, inputFieldConfig];
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
return void 0;
|
|
1027
|
+
},
|
|
1028
|
+
(typeName, inputFieldName, inputFieldNode) => {
|
|
1029
|
+
if (!(typeName in this.reverseMap)) {
|
|
1030
|
+
return inputFieldNode;
|
|
1031
|
+
}
|
|
1032
|
+
const inputFieldNameMap = this.reverseMap[typeName];
|
|
1033
|
+
if (!(inputFieldName in inputFieldNameMap)) {
|
|
1034
|
+
return inputFieldNode;
|
|
1035
|
+
}
|
|
1036
|
+
return {
|
|
1037
|
+
...inputFieldNode,
|
|
1038
|
+
name: {
|
|
1039
|
+
...inputFieldNode.name,
|
|
1040
|
+
value: inputFieldNameMap[inputFieldName]
|
|
1041
|
+
}
|
|
1042
|
+
};
|
|
1043
|
+
}
|
|
1044
|
+
);
|
|
1045
|
+
this.reverseMap = /* @__PURE__ */ Object.create(null);
|
|
1046
|
+
}
|
|
1047
|
+
transformSchema(originalWrappingSchema, subschemaConfig) {
|
|
1048
|
+
utils.mapSchema(originalWrappingSchema, {
|
|
1049
|
+
[utils.MapperKind.INPUT_OBJECT_FIELD]: (inputFieldConfig, fieldName, typeName) => {
|
|
1050
|
+
const newName = this.renamer(typeName, fieldName, inputFieldConfig);
|
|
1051
|
+
if (newName !== void 0 && newName !== fieldName) {
|
|
1052
|
+
if (this.reverseMap[typeName] == null) {
|
|
1053
|
+
this.reverseMap[typeName] = /* @__PURE__ */ Object.create(null);
|
|
1054
|
+
}
|
|
1055
|
+
this.reverseMap[typeName][newName] = fieldName;
|
|
1056
|
+
}
|
|
1057
|
+
return void 0;
|
|
1058
|
+
},
|
|
1059
|
+
[utils.MapperKind.ROOT_OBJECT]() {
|
|
1060
|
+
return void 0;
|
|
1061
|
+
}
|
|
1062
|
+
});
|
|
1063
|
+
return this.transformer.transformSchema(
|
|
1064
|
+
originalWrappingSchema,
|
|
1065
|
+
subschemaConfig
|
|
1066
|
+
);
|
|
1067
|
+
}
|
|
1068
|
+
transformRequest(originalRequest, delegationContext, transformationContext) {
|
|
1069
|
+
return this.transformer.transformRequest(
|
|
1070
|
+
originalRequest,
|
|
1071
|
+
delegationContext,
|
|
1072
|
+
transformationContext
|
|
1073
|
+
);
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
class FilterInputObjectFields {
|
|
1078
|
+
transformer;
|
|
1079
|
+
constructor(filter, inputObjectNodeTransformer) {
|
|
1080
|
+
this.transformer = new TransformInputObjectFields(
|
|
1081
|
+
(typeName, fieldName, inputFieldConfig) => filter(typeName, fieldName, inputFieldConfig) ? void 0 : null,
|
|
1082
|
+
void 0,
|
|
1083
|
+
inputObjectNodeTransformer
|
|
1084
|
+
);
|
|
1085
|
+
}
|
|
1086
|
+
transformSchema(originalWrappingSchema, subschemaConfig) {
|
|
1087
|
+
return this.transformer.transformSchema(
|
|
1088
|
+
originalWrappingSchema,
|
|
1089
|
+
subschemaConfig
|
|
1090
|
+
);
|
|
1091
|
+
}
|
|
1092
|
+
transformRequest(originalRequest, delegationContext, transformationContext) {
|
|
1093
|
+
return this.transformer.transformRequest(
|
|
1094
|
+
originalRequest,
|
|
1095
|
+
delegationContext,
|
|
1096
|
+
transformationContext
|
|
1097
|
+
);
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
class MapLeafValues {
|
|
1102
|
+
inputValueTransformer;
|
|
1103
|
+
outputValueTransformer;
|
|
1104
|
+
resultVisitorMap;
|
|
1105
|
+
typeInfo;
|
|
1106
|
+
constructor(inputValueTransformer, outputValueTransformer) {
|
|
1107
|
+
this.inputValueTransformer = inputValueTransformer;
|
|
1108
|
+
this.outputValueTransformer = outputValueTransformer;
|
|
1109
|
+
this.resultVisitorMap = /* @__PURE__ */ Object.create(null);
|
|
1110
|
+
}
|
|
1111
|
+
originalWrappingSchema;
|
|
1112
|
+
transformSchema(originalWrappingSchema, _subschemaConfig) {
|
|
1113
|
+
this.originalWrappingSchema = originalWrappingSchema;
|
|
1114
|
+
const typeMap = originalWrappingSchema.getTypeMap();
|
|
1115
|
+
for (const typeName in typeMap) {
|
|
1116
|
+
const type = typeMap[typeName];
|
|
1117
|
+
if (!typeName.startsWith("__")) {
|
|
1118
|
+
if (graphql.isLeafType(type)) {
|
|
1119
|
+
this.resultVisitorMap[typeName] = (value) => this.outputValueTransformer(typeName, value);
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
this.typeInfo = delegate.getTypeInfo(originalWrappingSchema);
|
|
1124
|
+
return originalWrappingSchema;
|
|
1125
|
+
}
|
|
1126
|
+
transformRequest(originalRequest, _delegationContext, transformationContext) {
|
|
1127
|
+
const document = originalRequest.document;
|
|
1128
|
+
const variableValues = originalRequest.variables ?? {};
|
|
1129
|
+
const operations = document.definitions.filter(
|
|
1130
|
+
(def) => def.kind === graphql.Kind.OPERATION_DEFINITION
|
|
1131
|
+
);
|
|
1132
|
+
const fragments = document.definitions.filter(
|
|
1133
|
+
(def) => def.kind === graphql.Kind.FRAGMENT_DEFINITION
|
|
1134
|
+
);
|
|
1135
|
+
const newOperations = this.transformOperations(operations, variableValues);
|
|
1136
|
+
const transformedRequest = {
|
|
1137
|
+
...originalRequest,
|
|
1138
|
+
document: {
|
|
1139
|
+
...document,
|
|
1140
|
+
definitions: [...newOperations, ...fragments]
|
|
1141
|
+
},
|
|
1142
|
+
variables: variableValues
|
|
1143
|
+
};
|
|
1144
|
+
transformationContext.transformedRequest = transformedRequest;
|
|
1145
|
+
return transformedRequest;
|
|
1146
|
+
}
|
|
1147
|
+
transformResult(originalResult, _delegationContext, transformationContext) {
|
|
1148
|
+
if (!this.originalWrappingSchema) {
|
|
1149
|
+
throw new Error(
|
|
1150
|
+
`The MapLeafValues transform's "transformRequest" and "transformResult" methods cannot be used without first calling "transformSchema".`
|
|
1151
|
+
);
|
|
1152
|
+
}
|
|
1153
|
+
return utils.visitResult(
|
|
1154
|
+
originalResult,
|
|
1155
|
+
transformationContext.transformedRequest,
|
|
1156
|
+
this.originalWrappingSchema,
|
|
1157
|
+
this.resultVisitorMap
|
|
1158
|
+
);
|
|
1159
|
+
}
|
|
1160
|
+
transformOperations(operations, variableValues) {
|
|
1161
|
+
if (this.typeInfo == null) {
|
|
1162
|
+
throw new Error(
|
|
1163
|
+
`The MapLeafValues transform's "transformRequest" and "transformResult" methods cannot be used without first calling "transformSchema".`
|
|
1164
|
+
);
|
|
1165
|
+
}
|
|
1166
|
+
return operations.map((operation) => {
|
|
1167
|
+
return graphql.visit(
|
|
1168
|
+
operation,
|
|
1169
|
+
graphql.visitWithTypeInfo(this.typeInfo, {
|
|
1170
|
+
[graphql.Kind.FIELD]: (node) => this.transformFieldNode(node, variableValues)
|
|
1171
|
+
})
|
|
1172
|
+
);
|
|
1173
|
+
});
|
|
1174
|
+
}
|
|
1175
|
+
transformFieldNode(field, variableValues) {
|
|
1176
|
+
if (this.typeInfo == null) {
|
|
1177
|
+
throw new Error(
|
|
1178
|
+
`The MapLeafValues transform's "transformRequest" and "transformResult" methods cannot be used without first calling "transformSchema".`
|
|
1179
|
+
);
|
|
1180
|
+
}
|
|
1181
|
+
const targetField = this.typeInfo.getFieldDef();
|
|
1182
|
+
if (!targetField) {
|
|
1183
|
+
return;
|
|
1184
|
+
}
|
|
1185
|
+
if (!targetField.name.startsWith("__")) {
|
|
1186
|
+
const argumentNodes = field.arguments;
|
|
1187
|
+
if (argumentNodes != null) {
|
|
1188
|
+
const argumentNodeMap = argumentNodes.reduce(
|
|
1189
|
+
(prev, argument) => ({
|
|
1190
|
+
...prev,
|
|
1191
|
+
[argument.name.value]: argument
|
|
1192
|
+
}),
|
|
1193
|
+
/* @__PURE__ */ Object.create(null)
|
|
1194
|
+
);
|
|
1195
|
+
for (const argument of targetField.args) {
|
|
1196
|
+
const argName = argument.name;
|
|
1197
|
+
const argType = argument.type;
|
|
1198
|
+
const argumentNode = argumentNodeMap[argName];
|
|
1199
|
+
let value;
|
|
1200
|
+
const argValue = argumentNode?.value;
|
|
1201
|
+
if (argValue != null) {
|
|
1202
|
+
value = graphql.valueFromAST(argValue, argType, variableValues);
|
|
1203
|
+
if (value == null) {
|
|
1204
|
+
value = graphql.valueFromASTUntyped(argValue, variableValues);
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
const transformedValue = utils.transformInputValue(
|
|
1208
|
+
argType,
|
|
1209
|
+
value,
|
|
1210
|
+
(t, v) => {
|
|
1211
|
+
const newValue = this.inputValueTransformer(t.name, v);
|
|
1212
|
+
return newValue === void 0 ? v : newValue;
|
|
1213
|
+
}
|
|
1214
|
+
);
|
|
1215
|
+
if (argValue?.kind === graphql.Kind.VARIABLE) {
|
|
1216
|
+
variableValues[argValue.name.value] = transformedValue;
|
|
1217
|
+
} else {
|
|
1218
|
+
let newValueNode;
|
|
1219
|
+
try {
|
|
1220
|
+
newValueNode = graphql.astFromValue(transformedValue, argType);
|
|
1221
|
+
} catch (e) {
|
|
1222
|
+
newValueNode = utils.astFromValueUntyped(transformedValue);
|
|
1223
|
+
}
|
|
1224
|
+
if (newValueNode != null) {
|
|
1225
|
+
argumentNodeMap[argName] = {
|
|
1226
|
+
...argumentNode,
|
|
1227
|
+
value: newValueNode
|
|
1228
|
+
};
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
return {
|
|
1233
|
+
...field,
|
|
1234
|
+
arguments: Object.values(argumentNodeMap)
|
|
1235
|
+
};
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
return void 0;
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
class TransformEnumValues {
|
|
1243
|
+
enumValueTransformer;
|
|
1244
|
+
transformer;
|
|
1245
|
+
transformedSchema;
|
|
1246
|
+
mapping;
|
|
1247
|
+
reverseMapping;
|
|
1248
|
+
noTransformation = true;
|
|
1249
|
+
constructor(enumValueTransformer, inputValueTransformer, outputValueTransformer) {
|
|
1250
|
+
this.enumValueTransformer = enumValueTransformer;
|
|
1251
|
+
this.mapping = /* @__PURE__ */ Object.create(null);
|
|
1252
|
+
this.reverseMapping = /* @__PURE__ */ Object.create(null);
|
|
1253
|
+
this.transformer = new MapLeafValues(
|
|
1254
|
+
generateValueTransformer(inputValueTransformer, this.reverseMapping),
|
|
1255
|
+
generateValueTransformer(outputValueTransformer, this.mapping)
|
|
1256
|
+
);
|
|
1257
|
+
}
|
|
1258
|
+
transformSchema(originalWrappingSchema, subschemaConfig) {
|
|
1259
|
+
const mappingSchema = this.transformer.transformSchema(
|
|
1260
|
+
originalWrappingSchema,
|
|
1261
|
+
subschemaConfig
|
|
1262
|
+
);
|
|
1263
|
+
this.transformedSchema = utils.mapSchema(mappingSchema, {
|
|
1264
|
+
[utils.MapperKind.ENUM_VALUE]: (valueConfig, typeName, _schema, externalValue) => this.transformEnumValue(typeName, externalValue, valueConfig),
|
|
1265
|
+
[utils.MapperKind.ARGUMENT]: (argConfig) => {
|
|
1266
|
+
if (argConfig.defaultValue != null) {
|
|
1267
|
+
const newValue = utils.transformInputValue(
|
|
1268
|
+
argConfig.type,
|
|
1269
|
+
argConfig.defaultValue,
|
|
1270
|
+
(type, value) => {
|
|
1271
|
+
return this.mapping[type.name]?.[value] ?? value;
|
|
1272
|
+
}
|
|
1273
|
+
);
|
|
1274
|
+
return {
|
|
1275
|
+
...argConfig,
|
|
1276
|
+
defaultValue: newValue
|
|
1277
|
+
};
|
|
1278
|
+
}
|
|
1279
|
+
return void 0;
|
|
1280
|
+
}
|
|
1281
|
+
});
|
|
1282
|
+
return this.transformedSchema;
|
|
1283
|
+
}
|
|
1284
|
+
transformRequest(originalRequest, delegationContext, transformationContext) {
|
|
1285
|
+
if (this.noTransformation) {
|
|
1286
|
+
return originalRequest;
|
|
1287
|
+
}
|
|
1288
|
+
return this.transformer.transformRequest(
|
|
1289
|
+
originalRequest,
|
|
1290
|
+
delegationContext,
|
|
1291
|
+
transformationContext
|
|
1292
|
+
);
|
|
1293
|
+
}
|
|
1294
|
+
transformResult(originalResult, delegationContext, transformationContext) {
|
|
1295
|
+
if (this.noTransformation) {
|
|
1296
|
+
return originalResult;
|
|
1297
|
+
}
|
|
1298
|
+
return this.transformer.transformResult(
|
|
1299
|
+
originalResult,
|
|
1300
|
+
delegationContext,
|
|
1301
|
+
transformationContext
|
|
1302
|
+
);
|
|
1303
|
+
}
|
|
1304
|
+
transformEnumValue(typeName, externalValue, enumValueConfig) {
|
|
1305
|
+
const transformedEnumValue = this.enumValueTransformer(
|
|
1306
|
+
typeName,
|
|
1307
|
+
externalValue,
|
|
1308
|
+
enumValueConfig
|
|
1309
|
+
);
|
|
1310
|
+
if (Array.isArray(transformedEnumValue)) {
|
|
1311
|
+
const newExternalValue = transformedEnumValue[0];
|
|
1312
|
+
if (newExternalValue !== externalValue) {
|
|
1313
|
+
if (!this.mapping[typeName]) {
|
|
1314
|
+
this.mapping[typeName] = /* @__PURE__ */ Object.create(null);
|
|
1315
|
+
this.reverseMapping[typeName] = /* @__PURE__ */ Object.create(null);
|
|
1316
|
+
}
|
|
1317
|
+
this.mapping[typeName][externalValue] = newExternalValue;
|
|
1318
|
+
this.reverseMapping[typeName][newExternalValue] = externalValue;
|
|
1319
|
+
this.noTransformation = false;
|
|
1320
|
+
}
|
|
1321
|
+
return [
|
|
1322
|
+
newExternalValue,
|
|
1323
|
+
{
|
|
1324
|
+
...transformedEnumValue[1],
|
|
1325
|
+
value: void 0
|
|
1326
|
+
}
|
|
1327
|
+
];
|
|
1328
|
+
}
|
|
1329
|
+
return {
|
|
1330
|
+
...transformedEnumValue,
|
|
1331
|
+
value: void 0
|
|
1332
|
+
};
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
function mapEnumValues(typeName, value, mapping) {
|
|
1336
|
+
const newExternalValue = mapping[typeName]?.[value];
|
|
1337
|
+
return newExternalValue != null ? newExternalValue : value;
|
|
1338
|
+
}
|
|
1339
|
+
function generateValueTransformer(valueTransformer, mapping) {
|
|
1340
|
+
if (valueTransformer == null) {
|
|
1341
|
+
return (typeName, value) => mapEnumValues(typeName, value, mapping);
|
|
1342
|
+
} else {
|
|
1343
|
+
return (typeName, value) => mapEnumValues(typeName, valueTransformer(typeName, value), mapping);
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
class TransformQuery {
|
|
1348
|
+
path;
|
|
1349
|
+
queryTransformer;
|
|
1350
|
+
resultTransformer;
|
|
1351
|
+
errorPathTransformer;
|
|
1352
|
+
fragments;
|
|
1353
|
+
constructor({
|
|
1354
|
+
path,
|
|
1355
|
+
queryTransformer,
|
|
1356
|
+
resultTransformer = (result) => result,
|
|
1357
|
+
errorPathTransformer = (errorPath) => [...errorPath],
|
|
1358
|
+
fragments = {}
|
|
1359
|
+
}) {
|
|
1360
|
+
this.path = path;
|
|
1361
|
+
const pollutingKeys = this.path.filter(delegate.isPrototypePollutingKey);
|
|
1362
|
+
if (pollutingKeys.length > 0) {
|
|
1363
|
+
throw new TypeError(
|
|
1364
|
+
`Invalid path - cannot be a prototype polluting keys: ${pollutingKeys.join(".")}`
|
|
1365
|
+
);
|
|
1366
|
+
}
|
|
1367
|
+
this.queryTransformer = queryTransformer;
|
|
1368
|
+
this.resultTransformer = resultTransformer;
|
|
1369
|
+
this.errorPathTransformer = errorPathTransformer;
|
|
1370
|
+
this.fragments = fragments;
|
|
1371
|
+
}
|
|
1372
|
+
transformRequest(originalRequest, delegationContext, transformationContext) {
|
|
1373
|
+
const pathLength = this.path.length;
|
|
1374
|
+
let index = 0;
|
|
1375
|
+
const operationAst = utils.getOperationASTFromRequest(originalRequest);
|
|
1376
|
+
const document = {
|
|
1377
|
+
kind: graphql.Kind.DOCUMENT,
|
|
1378
|
+
definitions: originalRequest.document.definitions.map((def) => {
|
|
1379
|
+
if (def === operationAst) {
|
|
1380
|
+
return graphql.visit(def, {
|
|
1381
|
+
[graphql.Kind.FIELD]: {
|
|
1382
|
+
enter: (node) => {
|
|
1383
|
+
if (index === pathLength || node.name.value !== this.path[index]) {
|
|
1384
|
+
return false;
|
|
1385
|
+
}
|
|
1386
|
+
index++;
|
|
1387
|
+
if (index === pathLength) {
|
|
1388
|
+
const selectionSet = this.queryTransformer(
|
|
1389
|
+
node.selectionSet,
|
|
1390
|
+
this.fragments,
|
|
1391
|
+
delegationContext,
|
|
1392
|
+
transformationContext
|
|
1393
|
+
);
|
|
1394
|
+
return {
|
|
1395
|
+
...node,
|
|
1396
|
+
selectionSet
|
|
1397
|
+
};
|
|
1398
|
+
}
|
|
1399
|
+
return void 0;
|
|
1400
|
+
},
|
|
1401
|
+
leave: () => {
|
|
1402
|
+
index--;
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
});
|
|
1406
|
+
}
|
|
1407
|
+
return def;
|
|
1408
|
+
})
|
|
1409
|
+
};
|
|
1410
|
+
return {
|
|
1411
|
+
...originalRequest,
|
|
1412
|
+
document
|
|
1413
|
+
};
|
|
1414
|
+
}
|
|
1415
|
+
transformResult(originalResult, delegationContext, transformationContext) {
|
|
1416
|
+
const data = this.transformData(
|
|
1417
|
+
originalResult.data,
|
|
1418
|
+
delegationContext,
|
|
1419
|
+
transformationContext
|
|
1420
|
+
);
|
|
1421
|
+
const errors = originalResult.errors;
|
|
1422
|
+
return {
|
|
1423
|
+
data,
|
|
1424
|
+
errors: errors != null ? this.transformErrors(errors) : void 0
|
|
1425
|
+
};
|
|
1426
|
+
}
|
|
1427
|
+
transformData(data, delegationContext, transformationContext) {
|
|
1428
|
+
const leafIndex = this.path.length - 1;
|
|
1429
|
+
let index = 0;
|
|
1430
|
+
let newData = data;
|
|
1431
|
+
if (newData) {
|
|
1432
|
+
let next = this.path[index];
|
|
1433
|
+
while (index < leafIndex) {
|
|
1434
|
+
if (data[next]) {
|
|
1435
|
+
newData = newData[next];
|
|
1436
|
+
} else {
|
|
1437
|
+
break;
|
|
1438
|
+
}
|
|
1439
|
+
index++;
|
|
1440
|
+
next = this.path[index];
|
|
1441
|
+
}
|
|
1442
|
+
newData[next] = this.resultTransformer(
|
|
1443
|
+
newData[next],
|
|
1444
|
+
delegationContext,
|
|
1445
|
+
transformationContext
|
|
1446
|
+
);
|
|
1447
|
+
}
|
|
1448
|
+
return data;
|
|
1449
|
+
}
|
|
1450
|
+
transformErrors(errors) {
|
|
1451
|
+
return errors.map((error) => {
|
|
1452
|
+
const path = error.path;
|
|
1453
|
+
if (path == null) {
|
|
1454
|
+
return error;
|
|
1455
|
+
}
|
|
1456
|
+
let match = true;
|
|
1457
|
+
let index = 0;
|
|
1458
|
+
while (index < this.path.length) {
|
|
1459
|
+
if (path[index] !== this.path[index]) {
|
|
1460
|
+
match = false;
|
|
1461
|
+
break;
|
|
1462
|
+
}
|
|
1463
|
+
index++;
|
|
1464
|
+
}
|
|
1465
|
+
const newPath = match ? path.slice(0, index).concat(this.errorPathTransformer(path.slice(index))) : path;
|
|
1466
|
+
return utils.relocatedError(error, newPath);
|
|
1467
|
+
});
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
class FilterObjectFieldDirectives {
|
|
1472
|
+
filter;
|
|
1473
|
+
constructor(filter) {
|
|
1474
|
+
this.filter = filter;
|
|
1475
|
+
}
|
|
1476
|
+
transformSchema(originalWrappingSchema, subschemaConfig) {
|
|
1477
|
+
const transformer = new TransformObjectFields(
|
|
1478
|
+
(_typeName, _fieldName, fieldConfig) => {
|
|
1479
|
+
const keepDirectives = fieldConfig.astNode?.directives?.filter((dir) => {
|
|
1480
|
+
const directiveDef = originalWrappingSchema.getDirective(
|
|
1481
|
+
dir.name.value
|
|
1482
|
+
);
|
|
1483
|
+
const directiveValue = directiveDef ? utils.getArgumentValues(directiveDef, dir) : void 0;
|
|
1484
|
+
return this.filter(dir.name.value, directiveValue);
|
|
1485
|
+
}) ?? [];
|
|
1486
|
+
if (fieldConfig.astNode?.directives != null && keepDirectives.length !== fieldConfig.astNode.directives.length) {
|
|
1487
|
+
fieldConfig = {
|
|
1488
|
+
...fieldConfig,
|
|
1489
|
+
astNode: {
|
|
1490
|
+
...fieldConfig.astNode,
|
|
1491
|
+
directives: keepDirectives
|
|
1492
|
+
}
|
|
1493
|
+
};
|
|
1494
|
+
return fieldConfig;
|
|
1495
|
+
}
|
|
1496
|
+
return void 0;
|
|
1497
|
+
}
|
|
1498
|
+
);
|
|
1499
|
+
return transformer.transformSchema(originalWrappingSchema, subschemaConfig);
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
class RemoveObjectFieldDirectives {
|
|
1504
|
+
transformer;
|
|
1505
|
+
constructor(directiveName, args = {}) {
|
|
1506
|
+
this.transformer = new FilterObjectFieldDirectives(
|
|
1507
|
+
(dirName, dirValue) => {
|
|
1508
|
+
return !(utils.valueMatchesCriteria(dirName, directiveName) && utils.valueMatchesCriteria(dirValue, args));
|
|
1509
|
+
}
|
|
1510
|
+
);
|
|
1511
|
+
}
|
|
1512
|
+
transformSchema(originalWrappingSchema, subschemaConfig) {
|
|
1513
|
+
return this.transformer.transformSchema(
|
|
1514
|
+
originalWrappingSchema,
|
|
1515
|
+
subschemaConfig
|
|
1516
|
+
);
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
|
|
1520
|
+
class RemoveObjectFieldsWithDirective {
|
|
1521
|
+
directiveName;
|
|
1522
|
+
args;
|
|
1523
|
+
constructor(directiveName, args = {}) {
|
|
1524
|
+
this.directiveName = directiveName;
|
|
1525
|
+
this.args = args;
|
|
1526
|
+
}
|
|
1527
|
+
transformSchema(originalWrappingSchema, subschemaConfig) {
|
|
1528
|
+
const transformer = new FilterObjectFields(
|
|
1529
|
+
(_typeName, _fieldName, fieldConfig) => {
|
|
1530
|
+
const directives = utils.getDirectives(originalWrappingSchema, fieldConfig);
|
|
1531
|
+
return !directives.some(
|
|
1532
|
+
(directive) => utils.valueMatchesCriteria(directive.name, this.directiveName) && utils.valueMatchesCriteria(directive.args, this.args)
|
|
1533
|
+
);
|
|
1534
|
+
}
|
|
1535
|
+
);
|
|
1536
|
+
return transformer.transformSchema(originalWrappingSchema, subschemaConfig);
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1540
|
+
class RemoveObjectFieldDeprecations {
|
|
1541
|
+
removeDirectives;
|
|
1542
|
+
removeDeprecations;
|
|
1543
|
+
constructor(reason) {
|
|
1544
|
+
const args = { reason };
|
|
1545
|
+
this.removeDirectives = new FilterObjectFieldDirectives(
|
|
1546
|
+
(dirName, dirValue) => {
|
|
1547
|
+
return !(dirName === "deprecated" && utils.valueMatchesCriteria(dirValue, args));
|
|
1548
|
+
}
|
|
1549
|
+
);
|
|
1550
|
+
this.removeDeprecations = new TransformObjectFields(
|
|
1551
|
+
(_typeName, _fieldName, fieldConfig) => {
|
|
1552
|
+
if (fieldConfig.deprecationReason && utils.valueMatchesCriteria(fieldConfig.deprecationReason, reason)) {
|
|
1553
|
+
fieldConfig = { ...fieldConfig };
|
|
1554
|
+
delete fieldConfig.deprecationReason;
|
|
1555
|
+
}
|
|
1556
|
+
return fieldConfig;
|
|
1557
|
+
}
|
|
1558
|
+
);
|
|
1559
|
+
}
|
|
1560
|
+
transformSchema(originalWrappingSchema, subschemaConfig) {
|
|
1561
|
+
return this.removeDeprecations.transformSchema(
|
|
1562
|
+
this.removeDirectives.transformSchema(
|
|
1563
|
+
originalWrappingSchema,
|
|
1564
|
+
subschemaConfig
|
|
1565
|
+
),
|
|
1566
|
+
subschemaConfig
|
|
1567
|
+
);
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
|
|
1571
|
+
class RemoveObjectFieldsWithDeprecation {
|
|
1572
|
+
transformer;
|
|
1573
|
+
constructor(reason) {
|
|
1574
|
+
this.transformer = new FilterObjectFields(
|
|
1575
|
+
(_typeName, _fieldName, fieldConfig) => {
|
|
1576
|
+
if (fieldConfig.deprecationReason) {
|
|
1577
|
+
return !utils.valueMatchesCriteria(fieldConfig.deprecationReason, reason);
|
|
1578
|
+
}
|
|
1579
|
+
return true;
|
|
1580
|
+
}
|
|
1581
|
+
);
|
|
1582
|
+
}
|
|
1583
|
+
transformSchema(originalWrappingSchema, subschemaConfig) {
|
|
1584
|
+
return this.transformer.transformSchema(
|
|
1585
|
+
originalWrappingSchema,
|
|
1586
|
+
subschemaConfig
|
|
1587
|
+
);
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
class PruneTypes {
|
|
1592
|
+
options;
|
|
1593
|
+
constructor(options = {}) {
|
|
1594
|
+
this.options = options;
|
|
1595
|
+
}
|
|
1596
|
+
transformSchema(originalWrappingSchema, _subschemaConfig) {
|
|
1597
|
+
return utils.pruneSchema(originalWrappingSchema, this.options);
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
class MapFields {
|
|
1602
|
+
fieldNodeTransformerMap;
|
|
1603
|
+
objectValueTransformerMap;
|
|
1604
|
+
errorsTransformer;
|
|
1605
|
+
transformer;
|
|
1606
|
+
constructor(fieldNodeTransformerMap, objectValueTransformerMap, errorsTransformer) {
|
|
1607
|
+
this.fieldNodeTransformerMap = fieldNodeTransformerMap;
|
|
1608
|
+
this.objectValueTransformerMap = objectValueTransformerMap;
|
|
1609
|
+
this.errorsTransformer = errorsTransformer;
|
|
1610
|
+
}
|
|
1611
|
+
_getTransformer() {
|
|
1612
|
+
const transformer = this.transformer;
|
|
1613
|
+
if (transformer === void 0) {
|
|
1614
|
+
throw new Error(
|
|
1615
|
+
`The MapFields transform's "transformRequest" and "transformResult" methods cannot be used without first calling "transformSchema".`
|
|
1616
|
+
);
|
|
1617
|
+
}
|
|
1618
|
+
return transformer;
|
|
1619
|
+
}
|
|
1620
|
+
transformSchema(originalWrappingSchema, subschemaConfig) {
|
|
1621
|
+
const subscriptionTypeName = originalWrappingSchema.getSubscriptionType()?.name;
|
|
1622
|
+
const objectValueTransformerMap = this.objectValueTransformerMap;
|
|
1623
|
+
this.transformer = new TransformCompositeFields(
|
|
1624
|
+
() => void 0,
|
|
1625
|
+
(typeName, fieldName, fieldNode, fragments, transformationContext) => {
|
|
1626
|
+
const typeTransformers = this.fieldNodeTransformerMap[typeName];
|
|
1627
|
+
if (typeTransformers == null) {
|
|
1628
|
+
return void 0;
|
|
1629
|
+
}
|
|
1630
|
+
const fieldNodeTransformer = typeTransformers[fieldName];
|
|
1631
|
+
if (fieldNodeTransformer == null) {
|
|
1632
|
+
return void 0;
|
|
1633
|
+
}
|
|
1634
|
+
return fieldNodeTransformer(
|
|
1635
|
+
fieldNode,
|
|
1636
|
+
fragments,
|
|
1637
|
+
transformationContext
|
|
1638
|
+
);
|
|
1639
|
+
},
|
|
1640
|
+
objectValueTransformerMap != null ? (data, transformationContext) => {
|
|
1641
|
+
if (data == null) {
|
|
1642
|
+
return data;
|
|
1643
|
+
}
|
|
1644
|
+
let typeName = data.__typename;
|
|
1645
|
+
if (typeName == null) {
|
|
1646
|
+
typeName = subscriptionTypeName;
|
|
1647
|
+
if (typeName == null) {
|
|
1648
|
+
return data;
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
const transformer = objectValueTransformerMap[typeName];
|
|
1652
|
+
if (transformer == null) {
|
|
1653
|
+
return data;
|
|
1654
|
+
}
|
|
1655
|
+
return transformer(data, transformationContext);
|
|
1656
|
+
} : void 0,
|
|
1657
|
+
this.errorsTransformer != null ? this.errorsTransformer : void 0
|
|
1658
|
+
);
|
|
1659
|
+
return this.transformer.transformSchema(
|
|
1660
|
+
originalWrappingSchema,
|
|
1661
|
+
subschemaConfig
|
|
1662
|
+
);
|
|
1663
|
+
}
|
|
1664
|
+
transformRequest(originalRequest, delegationContext, transformationContext) {
|
|
1665
|
+
return this._getTransformer().transformRequest(
|
|
1666
|
+
originalRequest,
|
|
1667
|
+
delegationContext,
|
|
1668
|
+
transformationContext
|
|
1669
|
+
);
|
|
1670
|
+
}
|
|
1671
|
+
transformResult(originalResult, delegationContext, transformationContext) {
|
|
1672
|
+
return this._getTransformer().transformResult(
|
|
1673
|
+
originalResult,
|
|
1674
|
+
delegationContext,
|
|
1675
|
+
transformationContext
|
|
1676
|
+
);
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
|
|
1680
|
+
class WrapFields {
|
|
1681
|
+
outerTypeName;
|
|
1682
|
+
wrappingFieldNames;
|
|
1683
|
+
wrappingTypeNames;
|
|
1684
|
+
numWraps;
|
|
1685
|
+
fieldNames;
|
|
1686
|
+
transformer;
|
|
1687
|
+
config;
|
|
1688
|
+
constructor(outerTypeName, wrappingFieldNames, wrappingTypeNames, fieldNames, prefix = "gqtld", config = { isNullable: false }) {
|
|
1689
|
+
this.outerTypeName = outerTypeName;
|
|
1690
|
+
this.wrappingFieldNames = wrappingFieldNames;
|
|
1691
|
+
this.wrappingTypeNames = wrappingTypeNames;
|
|
1692
|
+
this.numWraps = wrappingFieldNames.length;
|
|
1693
|
+
this.fieldNames = fieldNames;
|
|
1694
|
+
this.config = config;
|
|
1695
|
+
const remainingWrappingFieldNames = this.wrappingFieldNames.slice();
|
|
1696
|
+
const outerMostWrappingFieldName = remainingWrappingFieldNames.shift();
|
|
1697
|
+
if (outerMostWrappingFieldName == null) {
|
|
1698
|
+
throw new Error(`Cannot wrap fields, no wrapping field name provided.`);
|
|
1699
|
+
}
|
|
1700
|
+
this.transformer = new MapFields(
|
|
1701
|
+
{
|
|
1702
|
+
[outerTypeName]: {
|
|
1703
|
+
[outerMostWrappingFieldName]: (fieldNode, fragments, transformationContext) => hoistFieldNodes({
|
|
1704
|
+
fieldNode,
|
|
1705
|
+
path: remainingWrappingFieldNames,
|
|
1706
|
+
fieldNames,
|
|
1707
|
+
fragments,
|
|
1708
|
+
transformationContext,
|
|
1709
|
+
prefix
|
|
1710
|
+
})
|
|
1711
|
+
}
|
|
1712
|
+
},
|
|
1713
|
+
{
|
|
1714
|
+
[outerTypeName]: (value, context) => dehoistValue(value, context)
|
|
1715
|
+
},
|
|
1716
|
+
(errors, context) => dehoistErrors(errors, context)
|
|
1717
|
+
);
|
|
1718
|
+
}
|
|
1719
|
+
transformSchema(originalWrappingSchema, subschemaConfig) {
|
|
1720
|
+
const fieldNames = this.fieldNames;
|
|
1721
|
+
const targetFieldConfigMap = utils.selectObjectFields(
|
|
1722
|
+
originalWrappingSchema,
|
|
1723
|
+
this.outerTypeName,
|
|
1724
|
+
!fieldNames ? () => true : (fieldName) => fieldNames.includes(fieldName)
|
|
1725
|
+
);
|
|
1726
|
+
const newTargetFieldConfigMap = /* @__PURE__ */ Object.create(null);
|
|
1727
|
+
for (const fieldName in targetFieldConfigMap) {
|
|
1728
|
+
const field = targetFieldConfigMap[fieldName];
|
|
1729
|
+
const newField = {
|
|
1730
|
+
...field,
|
|
1731
|
+
resolve: delegate.defaultMergedResolver
|
|
1732
|
+
};
|
|
1733
|
+
newTargetFieldConfigMap[fieldName] = newField;
|
|
1734
|
+
}
|
|
1735
|
+
let wrapIndex = this.numWraps - 1;
|
|
1736
|
+
let wrappingTypeName = this.wrappingTypeNames[wrapIndex];
|
|
1737
|
+
let wrappingFieldName = this.wrappingFieldNames[wrapIndex];
|
|
1738
|
+
let newSchema = utils.appendObjectFields(
|
|
1739
|
+
originalWrappingSchema,
|
|
1740
|
+
wrappingTypeName,
|
|
1741
|
+
newTargetFieldConfigMap
|
|
1742
|
+
);
|
|
1743
|
+
for (wrapIndex--; wrapIndex > -1; wrapIndex--) {
|
|
1744
|
+
const nextWrappingTypeName = this.wrappingTypeNames[wrapIndex];
|
|
1745
|
+
newSchema = utils.appendObjectFields(newSchema, nextWrappingTypeName, {
|
|
1746
|
+
[wrappingFieldName]: {
|
|
1747
|
+
type: new graphql.GraphQLNonNull(
|
|
1748
|
+
newSchema.getType(wrappingTypeName)
|
|
1749
|
+
),
|
|
1750
|
+
resolve: delegate.defaultMergedResolver
|
|
1751
|
+
}
|
|
1752
|
+
});
|
|
1753
|
+
wrappingTypeName = nextWrappingTypeName;
|
|
1754
|
+
wrappingFieldName = this.wrappingFieldNames[wrapIndex];
|
|
1755
|
+
}
|
|
1756
|
+
const targetSchema = subschemaConfig.schema;
|
|
1757
|
+
let wrappingOperation;
|
|
1758
|
+
switch (this.outerTypeName) {
|
|
1759
|
+
case targetSchema.getQueryType()?.name:
|
|
1760
|
+
wrappingOperation = "query";
|
|
1761
|
+
break;
|
|
1762
|
+
case targetSchema.getMutationType()?.name:
|
|
1763
|
+
wrappingOperation = "mutation";
|
|
1764
|
+
break;
|
|
1765
|
+
case targetSchema.getSubscriptionType()?.name:
|
|
1766
|
+
wrappingOperation = "subscription";
|
|
1767
|
+
break;
|
|
1768
|
+
}
|
|
1769
|
+
let resolve;
|
|
1770
|
+
if (wrappingOperation) {
|
|
1771
|
+
const createProxyingResolver = subschemaConfig.createProxyingResolver ?? defaultCreateProxyingResolver;
|
|
1772
|
+
resolve = createProxyingResolver({
|
|
1773
|
+
subschemaConfig,
|
|
1774
|
+
operation: wrappingOperation,
|
|
1775
|
+
fieldName: wrappingFieldName
|
|
1776
|
+
});
|
|
1777
|
+
} else {
|
|
1778
|
+
resolve = delegate.defaultMergedResolver;
|
|
1779
|
+
}
|
|
1780
|
+
const baseType = newSchema.getType(wrappingTypeName);
|
|
1781
|
+
const wrappingType = this.config.isNullable ? baseType : new graphql.GraphQLNonNull(baseType);
|
|
1782
|
+
const newFieldConfig = wrappingOperation === "subscription" ? {
|
|
1783
|
+
type: wrappingType,
|
|
1784
|
+
subscribe: resolve,
|
|
1785
|
+
resolve: (payload) => payload
|
|
1786
|
+
} : {
|
|
1787
|
+
type: wrappingType,
|
|
1788
|
+
resolve
|
|
1789
|
+
};
|
|
1790
|
+
[newSchema] = utils.modifyObjectFields(
|
|
1791
|
+
newSchema,
|
|
1792
|
+
this.outerTypeName,
|
|
1793
|
+
(fieldName) => !!newTargetFieldConfigMap[fieldName],
|
|
1794
|
+
{
|
|
1795
|
+
[wrappingFieldName]: newFieldConfig
|
|
1796
|
+
}
|
|
1797
|
+
);
|
|
1798
|
+
return this.transformer.transformSchema(newSchema, subschemaConfig);
|
|
1799
|
+
}
|
|
1800
|
+
transformRequest(originalRequest, delegationContext, transformationContext) {
|
|
1801
|
+
transformationContext.nextIndex = 0;
|
|
1802
|
+
transformationContext.paths = /* @__PURE__ */ Object.create(null);
|
|
1803
|
+
return this.transformer.transformRequest(
|
|
1804
|
+
originalRequest,
|
|
1805
|
+
delegationContext,
|
|
1806
|
+
transformationContext
|
|
1807
|
+
);
|
|
1808
|
+
}
|
|
1809
|
+
transformResult(originalResult, delegationContext, transformationContext) {
|
|
1810
|
+
return this.transformer.transformResult(
|
|
1811
|
+
originalResult,
|
|
1812
|
+
delegationContext,
|
|
1813
|
+
transformationContext
|
|
1814
|
+
);
|
|
1815
|
+
}
|
|
1816
|
+
}
|
|
1817
|
+
function collectFields(selectionSet, fragments, fields = [], visitedFragmentNames = {}) {
|
|
1818
|
+
if (selectionSet != null) {
|
|
1819
|
+
for (const selection of selectionSet.selections) {
|
|
1820
|
+
switch (selection.kind) {
|
|
1821
|
+
case graphql.Kind.FIELD:
|
|
1822
|
+
fields.push(selection);
|
|
1823
|
+
break;
|
|
1824
|
+
case graphql.Kind.INLINE_FRAGMENT:
|
|
1825
|
+
collectFields(
|
|
1826
|
+
selection.selectionSet,
|
|
1827
|
+
fragments,
|
|
1828
|
+
fields,
|
|
1829
|
+
visitedFragmentNames
|
|
1830
|
+
);
|
|
1831
|
+
break;
|
|
1832
|
+
case graphql.Kind.FRAGMENT_SPREAD: {
|
|
1833
|
+
const fragmentName = selection.name.value;
|
|
1834
|
+
if (!visitedFragmentNames[fragmentName]) {
|
|
1835
|
+
visitedFragmentNames[fragmentName] = true;
|
|
1836
|
+
collectFields(
|
|
1837
|
+
fragments[fragmentName].selectionSet,
|
|
1838
|
+
fragments,
|
|
1839
|
+
fields,
|
|
1840
|
+
visitedFragmentNames
|
|
1841
|
+
);
|
|
1842
|
+
}
|
|
1843
|
+
break;
|
|
1844
|
+
}
|
|
1845
|
+
}
|
|
1846
|
+
}
|
|
1847
|
+
}
|
|
1848
|
+
return fields;
|
|
1849
|
+
}
|
|
1850
|
+
function aliasFieldNode(fieldNode, str) {
|
|
1851
|
+
return {
|
|
1852
|
+
...fieldNode,
|
|
1853
|
+
alias: {
|
|
1854
|
+
kind: graphql.Kind.NAME,
|
|
1855
|
+
value: str
|
|
1856
|
+
}
|
|
1857
|
+
};
|
|
1858
|
+
}
|
|
1859
|
+
function hoistFieldNodes({
|
|
1860
|
+
fieldNode,
|
|
1861
|
+
fieldNames,
|
|
1862
|
+
path,
|
|
1863
|
+
fragments,
|
|
1864
|
+
transformationContext,
|
|
1865
|
+
prefix,
|
|
1866
|
+
index = 0,
|
|
1867
|
+
wrappingPath = []
|
|
1868
|
+
}) {
|
|
1869
|
+
const alias = fieldNode.alias != null ? fieldNode.alias.value : fieldNode.name.value;
|
|
1870
|
+
let newFieldNodes = [];
|
|
1871
|
+
if (index < path.length) {
|
|
1872
|
+
const pathSegment = path[index];
|
|
1873
|
+
for (const possibleFieldNode of collectFields(
|
|
1874
|
+
fieldNode.selectionSet,
|
|
1875
|
+
fragments
|
|
1876
|
+
)) {
|
|
1877
|
+
if (possibleFieldNode.name.value === pathSegment) {
|
|
1878
|
+
const newWrappingPath = wrappingPath.concat([alias]);
|
|
1879
|
+
newFieldNodes = newFieldNodes.concat(
|
|
1880
|
+
hoistFieldNodes({
|
|
1881
|
+
fieldNode: possibleFieldNode,
|
|
1882
|
+
fieldNames,
|
|
1883
|
+
path,
|
|
1884
|
+
fragments,
|
|
1885
|
+
transformationContext,
|
|
1886
|
+
prefix,
|
|
1887
|
+
index: index + 1,
|
|
1888
|
+
wrappingPath: newWrappingPath
|
|
1889
|
+
})
|
|
1890
|
+
);
|
|
1891
|
+
}
|
|
1892
|
+
}
|
|
1893
|
+
} else {
|
|
1894
|
+
for (const possibleFieldNode of collectFields(
|
|
1895
|
+
fieldNode.selectionSet,
|
|
1896
|
+
fragments
|
|
1897
|
+
)) {
|
|
1898
|
+
if (!fieldNames || fieldNames.includes(possibleFieldNode.name.value)) {
|
|
1899
|
+
const nextIndex = transformationContext.nextIndex;
|
|
1900
|
+
transformationContext.nextIndex++;
|
|
1901
|
+
const indexingAlias = `__${prefix}${nextIndex}__`;
|
|
1902
|
+
transformationContext.paths[indexingAlias] = {
|
|
1903
|
+
pathToField: wrappingPath.concat([alias]),
|
|
1904
|
+
alias: possibleFieldNode.alias != null ? possibleFieldNode.alias.value : possibleFieldNode.name.value
|
|
1905
|
+
};
|
|
1906
|
+
newFieldNodes.push(aliasFieldNode(possibleFieldNode, indexingAlias));
|
|
1907
|
+
}
|
|
1908
|
+
}
|
|
1909
|
+
}
|
|
1910
|
+
return newFieldNodes;
|
|
1911
|
+
}
|
|
1912
|
+
function dehoistValue(originalValue, context) {
|
|
1913
|
+
if (originalValue == null) {
|
|
1914
|
+
return originalValue;
|
|
1915
|
+
}
|
|
1916
|
+
const newValue = /* @__PURE__ */ Object.create(null);
|
|
1917
|
+
for (const alias in originalValue) {
|
|
1918
|
+
let obj = newValue;
|
|
1919
|
+
const path = context.paths[alias];
|
|
1920
|
+
if (path == null) {
|
|
1921
|
+
newValue[alias] = originalValue[alias];
|
|
1922
|
+
continue;
|
|
1923
|
+
}
|
|
1924
|
+
const pathToField = path.pathToField;
|
|
1925
|
+
const fieldAlias = path.alias;
|
|
1926
|
+
for (const key of pathToField) {
|
|
1927
|
+
obj = obj[key] = obj[key] || /* @__PURE__ */ Object.create(null);
|
|
1928
|
+
}
|
|
1929
|
+
obj[fieldAlias] = originalValue[alias];
|
|
1930
|
+
}
|
|
1931
|
+
return newValue;
|
|
1932
|
+
}
|
|
1933
|
+
function dehoistErrors(errors, context) {
|
|
1934
|
+
if (errors === void 0) {
|
|
1935
|
+
return void 0;
|
|
1936
|
+
}
|
|
1937
|
+
return errors.map((error) => {
|
|
1938
|
+
const originalPath = error.path;
|
|
1939
|
+
if (originalPath == null) {
|
|
1940
|
+
return error;
|
|
1941
|
+
}
|
|
1942
|
+
let newPath = [];
|
|
1943
|
+
for (const pathSegment of originalPath) {
|
|
1944
|
+
if (typeof pathSegment !== "string") {
|
|
1945
|
+
newPath.push(pathSegment);
|
|
1946
|
+
continue;
|
|
1947
|
+
}
|
|
1948
|
+
const path = context.paths[pathSegment];
|
|
1949
|
+
if (path == null) {
|
|
1950
|
+
newPath.push(pathSegment);
|
|
1951
|
+
continue;
|
|
1952
|
+
}
|
|
1953
|
+
newPath = newPath.concat(path.pathToField, [path.alias]);
|
|
1954
|
+
}
|
|
1955
|
+
return utils.relocatedError(error, newPath);
|
|
1956
|
+
});
|
|
1957
|
+
}
|
|
1958
|
+
|
|
1959
|
+
class WrapType {
|
|
1960
|
+
transformer;
|
|
1961
|
+
constructor(outerTypeName, innerTypeName, fieldName) {
|
|
1962
|
+
this.transformer = new WrapFields(
|
|
1963
|
+
outerTypeName,
|
|
1964
|
+
[fieldName],
|
|
1965
|
+
[innerTypeName]
|
|
1966
|
+
);
|
|
1967
|
+
}
|
|
1968
|
+
transformSchema(originalWrappingSchema, subschemaConfig) {
|
|
1969
|
+
return this.transformer.transformSchema(
|
|
1970
|
+
originalWrappingSchema,
|
|
1971
|
+
subschemaConfig
|
|
1972
|
+
);
|
|
1973
|
+
}
|
|
1974
|
+
transformRequest(originalRequest, delegationContext, transformationContext) {
|
|
1975
|
+
return this.transformer.transformRequest(
|
|
1976
|
+
originalRequest,
|
|
1977
|
+
delegationContext,
|
|
1978
|
+
transformationContext
|
|
1979
|
+
);
|
|
1980
|
+
}
|
|
1981
|
+
transformResult(originalResult, delegationContext, transformationContext) {
|
|
1982
|
+
return this.transformer.transformResult(
|
|
1983
|
+
originalResult,
|
|
1984
|
+
delegationContext,
|
|
1985
|
+
transformationContext
|
|
1986
|
+
);
|
|
1987
|
+
}
|
|
1988
|
+
}
|
|
1989
|
+
|
|
1990
|
+
class HoistField {
|
|
1991
|
+
typeName;
|
|
1992
|
+
newFieldName;
|
|
1993
|
+
pathToField;
|
|
1994
|
+
oldFieldName;
|
|
1995
|
+
argFilters;
|
|
1996
|
+
argLevels;
|
|
1997
|
+
transformer;
|
|
1998
|
+
constructor(typeName, pathConfig, newFieldName, alias = "__gqtlw__") {
|
|
1999
|
+
this.typeName = typeName;
|
|
2000
|
+
this.newFieldName = newFieldName;
|
|
2001
|
+
const path = pathConfig.map(
|
|
2002
|
+
(segment) => typeof segment === "string" ? segment : segment.fieldName
|
|
2003
|
+
);
|
|
2004
|
+
this.argFilters = pathConfig.map((segment, index) => {
|
|
2005
|
+
if (typeof segment === "string" || segment.argFilter == null) {
|
|
2006
|
+
return index === pathConfig.length - 1 ? () => true : () => false;
|
|
2007
|
+
}
|
|
2008
|
+
return segment.argFilter;
|
|
2009
|
+
});
|
|
2010
|
+
const pathToField = path.slice();
|
|
2011
|
+
const oldFieldName = pathToField.pop();
|
|
2012
|
+
if (oldFieldName == null) {
|
|
2013
|
+
throw new Error(
|
|
2014
|
+
`Cannot hoist field to ${newFieldName} on type ${typeName}, no path provided.`
|
|
2015
|
+
);
|
|
2016
|
+
}
|
|
2017
|
+
this.oldFieldName = oldFieldName;
|
|
2018
|
+
this.pathToField = pathToField;
|
|
2019
|
+
const argLevels = /* @__PURE__ */ Object.create(null);
|
|
2020
|
+
this.transformer = new MapFields(
|
|
2021
|
+
{
|
|
2022
|
+
[typeName]: {
|
|
2023
|
+
[newFieldName]: (fieldNode) => wrapFieldNode(
|
|
2024
|
+
renameFieldNode(fieldNode, oldFieldName),
|
|
2025
|
+
pathToField,
|
|
2026
|
+
alias,
|
|
2027
|
+
argLevels
|
|
2028
|
+
)
|
|
2029
|
+
}
|
|
2030
|
+
},
|
|
2031
|
+
{
|
|
2032
|
+
[typeName]: (value) => unwrapValue(value, alias)
|
|
2033
|
+
},
|
|
2034
|
+
(errors) => errors != null ? unwrapErrors(errors, alias) : void 0
|
|
2035
|
+
);
|
|
2036
|
+
this.argLevels = argLevels;
|
|
2037
|
+
}
|
|
2038
|
+
transformSchema(originalWrappingSchema, subschemaConfig) {
|
|
2039
|
+
const argsMap = /* @__PURE__ */ Object.create(null);
|
|
2040
|
+
let isList = false;
|
|
2041
|
+
const innerType = this.pathToField.reduce(
|
|
2042
|
+
(acc, pathSegment, index) => {
|
|
2043
|
+
const field = acc.getFields()[pathSegment];
|
|
2044
|
+
for (const arg of field.args) {
|
|
2045
|
+
if (this.argFilters[index](arg)) {
|
|
2046
|
+
argsMap[arg.name] = arg;
|
|
2047
|
+
this.argLevels[arg.name] = index;
|
|
2048
|
+
}
|
|
2049
|
+
}
|
|
2050
|
+
const nullableType = graphql.getNullableType(field?.type);
|
|
2051
|
+
if (graphql.isListType(nullableType)) {
|
|
2052
|
+
isList = true;
|
|
2053
|
+
return graphql.getNamedType(nullableType);
|
|
2054
|
+
}
|
|
2055
|
+
return nullableType;
|
|
2056
|
+
},
|
|
2057
|
+
originalWrappingSchema.getType(this.typeName)
|
|
2058
|
+
);
|
|
2059
|
+
let [newSchema, targetFieldConfigMap] = utils.removeObjectFields(
|
|
2060
|
+
originalWrappingSchema,
|
|
2061
|
+
innerType.name,
|
|
2062
|
+
(fieldName) => fieldName === this.oldFieldName
|
|
2063
|
+
);
|
|
2064
|
+
const targetField = targetFieldConfigMap[this.oldFieldName];
|
|
2065
|
+
let resolve;
|
|
2066
|
+
const hoistingToRootField = this.typeName === originalWrappingSchema.getQueryType()?.name || this.typeName === originalWrappingSchema.getMutationType()?.name;
|
|
2067
|
+
if (hoistingToRootField) {
|
|
2068
|
+
const targetSchema = subschemaConfig.schema;
|
|
2069
|
+
const operation = this.typeName === targetSchema.getQueryType()?.name ? "query" : "mutation";
|
|
2070
|
+
const createProxyingResolver = subschemaConfig.createProxyingResolver ?? defaultCreateProxyingResolver;
|
|
2071
|
+
resolve = createProxyingResolver({
|
|
2072
|
+
subschemaConfig,
|
|
2073
|
+
operation,
|
|
2074
|
+
fieldName: this.newFieldName
|
|
2075
|
+
});
|
|
2076
|
+
} else {
|
|
2077
|
+
resolve = delegate.defaultMergedResolver;
|
|
2078
|
+
}
|
|
2079
|
+
const newTargetField = {
|
|
2080
|
+
...targetField,
|
|
2081
|
+
resolve
|
|
2082
|
+
};
|
|
2083
|
+
const level = this.pathToField.length;
|
|
2084
|
+
const args = targetField?.args;
|
|
2085
|
+
if (args != null) {
|
|
2086
|
+
for (const argName in args) {
|
|
2087
|
+
const argConfig = args[argName];
|
|
2088
|
+
if (argConfig == null) {
|
|
2089
|
+
continue;
|
|
2090
|
+
}
|
|
2091
|
+
const arg = {
|
|
2092
|
+
...argConfig,
|
|
2093
|
+
name: argName,
|
|
2094
|
+
description: argConfig.description,
|
|
2095
|
+
defaultValue: argConfig.defaultValue,
|
|
2096
|
+
extensions: argConfig.extensions,
|
|
2097
|
+
astNode: argConfig.astNode
|
|
2098
|
+
};
|
|
2099
|
+
if (this.argFilters[level]?.(arg)) {
|
|
2100
|
+
argsMap[argName] = arg;
|
|
2101
|
+
this.argLevels[arg.name] = level;
|
|
2102
|
+
}
|
|
2103
|
+
}
|
|
2104
|
+
}
|
|
2105
|
+
newTargetField.args = argsMap;
|
|
2106
|
+
if (isList) {
|
|
2107
|
+
newTargetField.type = new graphql.GraphQLList(newTargetField.type);
|
|
2108
|
+
const resolver = newTargetField.resolve;
|
|
2109
|
+
newTargetField.resolve = (parent, args2, context, info) => Promise.all(
|
|
2110
|
+
Object.keys(parent).filter((key) => !isNaN(parseInt(key, 10))).map((key) => resolver(parent[key], args2, context, info))
|
|
2111
|
+
);
|
|
2112
|
+
}
|
|
2113
|
+
newSchema = utils.appendObjectFields(newSchema, this.typeName, {
|
|
2114
|
+
[this.newFieldName]: newTargetField
|
|
2115
|
+
});
|
|
2116
|
+
return this.transformer.transformSchema(newSchema, subschemaConfig);
|
|
2117
|
+
}
|
|
2118
|
+
transformRequest(originalRequest, delegationContext, transformationContext) {
|
|
2119
|
+
return this.transformer.transformRequest(
|
|
2120
|
+
originalRequest,
|
|
2121
|
+
delegationContext,
|
|
2122
|
+
transformationContext
|
|
2123
|
+
);
|
|
2124
|
+
}
|
|
2125
|
+
transformResult(originalResult, delegationContext, transformationContext) {
|
|
2126
|
+
return this.transformer.transformResult(
|
|
2127
|
+
originalResult,
|
|
2128
|
+
delegationContext,
|
|
2129
|
+
transformationContext
|
|
2130
|
+
);
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
function wrapFieldNode(fieldNode, path, alias, argLevels) {
|
|
2134
|
+
return path.reduceRight(
|
|
2135
|
+
(acc, fieldName, index) => ({
|
|
2136
|
+
kind: graphql.Kind.FIELD,
|
|
2137
|
+
alias: {
|
|
2138
|
+
kind: graphql.Kind.NAME,
|
|
2139
|
+
value: alias
|
|
2140
|
+
},
|
|
2141
|
+
name: {
|
|
2142
|
+
kind: graphql.Kind.NAME,
|
|
2143
|
+
value: fieldName
|
|
2144
|
+
},
|
|
2145
|
+
selectionSet: {
|
|
2146
|
+
kind: graphql.Kind.SELECTION_SET,
|
|
2147
|
+
selections: [acc]
|
|
2148
|
+
},
|
|
2149
|
+
arguments: fieldNode.arguments != null ? fieldNode.arguments.filter(
|
|
2150
|
+
(arg) => argLevels[arg.name.value] === index
|
|
2151
|
+
) : void 0
|
|
2152
|
+
}),
|
|
2153
|
+
{
|
|
2154
|
+
...fieldNode,
|
|
2155
|
+
arguments: fieldNode.arguments != null ? fieldNode.arguments.filter(
|
|
2156
|
+
(arg) => argLevels[arg.name.value] === path.length
|
|
2157
|
+
) : void 0
|
|
2158
|
+
}
|
|
2159
|
+
);
|
|
2160
|
+
}
|
|
2161
|
+
function renameFieldNode(fieldNode, name) {
|
|
2162
|
+
return {
|
|
2163
|
+
...fieldNode,
|
|
2164
|
+
alias: {
|
|
2165
|
+
kind: graphql.Kind.NAME,
|
|
2166
|
+
value: fieldNode.alias != null ? fieldNode.alias.value : fieldNode.name.value
|
|
2167
|
+
},
|
|
2168
|
+
name: {
|
|
2169
|
+
kind: graphql.Kind.NAME,
|
|
2170
|
+
value: name
|
|
2171
|
+
}
|
|
2172
|
+
};
|
|
2173
|
+
}
|
|
2174
|
+
function unwrapValue(originalValue, alias) {
|
|
2175
|
+
let newValue = originalValue;
|
|
2176
|
+
let object = newValue[alias];
|
|
2177
|
+
while (object != null) {
|
|
2178
|
+
newValue = object;
|
|
2179
|
+
object = newValue[alias];
|
|
2180
|
+
}
|
|
2181
|
+
delete originalValue[alias];
|
|
2182
|
+
Object.assign(originalValue, newValue);
|
|
2183
|
+
return originalValue;
|
|
2184
|
+
}
|
|
2185
|
+
function unwrapErrors(errors, alias) {
|
|
2186
|
+
return errors.map((error) => {
|
|
2187
|
+
const originalPath = error.path;
|
|
2188
|
+
if (originalPath == null) {
|
|
2189
|
+
return error;
|
|
2190
|
+
}
|
|
2191
|
+
const newPath = originalPath.filter((pathSegment) => pathSegment !== alias);
|
|
2192
|
+
return utils.relocatedError(error, newPath);
|
|
2193
|
+
});
|
|
2194
|
+
}
|
|
2195
|
+
|
|
2196
|
+
class WrapQuery {
|
|
2197
|
+
constructor(path, wrapper, extractor) {
|
|
2198
|
+
this.path = path;
|
|
2199
|
+
this.wrapper = wrapper;
|
|
2200
|
+
this.extractor = extractor;
|
|
2201
|
+
const pollutingKeys = this.path.filter(delegate.isPrototypePollutingKey);
|
|
2202
|
+
if (pollutingKeys.length > 0) {
|
|
2203
|
+
throw new TypeError(
|
|
2204
|
+
`Invalid path - cannot be a prototype polluting keys: ${pollutingKeys.join(".")}`
|
|
2205
|
+
);
|
|
2206
|
+
}
|
|
2207
|
+
}
|
|
2208
|
+
transformRequest(originalRequest, _delegationContext, _transformationContext) {
|
|
2209
|
+
const fieldPath = [];
|
|
2210
|
+
const ourPath = JSON.stringify(this.path);
|
|
2211
|
+
const document = graphql.visit(originalRequest.document, {
|
|
2212
|
+
[graphql.Kind.FIELD]: {
|
|
2213
|
+
enter: (node) => {
|
|
2214
|
+
fieldPath.push(node.name.value);
|
|
2215
|
+
if (node.selectionSet != null && ourPath === JSON.stringify(fieldPath)) {
|
|
2216
|
+
const wrapResult = this.wrapper(node.selectionSet);
|
|
2217
|
+
const selectionSet = wrapResult != null && wrapResult.kind === graphql.Kind.SELECTION_SET ? wrapResult : {
|
|
2218
|
+
kind: graphql.Kind.SELECTION_SET,
|
|
2219
|
+
selections: [wrapResult]
|
|
2220
|
+
};
|
|
2221
|
+
return {
|
|
2222
|
+
...node,
|
|
2223
|
+
selectionSet
|
|
2224
|
+
};
|
|
2225
|
+
}
|
|
2226
|
+
return void 0;
|
|
2227
|
+
},
|
|
2228
|
+
leave: () => {
|
|
2229
|
+
fieldPath.pop();
|
|
2230
|
+
}
|
|
2231
|
+
}
|
|
2232
|
+
});
|
|
2233
|
+
return {
|
|
2234
|
+
...originalRequest,
|
|
2235
|
+
document
|
|
2236
|
+
};
|
|
2237
|
+
}
|
|
2238
|
+
transformResult(originalResult, _delegationContext, _transformationContext) {
|
|
2239
|
+
const rootData = originalResult.data;
|
|
2240
|
+
if (rootData != null) {
|
|
2241
|
+
let data = rootData;
|
|
2242
|
+
const path = [...this.path];
|
|
2243
|
+
while (path.length > 1) {
|
|
2244
|
+
const next = path.shift();
|
|
2245
|
+
if (data[next]) {
|
|
2246
|
+
data = data[next];
|
|
2247
|
+
}
|
|
2248
|
+
}
|
|
2249
|
+
const lastKey = path[0];
|
|
2250
|
+
data[lastKey] = this.extractor(data[lastKey]);
|
|
2251
|
+
}
|
|
2252
|
+
return {
|
|
2253
|
+
data: rootData,
|
|
2254
|
+
errors: originalResult.errors
|
|
2255
|
+
};
|
|
2256
|
+
}
|
|
2257
|
+
}
|
|
2258
|
+
|
|
2259
|
+
class ExtractField {
|
|
2260
|
+
from;
|
|
2261
|
+
to;
|
|
2262
|
+
constructor({ from, to }) {
|
|
2263
|
+
this.from = from;
|
|
2264
|
+
this.to = to;
|
|
2265
|
+
}
|
|
2266
|
+
transformRequest(originalRequest, _delegationContext, _transformationContext) {
|
|
2267
|
+
let fromSelection;
|
|
2268
|
+
const ourPathFrom = JSON.stringify(this.from);
|
|
2269
|
+
const ourPathTo = JSON.stringify(this.to);
|
|
2270
|
+
let fieldPath = [];
|
|
2271
|
+
graphql.visit(originalRequest.document, {
|
|
2272
|
+
[graphql.Kind.FIELD]: {
|
|
2273
|
+
enter: (node) => {
|
|
2274
|
+
fieldPath.push(node.name.value);
|
|
2275
|
+
if (ourPathFrom === JSON.stringify(fieldPath)) {
|
|
2276
|
+
fromSelection = node.selectionSet;
|
|
2277
|
+
return graphql.BREAK;
|
|
2278
|
+
}
|
|
2279
|
+
return void 0;
|
|
2280
|
+
},
|
|
2281
|
+
leave: () => {
|
|
2282
|
+
fieldPath.pop();
|
|
2283
|
+
}
|
|
2284
|
+
}
|
|
2285
|
+
});
|
|
2286
|
+
fieldPath = [];
|
|
2287
|
+
const document = graphql.visit(originalRequest.document, {
|
|
2288
|
+
[graphql.Kind.FIELD]: {
|
|
2289
|
+
enter: (node) => {
|
|
2290
|
+
fieldPath.push(node.name.value);
|
|
2291
|
+
if (ourPathTo === JSON.stringify(fieldPath) && fromSelection != null) {
|
|
2292
|
+
return {
|
|
2293
|
+
...node,
|
|
2294
|
+
selectionSet: fromSelection
|
|
2295
|
+
};
|
|
2296
|
+
}
|
|
2297
|
+
return void 0;
|
|
2298
|
+
},
|
|
2299
|
+
leave: () => {
|
|
2300
|
+
fieldPath.pop();
|
|
2301
|
+
}
|
|
2302
|
+
}
|
|
2303
|
+
});
|
|
2304
|
+
return {
|
|
2305
|
+
...originalRequest,
|
|
2306
|
+
document
|
|
2307
|
+
};
|
|
2308
|
+
}
|
|
2309
|
+
}
|
|
2310
|
+
|
|
2311
|
+
function getSchemaFromIntrospection(introspectionResult, options) {
|
|
2312
|
+
if (introspectionResult?.data?.__schema) {
|
|
2313
|
+
return graphql.buildClientSchema(introspectionResult.data, options);
|
|
2314
|
+
}
|
|
2315
|
+
if (introspectionResult?.errors) {
|
|
2316
|
+
const graphqlErrors = introspectionResult.errors.map(
|
|
2317
|
+
(error) => utils.createGraphQLError(error.message, error)
|
|
2318
|
+
);
|
|
2319
|
+
if (introspectionResult.errors.length === 1) {
|
|
2320
|
+
throw graphqlErrors[0];
|
|
2321
|
+
} else {
|
|
2322
|
+
throw new AggregateError(
|
|
2323
|
+
graphqlErrors,
|
|
2324
|
+
"Could not obtain introspection result"
|
|
2325
|
+
);
|
|
2326
|
+
}
|
|
2327
|
+
}
|
|
2328
|
+
throw utils.createGraphQLError(
|
|
2329
|
+
`Could not obtain introspection result, received the following as response;
|
|
2330
|
+
${utils.inspect(
|
|
2331
|
+
introspectionResult
|
|
2332
|
+
)}`
|
|
2333
|
+
);
|
|
2334
|
+
}
|
|
2335
|
+
function schemaFromExecutor(executor, context, options) {
|
|
2336
|
+
const parsedIntrospectionQuery = graphql.parse(
|
|
2337
|
+
graphql.getIntrospectionQuery(options),
|
|
2338
|
+
options
|
|
2339
|
+
);
|
|
2340
|
+
return promiseHelpers.handleMaybePromise(
|
|
2341
|
+
() => promiseHelpers.handleMaybePromise(
|
|
2342
|
+
() => executor({
|
|
2343
|
+
document: parsedIntrospectionQuery,
|
|
2344
|
+
context
|
|
2345
|
+
}),
|
|
2346
|
+
(introspection) => {
|
|
2347
|
+
if (utils.isAsyncIterable(introspection)) {
|
|
2348
|
+
const iterator = introspection[Symbol.asyncIterator]();
|
|
2349
|
+
return iterator.next().then(({ value }) => value);
|
|
2350
|
+
}
|
|
2351
|
+
return introspection;
|
|
2352
|
+
}
|
|
2353
|
+
),
|
|
2354
|
+
(introspection) => getSchemaFromIntrospection(introspection, options)
|
|
2355
|
+
);
|
|
2356
|
+
}
|
|
2357
|
+
|
|
2358
|
+
exports.ExtractField = ExtractField;
|
|
2359
|
+
exports.FilterInputObjectFields = FilterInputObjectFields;
|
|
2360
|
+
exports.FilterInterfaceFields = FilterInterfaceFields;
|
|
2361
|
+
exports.FilterObjectFieldDirectives = FilterObjectFieldDirectives;
|
|
2362
|
+
exports.FilterObjectFields = FilterObjectFields;
|
|
2363
|
+
exports.FilterRootFields = FilterRootFields;
|
|
2364
|
+
exports.FilterTypes = FilterTypes;
|
|
2365
|
+
exports.HoistField = HoistField;
|
|
2366
|
+
exports.MapFields = MapFields;
|
|
2367
|
+
exports.MapLeafValues = MapLeafValues;
|
|
2368
|
+
exports.PruneSchema = PruneTypes;
|
|
2369
|
+
exports.RemoveObjectFieldDeprecations = RemoveObjectFieldDeprecations;
|
|
2370
|
+
exports.RemoveObjectFieldDirectives = RemoveObjectFieldDirectives;
|
|
2371
|
+
exports.RemoveObjectFieldsWithDeprecation = RemoveObjectFieldsWithDeprecation;
|
|
2372
|
+
exports.RemoveObjectFieldsWithDirective = RemoveObjectFieldsWithDirective;
|
|
2373
|
+
exports.RenameInputObjectFields = RenameInputObjectFields;
|
|
2374
|
+
exports.RenameInterfaceFields = RenameInterfaceFields;
|
|
2375
|
+
exports.RenameObjectFieldArguments = RenameObjectFieldArguments;
|
|
2376
|
+
exports.RenameObjectFields = RenameObjectFields;
|
|
2377
|
+
exports.RenameRootFields = RenameRootFields;
|
|
2378
|
+
exports.RenameRootTypes = RenameRootTypes;
|
|
2379
|
+
exports.RenameTypes = RenameTypes;
|
|
2380
|
+
exports.TransformCompositeFields = TransformCompositeFields;
|
|
2381
|
+
exports.TransformEnumValues = TransformEnumValues;
|
|
2382
|
+
exports.TransformInputObjectFields = TransformInputObjectFields;
|
|
2383
|
+
exports.TransformInterfaceFields = TransformInterfaceFields;
|
|
2384
|
+
exports.TransformObjectFields = TransformObjectFields;
|
|
2385
|
+
exports.TransformQuery = TransformQuery;
|
|
2386
|
+
exports.TransformRootFields = TransformRootFields;
|
|
2387
|
+
exports.WrapFields = WrapFields;
|
|
2388
|
+
exports.WrapQuery = WrapQuery;
|
|
2389
|
+
exports.WrapType = WrapType;
|
|
2390
|
+
exports.defaultCreateProxyingResolver = defaultCreateProxyingResolver;
|
|
2391
|
+
exports.generateProxyingResolvers = generateProxyingResolvers;
|
|
2392
|
+
exports.schemaFromExecutor = schemaFromExecutor;
|
|
2393
|
+
exports.wrapSchema = wrapSchema;
|