@graphql-tools/wrap 9.2.20 → 9.2.21

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.
@@ -22,13 +22,13 @@ class MapLeafValues {
22
22
  this.typeInfo = new graphql_1.TypeInfo(originalWrappingSchema);
23
23
  return originalWrappingSchema;
24
24
  }
25
- transformRequest(originalRequest, _delegationContext, transformationContext) {
25
+ transformRequest(originalRequest, delegationContext, transformationContext) {
26
26
  var _a;
27
27
  const document = originalRequest.document;
28
28
  const variableValues = (_a = originalRequest.variables) !== null && _a !== void 0 ? _a : {};
29
29
  const operations = document.definitions.filter(def => def.kind === graphql_1.Kind.OPERATION_DEFINITION);
30
30
  const fragments = document.definitions.filter(def => def.kind === graphql_1.Kind.FRAGMENT_DEFINITION);
31
- const newOperations = this.transformOperations(operations, variableValues);
31
+ const newOperations = this.transformOperations(operations, variableValues, delegationContext.args);
32
32
  const transformedRequest = {
33
33
  ...originalRequest,
34
34
  document: {
@@ -46,17 +46,17 @@ class MapLeafValues {
46
46
  }
47
47
  return (0, utils_1.visitResult)(originalResult, transformationContext.transformedRequest, this.originalWrappingSchema, this.resultVisitorMap);
48
48
  }
49
- transformOperations(operations, variableValues) {
49
+ transformOperations(operations, variableValues, args) {
50
50
  if (this.typeInfo == null) {
51
51
  throw new Error(`The MapLeafValues transform's "transformRequest" and "transformResult" methods cannot be used without first calling "transformSchema".`);
52
52
  }
53
53
  return operations.map((operation) => {
54
54
  return (0, graphql_1.visit)(operation, (0, graphql_1.visitWithTypeInfo)(this.typeInfo, {
55
- [graphql_1.Kind.FIELD]: node => this.transformFieldNode(node, variableValues),
55
+ [graphql_1.Kind.FIELD]: node => this.transformFieldNode(node, variableValues, args),
56
56
  }));
57
57
  });
58
58
  }
59
- transformFieldNode(field, variableValues) {
59
+ transformFieldNode(field, variableValues, args) {
60
60
  if (this.typeInfo == null) {
61
61
  throw new Error(`The MapLeafValues transform's "transformRequest" and "transformResult" methods cannot be used without first calling "transformSchema".`);
62
62
  }
@@ -74,9 +74,15 @@ class MapLeafValues {
74
74
  for (const argument of targetField.args) {
75
75
  const argName = argument.name;
76
76
  const argType = argument.type;
77
+ if ((args === null || args === void 0 ? void 0 : args[argName]) != null) {
78
+ args[argName] = (0, utils_1.transformInputValue)(argType, args[argName], (t, v) => {
79
+ const newValue = this.inputValueTransformer(t.name, v);
80
+ return newValue === undefined ? v : newValue;
81
+ });
82
+ }
77
83
  const argumentNode = argumentNodeMap[argName];
78
- const argValue = argumentNode === null || argumentNode === void 0 ? void 0 : argumentNode.value;
79
84
  let value;
85
+ const argValue = argumentNode === null || argumentNode === void 0 ? void 0 : argumentNode.value;
80
86
  if (argValue != null) {
81
87
  value = (0, graphql_1.valueFromAST)(argValue, argType, variableValues);
82
88
  if (value == null) {
@@ -20,13 +20,13 @@ export default class MapLeafValues {
20
20
  this.typeInfo = new TypeInfo(originalWrappingSchema);
21
21
  return originalWrappingSchema;
22
22
  }
23
- transformRequest(originalRequest, _delegationContext, transformationContext) {
23
+ transformRequest(originalRequest, delegationContext, transformationContext) {
24
24
  var _a;
25
25
  const document = originalRequest.document;
26
26
  const variableValues = (_a = originalRequest.variables) !== null && _a !== void 0 ? _a : {};
27
27
  const operations = document.definitions.filter(def => def.kind === Kind.OPERATION_DEFINITION);
28
28
  const fragments = document.definitions.filter(def => def.kind === Kind.FRAGMENT_DEFINITION);
29
- const newOperations = this.transformOperations(operations, variableValues);
29
+ const newOperations = this.transformOperations(operations, variableValues, delegationContext.args);
30
30
  const transformedRequest = {
31
31
  ...originalRequest,
32
32
  document: {
@@ -44,17 +44,17 @@ export default class MapLeafValues {
44
44
  }
45
45
  return visitResult(originalResult, transformationContext.transformedRequest, this.originalWrappingSchema, this.resultVisitorMap);
46
46
  }
47
- transformOperations(operations, variableValues) {
47
+ transformOperations(operations, variableValues, args) {
48
48
  if (this.typeInfo == null) {
49
49
  throw new Error(`The MapLeafValues transform's "transformRequest" and "transformResult" methods cannot be used without first calling "transformSchema".`);
50
50
  }
51
51
  return operations.map((operation) => {
52
52
  return visit(operation, visitWithTypeInfo(this.typeInfo, {
53
- [Kind.FIELD]: node => this.transformFieldNode(node, variableValues),
53
+ [Kind.FIELD]: node => this.transformFieldNode(node, variableValues, args),
54
54
  }));
55
55
  });
56
56
  }
57
- transformFieldNode(field, variableValues) {
57
+ transformFieldNode(field, variableValues, args) {
58
58
  if (this.typeInfo == null) {
59
59
  throw new Error(`The MapLeafValues transform's "transformRequest" and "transformResult" methods cannot be used without first calling "transformSchema".`);
60
60
  }
@@ -72,9 +72,15 @@ export default class MapLeafValues {
72
72
  for (const argument of targetField.args) {
73
73
  const argName = argument.name;
74
74
  const argType = argument.type;
75
+ if ((args === null || args === void 0 ? void 0 : args[argName]) != null) {
76
+ args[argName] = transformInputValue(argType, args[argName], (t, v) => {
77
+ const newValue = this.inputValueTransformer(t.name, v);
78
+ return newValue === undefined ? v : newValue;
79
+ });
80
+ }
75
81
  const argumentNode = argumentNodeMap[argName];
76
- const argValue = argumentNode === null || argumentNode === void 0 ? void 0 : argumentNode.value;
77
82
  let value;
83
+ const argValue = argumentNode === null || argumentNode === void 0 ? void 0 : argumentNode.value;
78
84
  if (argValue != null) {
79
85
  value = valueFromAST(argValue, argType, variableValues);
80
86
  if (value == null) {
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@graphql-tools/wrap",
3
- "version": "9.2.20",
3
+ "version": "9.2.21",
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 || ^16.0.0 || ^17.0.0"
8
8
  },
9
9
  "dependencies": {
10
- "@graphql-tools/delegate": "9.0.19",
10
+ "@graphql-tools/delegate": "9.0.20",
11
11
  "@graphql-tools/schema": "9.0.12",
12
12
  "@graphql-tools/utils": "9.1.3",
13
13
  "tslib": "^2.4.0",
@@ -13,7 +13,7 @@ export default class MapLeafValues<TContext = Record<string, any>> implements Tr
13
13
  constructor(inputValueTransformer: LeafValueTransformer, outputValueTransformer: LeafValueTransformer);
14
14
  private originalWrappingSchema?;
15
15
  transformSchema(originalWrappingSchema: GraphQLSchema, _subschemaConfig: SubschemaConfig<any, any, any, TContext>): GraphQLSchema;
16
- transformRequest(originalRequest: ExecutionRequest, _delegationContext: DelegationContext<TContext>, transformationContext: MapLeafValuesTransformationContext): ExecutionRequest;
16
+ transformRequest(originalRequest: ExecutionRequest, delegationContext: DelegationContext<TContext>, transformationContext: MapLeafValuesTransformationContext): ExecutionRequest;
17
17
  transformResult(originalResult: ExecutionResult, _delegationContext: DelegationContext<TContext>, transformationContext: MapLeafValuesTransformationContext): ExecutionResult;
18
18
  private transformOperations;
19
19
  private transformFieldNode;
@@ -13,7 +13,7 @@ export default class MapLeafValues<TContext = Record<string, any>> implements Tr
13
13
  constructor(inputValueTransformer: LeafValueTransformer, outputValueTransformer: LeafValueTransformer);
14
14
  private originalWrappingSchema?;
15
15
  transformSchema(originalWrappingSchema: GraphQLSchema, _subschemaConfig: SubschemaConfig<any, any, any, TContext>): GraphQLSchema;
16
- transformRequest(originalRequest: ExecutionRequest, _delegationContext: DelegationContext<TContext>, transformationContext: MapLeafValuesTransformationContext): ExecutionRequest;
16
+ transformRequest(originalRequest: ExecutionRequest, delegationContext: DelegationContext<TContext>, transformationContext: MapLeafValuesTransformationContext): ExecutionRequest;
17
17
  transformResult(originalResult: ExecutionResult, _delegationContext: DelegationContext<TContext>, transformationContext: MapLeafValuesTransformationContext): ExecutionResult;
18
18
  private transformOperations;
19
19
  private transformFieldNode;