Skip to content

Commit af39391

Browse files
committed
improve error handling on input objects
1 parent d930749 commit af39391

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Utilities/InputValues.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,12 @@ static function coerceInputValue($inputValue, GraphQLType $type, $path = [])
7676
continue;
7777
}
7878

79-
$coercedValue[$field->getName()] = self::coerceInputValue($fieldValue, $field->getType(), [$path, $field->getName(), $type->getName()]);
79+
try {
80+
$coercedValue[$field->getName()] = self::coerceInputValue($fieldValue, $field->getType(), [$path, $field->getName(), $type->getName()]);
81+
} catch (GraphQLError $error) {
82+
// add information about explicit field name of input object type when coersion failed.
83+
throw new GraphQLError("Coercing value of \"{$field->getName()}\" failed explicity. " . $error->getMessage());
84+
}
8085
}
8186

8287
// ensure every provided field is defined

0 commit comments

Comments
 (0)