99designs / 99designs/gqlgen

ENUM types allow returning values other than the specified values

Đang mở
#1,467 4 bình luận 4 reaction 1 người được giao Được @MichaelJCompton nhận Xem trên GitHub
bug
Ngôn ngữ chính
Go
Star
10.8k
Fork
1.3k
Merge trung bình
2 ngày 36 phút
Pull request đã merge (30 ngày)
26

Mô tả

### 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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.