@graphql-tools/wrap 7.0.5-alpha-9e1fc254.0 → 7.0.5
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/es5/index.cjs.js +41 -2
- package/es5/index.cjs.js.map +1 -1
- package/es5/index.esm.js +43 -4
- package/es5/index.esm.js.map +1 -1
- package/es5/package.json +4 -4
- package/es5/transforms/TransformInputObjectFields.d.ts +1 -1
- package/index.cjs.js +40 -1
- package/index.cjs.js.map +1 -1
- package/index.esm.js +42 -3
- package/index.esm.js.map +1 -1
- package/package.json +4 -4
- package/transforms/TransformInputObjectFields.d.ts +1 -1
package/es5/index.cjs.js
CHANGED
|
@@ -583,15 +583,54 @@ var TransformInputObjectFields = /** @class */ (function () {
|
|
|
583
583
|
_a));
|
|
584
584
|
return this.transformedSchema;
|
|
585
585
|
};
|
|
586
|
-
TransformInputObjectFields.prototype.transformRequest = function (originalRequest, delegationContext, _transformationContext
|
|
586
|
+
TransformInputObjectFields.prototype.transformRequest = function (originalRequest, delegationContext, _transformationContext) {
|
|
587
|
+
var _this = this;
|
|
588
|
+
var variableValues = originalRequest.variables;
|
|
587
589
|
var fragments = Object.create(null);
|
|
590
|
+
var operations = [];
|
|
591
|
+
originalRequest.document.definitions.forEach(function (def) {
|
|
592
|
+
if (def.kind === graphql.Kind.OPERATION_DEFINITION) {
|
|
593
|
+
operations.push(def);
|
|
594
|
+
}
|
|
595
|
+
else {
|
|
596
|
+
fragments[def.name.value] = def;
|
|
597
|
+
}
|
|
598
|
+
});
|
|
599
|
+
operations.forEach(function (def) {
|
|
600
|
+
var variableDefs = def.variableDefinitions;
|
|
601
|
+
if (variableDefs != null) {
|
|
602
|
+
variableDefs.forEach(function (variableDef) {
|
|
603
|
+
var varName = variableDef.variable.name.value;
|
|
604
|
+
// requirement for 'as NamedTypeNode' appears to be a bug within types, as function should take any TypeNode
|
|
605
|
+
var varType = graphql.typeFromAST(delegationContext.transformedSchema, variableDef.type);
|
|
606
|
+
variableValues[varName] = utils.transformInputValue(varType, variableValues[varName], undefined, function (type, originalValue) {
|
|
607
|
+
var newValue = Object.create(null);
|
|
608
|
+
var fields = type.getFields();
|
|
609
|
+
Object.keys(originalValue).forEach(function (key) {
|
|
610
|
+
var _a;
|
|
611
|
+
var field = fields[key];
|
|
612
|
+
if (field != null) {
|
|
613
|
+
var newFieldName = (_a = _this.mapping[type.name]) === null || _a === void 0 ? void 0 : _a[field.name];
|
|
614
|
+
if (newFieldName != null) {
|
|
615
|
+
newValue[newFieldName] = originalValue[field.name];
|
|
616
|
+
}
|
|
617
|
+
else {
|
|
618
|
+
newValue[field.name] = originalValue[field.name];
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
});
|
|
622
|
+
return newValue;
|
|
623
|
+
});
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
});
|
|
588
627
|
originalRequest.document.definitions
|
|
589
628
|
.filter(function (def) { return def.kind === graphql.Kind.FRAGMENT_DEFINITION; })
|
|
590
629
|
.forEach(function (def) {
|
|
591
630
|
fragments[def.name.value] = def;
|
|
592
631
|
});
|
|
593
632
|
var document = this.transformDocument(originalRequest.document, this.mapping, this.inputFieldNodeTransformer, this.inputObjectNodeTransformer, originalRequest, delegationContext);
|
|
594
|
-
return tslib.__assign(tslib.__assign({}, originalRequest), { document: document });
|
|
633
|
+
return tslib.__assign(tslib.__assign({}, originalRequest), { document: document, variables: variableValues });
|
|
595
634
|
};
|
|
596
635
|
TransformInputObjectFields.prototype.transformDocument = function (document, mapping, inputFieldNodeTransformer, inputObjectNodeTransformer, request, delegationContext) {
|
|
597
636
|
var _a;
|