@graphql-tools/wrap 9.2.21 → 9.2.22-alpha-20221219142921-bb131fa3
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.
|
@@ -82,6 +82,38 @@ class TransformInputObjectFields {
|
|
|
82
82
|
fragments[def.name.value] = def;
|
|
83
83
|
}
|
|
84
84
|
const document = this.transformDocument(originalRequest.document, this.mapping, this.inputFieldNodeTransformer, this.inputObjectNodeTransformer, originalRequest, delegationContext);
|
|
85
|
+
if (delegationContext.args != null) {
|
|
86
|
+
const targetRootType = (0, utils_1.getDefinedRootType)(delegationContext.transformedSchema, delegationContext.operation);
|
|
87
|
+
if (targetRootType) {
|
|
88
|
+
const targetField = targetRootType.getFields()[delegationContext.fieldName];
|
|
89
|
+
if (targetField) {
|
|
90
|
+
const newArgs = Object.create(null);
|
|
91
|
+
for (const targetArg of targetField.args) {
|
|
92
|
+
if (targetArg.name in delegationContext.args) {
|
|
93
|
+
newArgs[targetArg.name] = (0, utils_1.transformInputValue)(targetArg.type, delegationContext.args[targetArg.name], undefined, (type, originalValue) => {
|
|
94
|
+
var _a;
|
|
95
|
+
const newValue = Object.create(null);
|
|
96
|
+
const fields = type.getFields();
|
|
97
|
+
for (const key in originalValue) {
|
|
98
|
+
const field = fields[key];
|
|
99
|
+
if (field != null) {
|
|
100
|
+
const newFieldName = (_a = this.mapping[type.name]) === null || _a === void 0 ? void 0 : _a[field.name];
|
|
101
|
+
if (newFieldName != null) {
|
|
102
|
+
newValue[newFieldName] = originalValue[field.name];
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
newValue[field.name] = originalValue[field.name];
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return newValue;
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
delegationContext.args = newArgs;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
85
117
|
return {
|
|
86
118
|
...originalRequest,
|
|
87
119
|
document,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { typeFromAST, TypeInfo, visit, visitWithTypeInfo, Kind, isInputType, getNamedType, } from 'graphql';
|
|
2
|
-
import { MapperKind, mapSchema, transformInputValue } from '@graphql-tools/utils';
|
|
2
|
+
import { getDefinedRootType, MapperKind, mapSchema, transformInputValue } from '@graphql-tools/utils';
|
|
3
3
|
export default class TransformInputObjectFields {
|
|
4
4
|
constructor(inputFieldTransformer, inputFieldNodeTransformer, inputObjectNodeTransformer) {
|
|
5
5
|
this.inputFieldTransformer = inputFieldTransformer;
|
|
@@ -80,6 +80,38 @@ export default class TransformInputObjectFields {
|
|
|
80
80
|
fragments[def.name.value] = def;
|
|
81
81
|
}
|
|
82
82
|
const document = this.transformDocument(originalRequest.document, this.mapping, this.inputFieldNodeTransformer, this.inputObjectNodeTransformer, originalRequest, delegationContext);
|
|
83
|
+
if (delegationContext.args != null) {
|
|
84
|
+
const targetRootType = getDefinedRootType(delegationContext.transformedSchema, delegationContext.operation);
|
|
85
|
+
if (targetRootType) {
|
|
86
|
+
const targetField = targetRootType.getFields()[delegationContext.fieldName];
|
|
87
|
+
if (targetField) {
|
|
88
|
+
const newArgs = Object.create(null);
|
|
89
|
+
for (const targetArg of targetField.args) {
|
|
90
|
+
if (targetArg.name in delegationContext.args) {
|
|
91
|
+
newArgs[targetArg.name] = transformInputValue(targetArg.type, delegationContext.args[targetArg.name], undefined, (type, originalValue) => {
|
|
92
|
+
var _a;
|
|
93
|
+
const newValue = Object.create(null);
|
|
94
|
+
const fields = type.getFields();
|
|
95
|
+
for (const key in originalValue) {
|
|
96
|
+
const field = fields[key];
|
|
97
|
+
if (field != null) {
|
|
98
|
+
const newFieldName = (_a = this.mapping[type.name]) === null || _a === void 0 ? void 0 : _a[field.name];
|
|
99
|
+
if (newFieldName != null) {
|
|
100
|
+
newValue[newFieldName] = originalValue[field.name];
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
newValue[field.name] = originalValue[field.name];
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return newValue;
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
delegationContext.args = newArgs;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
83
115
|
return {
|
|
84
116
|
...originalRequest,
|
|
85
117
|
document,
|