@wundergraph/composition 0.55.1 → 0.56.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.
@@ -107,6 +107,27 @@ class NormalizationFactory {
107
107
  operationTypes: new Map(),
108
108
  };
109
109
  }
110
+ sanitizeDefaultValue({ data, namedTypeData, node }) {
111
+ if (!data.defaultValue) {
112
+ return;
113
+ }
114
+ if (!(0, utils_4.isEnumData)(namedTypeData)) {
115
+ return;
116
+ }
117
+ data.defaultValue = (0, graphql_1.visit)(data.defaultValue, {
118
+ StringValue: {
119
+ enter(node) {
120
+ return {
121
+ kind: graphql_1.Kind.ENUM,
122
+ value: node.value,
123
+ };
124
+ },
125
+ },
126
+ });
127
+ if (node) {
128
+ node.defaultValue = data.defaultValue;
129
+ }
130
+ }
110
131
  validateArguments(fieldData, parentKind) {
111
132
  for (const argumentData of fieldData.argumentDataByName.values()) {
112
133
  const namedTypeName = (0, ast_1.getTypeNodeNamedTypeName)(argumentData.type);
@@ -121,6 +142,7 @@ class NormalizationFactory {
121
142
  }
122
143
  if ((0, utils_4.isInputNodeKind)(namedTypeData.kind)) {
123
144
  argumentData.namedTypeKind = namedTypeData.kind;
145
+ this.sanitizeDefaultValue({ data: argumentData, namedTypeData, node: argumentData.node });
124
146
  continue;
125
147
  }
126
148
  this.errors.push((0, errors_1.invalidNamedTypeError)({
@@ -194,7 +216,7 @@ class NormalizationFactory {
194
216
  return true;
195
217
  }
196
218
  if (parentData.kind === graphql_1.Kind.ENUM_TYPE_DEFINITION) {
197
- if (argumentValue.kind !== graphql_1.Kind.ENUM) {
219
+ if (argumentValue.kind !== graphql_1.Kind.ENUM && argumentValue.kind !== graphql_1.Kind.STRING) {
198
220
  return false;
199
221
  }
200
222
  const enumValue = parentData.enumValueDataByName.get(argumentValue.value);
@@ -406,6 +428,21 @@ class NormalizationFactory {
406
428
  }
407
429
  }
408
430
  const requiredArgumentNames = [...definitionData.requiredArgumentNames];
431
+ for (const argumentNode of definitionData.node.arguments ?? []) {
432
+ if (!argumentNode.defaultValue) {
433
+ continue;
434
+ }
435
+ const argumentData = definitionData.argumentTypeNodeByName.get(argumentNode.name.value);
436
+ if (!argumentData) {
437
+ continue;
438
+ }
439
+ const namedTypeData = this.parentDefinitionDataByTypeName.get((0, ast_1.getTypeNodeNamedTypeName)(argumentData.typeNode));
440
+ // Undefined types are handled elsewhere
441
+ if (!namedTypeData) {
442
+ continue;
443
+ }
444
+ this.sanitizeDefaultValue({ data: argumentData, namedTypeData, node: argumentNode });
445
+ }
409
446
  for (let i = 0; i < directiveNodes.length; i++) {
410
447
  const errorMessages = this.validateDirective({
411
448
  data,
@@ -2943,9 +2980,10 @@ class NormalizationFactory {
2943
2980
  }
2944
2981
  const namedTypeData = this.parentDefinitionDataByTypeName.get(valueData.namedTypeName);
2945
2982
  if (!namedTypeData) {
2946
- // undefined types are handled elsewhere
2983
+ // Undefined types are handled elsewhere
2947
2984
  continue;
2948
2985
  }
2986
+ this.sanitizeDefaultValue({ data: valueData, namedTypeData, node: valueData.node });
2949
2987
  if (!(0, utils_4.isInputNodeKind)(namedTypeData.kind)) {
2950
2988
  this.errors.push((0, errors_1.invalidNamedTypeError)({
2951
2989
  data: valueData,