Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions bluejay-validator/src/value/input_coercion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,14 @@ fn coerce_custom_scalar_value<'a, const CONST: bool, V: Value<CONST>>(
value: &'a V,
path: Path<'a>,
) -> Result<(), Vec<Error<'a, CONST, V>>> {
if matches!(value.as_ref(), ValueReference::Enum(_)) {
return Err(vec![Error::NoImplicitConversion {
value,
input_type_name: cstd.name().to_string(),
path,
}]);
}

cstd.coerce_input(value).map_err(|message| {
vec![Error::CustomScalarInvalidValue {
value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@ Error: Object with multiple entries for field name
│ ╰─── Entry for field
────╯

Error: No implicit conversion of enum to Int
╭─[ value_is_valid.graphql:22:25 ]
22 │ intArgField(intArg: SomeEnumValue)
│ ──────┬──────
│ ╰──────── No implicit conversion to Int
────╯

Error: No implicit conversion of enum to CustomScalar
╭─[ value_is_valid.graphql:27:38 ]
27 │ customScalarField(customScalarArg: SomeEnumValue)
│ ──────┬──────
│ ╰──────── No implicit conversion to CustomScalar
────╯

Error: No implicit conversion of string to Int
╭─[ value_is_valid.graphql:2:23 ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,13 @@ query inputFieldDoesNotExist {
query duplicateInputField {
findDog(complex: { name: "Fido", name: "Fido" }) { name }
}

query enumLiteralForBuiltinScalar {
arguments {
intArgField(intArg: SomeEnumValue)
}
}

query enumLiteralForCustomScalar {
customScalarField(customScalarArg: SomeEnumValue)
}
3 changes: 3 additions & 0 deletions bluejay-validator/tests/test_data/executable/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ type Query {
oneOf(oneOfArg: OneOfInput!): String
oneOfList(oneOfListArg: [OneOfInput]!): String
nestedOneOf(nestedOneOfArg: NestedOneOfInput!): String
customScalarField(customScalarArg: CustomScalar!): String
}

scalar CustomScalar

input OneOfInput @oneOf {
oneOfField: String
anotherField: String
Expand Down