graphql-core icon indicating copy to clipboard operation
graphql-core copied to clipboard

When enum is used as argument, its default value is not validated against enum definition

Open rafalp opened this issue 4 years ago • 2 comments

Hello!

While working on enum support in Ariadne I've found that enums values aren't validated against GraphQL enum when they are defined as fields on GraphQL schema.

Following schema passes validation:

enum Role {
  ADMIN
  USER
}

type Query {
  hello(r: Role = ADMIN): String
  complex(i: Test = { role: INVALID }): String
  complexAlt(i: Test): String
}

input Test {
  ignore: String
  role: Role = INVALID
}

I would've expected schema validators to raise INVALID, but instead those fields are quietly excluded from default value passed to field's resolver.

rafalp avatar Mar 02 '21 22:03 rafalp

Thanks for reporting. GraphQL.js behaves the same, so I passed this question on.

Cito avatar Mar 03 '21 18:03 Cito