ENUM types allow returning values other than the specified values
- Dominant language
- Go
- Stars
- 10.8k
- Forks
- 1.3k
- Avg merge
- 2d 36m
- Merged PRs (30d)
- 26
Description
### What happened?
The server allows returning values for enums that aren't in the listed values for the enum types.
### What did you expect?
Spec doesn't allow this https://spec.graphql.org/June2018/#sec-Enums -> Result Coercion:
"GraphQL services must return one of the defined set of possible values. If a reasonable coercion is not possible they must raise a field error."
### Minimal graphql.schema and models to reproduce
Add an enum to the default schema
```graphql
type Todo {
...
type: TodoType!
}
enum TodoType {
WORK
PLAY
}
```
With resolver
```go
func (r *todoResolver) Type(ctx context.Context, obj *model.Todo) (model.TodoType, error) {
return model.TodoType("rubbish"), nil
}
```
### versions
- `gqlgen version` : 0.13.0
- `go version` : go version go1.13.15 darwin/amd64
- dep or go modules : modules
Contributor guide
Assessment
This issue has not been assessed yet.