From 093678bcdc9c395353680f275025e65d21991fbf Mon Sep 17 00:00:00 2001 From: Christoph Zwerschke Date: Sat, 7 Sep 2024 19:47:32 +0200 Subject: [PATCH] Fix value coercion check for OneOf type --- src/utilities/coerceInputValue.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/utilities/coerceInputValue.ts b/src/utilities/coerceInputValue.ts index 7b3a61926c..29260b4327 100644 --- a/src/utilities/coerceInputValue.ts +++ b/src/utilities/coerceInputValue.ts @@ -153,16 +153,16 @@ function coerceInputValueImpl( `Exactly one key must be specified for OneOf type "${type}".`, ), ); - } - - const key = keys[0]; - const value = coercedValue[key]; - if (value === null) { - onError( - pathToArray(path).concat(key), - value, - new GraphQLError(`Field "${key}" must be non-null.`), - ); + } else { + const key = keys[0]; + const value = coercedValue[key]; + if (value === null) { + onError( + pathToArray(path).concat(key), + value, + new GraphQLError(`Field "${key}" must be non-null.`), + ); + } } }