@graphql-tools/wrap 7.0.5-alpha-bacafb47.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/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@graphql-tools/wrap/es5",
3
- "version": "7.0.5-alpha-bacafb47.0",
3
+ "version": "7.0.5",
4
4
  "description": "A set of utils for faster development of GraphQL tools",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
7
7
  "graphql": "^14.0.0 || ^15.0.0"
8
8
  },
9
9
  "dependencies": {
10
- "@graphql-tools/delegate": "7.0.9-alpha-bacafb47.0",
11
- "@graphql-tools/schema": "7.2.0-alpha-bacafb47.0",
12
- "@graphql-tools/utils": "^7.1.4",
10
+ "@graphql-tools/delegate": "^7.0.7",
11
+ "@graphql-tools/schema": "^7.1.2",
12
+ "@graphql-tools/utils": "^7.2.1",
13
13
  "is-promise": "4.0.0",
14
14
  "tslib": "~2.0.1"
15
15
  },
@@ -10,6 +10,6 @@ export default class TransformInputObjectFields implements Transform {
10
10
  private mapping;
11
11
  constructor(inputFieldTransformer: InputFieldTransformer, inputFieldNodeTransformer?: InputFieldNodeTransformer, inputObjectNodeTransformer?: InputObjectNodeTransformer);
12
12
  transformSchema(originalWrappingSchema: GraphQLSchema, _subschemaConfig: SubschemaConfig, _transformedSchema?: GraphQLSchema): GraphQLSchema;
13
- transformRequest(originalRequest: Request, delegationContext: DelegationContext, _transformationContextד: Record<string, any>): Request;
13
+ transformRequest(originalRequest: Request, delegationContext: DelegationContext, _transformationContext: Record<string, any>): Request;
14
14
  private transformDocument;
15
15
  }
package/index.cjs.js CHANGED
@@ -565,8 +565,46 @@ class TransformInputObjectFields {
565
565
  });
566
566
  return this.transformedSchema;
567
567
  }
568
- transformRequest(originalRequest, delegationContext, _transformationContextד) {
568
+ transformRequest(originalRequest, delegationContext, _transformationContext) {
569
+ const variableValues = originalRequest.variables;
569
570
  const fragments = Object.create(null);
571
+ const operations = [];
572
+ originalRequest.document.definitions.forEach(def => {
573
+ if (def.kind === graphql.Kind.OPERATION_DEFINITION) {
574
+ operations.push(def);
575
+ }
576
+ else {
577
+ fragments[def.name.value] = def;
578
+ }
579
+ });
580
+ operations.forEach(def => {
581
+ const variableDefs = def.variableDefinitions;
582
+ if (variableDefs != null) {
583
+ variableDefs.forEach(variableDef => {
584
+ const varName = variableDef.variable.name.value;
585
+ // requirement for 'as NamedTypeNode' appears to be a bug within types, as function should take any TypeNode
586
+ const varType = graphql.typeFromAST(delegationContext.transformedSchema, variableDef.type);
587
+ variableValues[varName] = utils.transformInputValue(varType, variableValues[varName], undefined, (type, originalValue) => {
588
+ const newValue = Object.create(null);
589
+ const fields = type.getFields();
590
+ Object.keys(originalValue).forEach(key => {
591
+ var _a;
592
+ const field = fields[key];
593
+ if (field != null) {
594
+ const newFieldName = (_a = this.mapping[type.name]) === null || _a === void 0 ? void 0 : _a[field.name];
595
+ if (newFieldName != null) {
596
+ newValue[newFieldName] = originalValue[field.name];
597
+ }
598
+ else {
599
+ newValue[field.name] = originalValue[field.name];
600
+ }
601
+ }
602
+ });
603
+ return newValue;
604
+ });
605
+ });
606
+ }
607
+ });
570
608
  originalRequest.document.definitions
571
609
  .filter(def => def.kind === graphql.Kind.FRAGMENT_DEFINITION)
572
610
  .forEach(def => {
@@ -576,6 +614,7 @@ class TransformInputObjectFields {
576
614
  return {
577
615
  ...originalRequest,
578
616
  document,
617
+ variables: variableValues,
579
618
  };
580
619
  }
581
620
  transformDocument(document, mapping, inputFieldNodeTransformer, inputObjectNodeTransformer, request, delegationContext) {