gqlgen icon indicating copy to clipboard operation
gqlgen copied to clipboard

Return null if invalid enum is encountered

Open blmhemu opened this issue 2 years ago • 3 comments

Describe your PR and link to any relevant issues.

In the current scenario, invalid enums are propagated to the client. This PR sends a null instead - while the graphql spec insists on returning a type error, I found this to be less breaking.

I have:

  • [ ] Added tests covering the bug / feature (see testing)
  • [ ] Updated any relevant documentation (see docs)

blmhemu avatar Dec 18 '23 09:12 blmhemu

Hi @StevenACoffman (Sorry if I tagged the wrong person) and gqlgen team, Wanted to gather information / comments on this topic, before I do full on implementation.

blmhemu avatar Dec 18 '23 15:12 blmhemu

Hey, so breaking compatibility with the GraphQL spec is not something most people will want, so I would want to only enable this behavior with a config option and have it default to off.

That said, I'm not sure it is even a common enough desire to add this PR.

StevenACoffman avatar Dec 20 '23 18:12 StevenACoffman

Coverage Status

coverage: 79.4% (+0.2%) from 79.153% when pulling 27ca2fc92df8425c6c159f494d8340e69982d1f3 on blmhemu:fix-invalid-enum into 7dd971c871c0b0159ad26c9bf3095a8ba3780402 on 99designs:master.

coveralls avatar Dec 20 '23 18:12 coveralls