From 6c2cde65e63a4362ef97bc09b3b23eef394fe6ea Mon Sep 17 00:00:00 2001 From: Yaacov Rydzinski Date: Fri, 18 Oct 2024 11:19:31 +0300 Subject: [PATCH] final polishes? --- src/execution/values.ts | 3 ++- src/utilities/coerceInputValue.ts | 2 +- src/utilities/validateInputValue.ts | 10 +++------- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/execution/values.ts b/src/execution/values.ts index bd1ee99774..ed869e10bd 100644 --- a/src/execution/values.ts +++ b/src/execution/values.ts @@ -245,7 +245,8 @@ export function experimentalGetArgumentValues( ? fragmentVariableValues : variableValues; if ( - scopedVariableValues?.coerced[variableName] === undefined && + (scopedVariableValues == null || + !Object.hasOwn(scopedVariableValues.coerced, variableName)) && !isRequiredArgument(argDef) ) { if (argDef.defaultValue) { diff --git a/src/utilities/coerceInputValue.ts b/src/utilities/coerceInputValue.ts index dd8cef953a..903733d967 100644 --- a/src/utilities/coerceInputValue.ts +++ b/src/utilities/coerceInputValue.ts @@ -272,7 +272,7 @@ export function coerceInputLiteral( const leafType = assertLeafType(type); try { - return leafType.coerceInputLiteral !== undefined + return leafType.coerceInputLiteral ? leafType.coerceInputLiteral( replaceVariables(valueNode, variableValues, fragmentVariableValues), ) diff --git a/src/utilities/validateInputValue.ts b/src/utilities/validateInputValue.ts index 2d2506bf9c..8f2b8480ba 100644 --- a/src/utilities/validateInputValue.ts +++ b/src/utilities/validateInputValue.ts @@ -455,13 +455,9 @@ function validateInputLiteralImpl( let result; let caughtError; try { - result = - type.coerceInputLiteral !== undefined - ? type.coerceInputLiteral( - replaceVariables(valueNode), - hideSuggestions, - ) - : type.parseLiteral(valueNode, undefined, hideSuggestions); + result = type.coerceInputLiteral + ? type.coerceInputLiteral(replaceVariables(valueNode), hideSuggestions) + : type.parseLiteral(valueNode, undefined, hideSuggestions); } catch (error) { if (error instanceof GraphQLError) { context.onError(error, pathToArray(path));