From c343454488e6e5af7ae50f7a8d988396f2e726cb Mon Sep 17 00:00:00 2001 From: jdecroock Date: Thu, 1 Feb 2024 10:54:20 +0100 Subject: [PATCH] remove unused code, TODO: double check whether we deleted crucial branches --- src/execution/values.ts | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/src/execution/values.ts b/src/execution/values.ts index 4565922670c..c393c3c7f43 100644 --- a/src/execution/values.ts +++ b/src/execution/values.ts @@ -160,7 +160,7 @@ function coerceVariableValues( */ export function getArgumentValues( node: FieldNode | DirectiveNode, - argDefs: ReadonlyArray | undefined, + argDefs: ReadonlyArray, variableValues: Maybe>, fragmentArgValues?: Maybe>, ): { [argument: string]: unknown } { @@ -169,7 +169,7 @@ export function getArgumentValues( node.arguments?.map((arg) => [arg.name.value, arg]), ); - for (const argDef of argDefs ?? []) { + for (const argDef of argDefs) { const name = argDef.name; const argType = argDef.type; const argumentNode = argNodeMap.get(name); @@ -291,27 +291,12 @@ export function getArgumentValuesFromSpread( Object.hasOwn(fragmentArgValues, variableName) ) { hasValue = fragmentArgValues[variableName] != null; - if (!hasValue && varDef.defaultValue !== undefined) { - coercedValues[name] = valueFromASTUntyped(varDef.defaultValue); - continue; - } + } else if ( variableValues != null && Object.hasOwn(variableValues, variableName) ) { hasValue = variableValues[variableName] != null; - } else if (varDef.defaultValue !== undefined) { - coercedValues[name] = valueFromASTUntyped(varDef.defaultValue); - continue; - } else if (isNonNullType(argType)) { - throw new GraphQLError( - `Argument "${name}" of required type "${inspect(argType)}" ` + - `was provided the variable "$${variableName}" which was not provided a runtime value.`, - { nodes: valueNode }, - ); - } else { - coercedValues[name] = undefined; - hasValue = false; } } @@ -332,15 +317,6 @@ export function getArgumentValuesFromSpread( }); } - if (coercedValue === undefined) { - // Note: ValuesOfCorrectTypeRule validation should catch this before - // execution. This is a runtime check to ensure execution does not - // continue with an invalid argument value. - throw new GraphQLError( - `Argument "${name}" has invalid value ${print(valueNode)}.`, - { nodes: valueNode }, - ); - } coercedValues[name] = coercedValue; } return coercedValues;