GraphQL interfaces not unmarshaled by the test client
- 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?
I got an error when decoding a response for a type with an interface property using the test client.
### What did you expect?
I expected it to work, handling the parsing of an interface to the corresponding type.
### Minimal graphql.schema and models to reproduce
Schema and model.
```graphql
type Example {
foo: FooInterface
}
type FooInterface {
version: String!
}
type FooInterfaceV1 {
version: String!
someField: String!
}
extend type Query {
getExample(): Example!
}
```
Query.
```graphql
query {
getExample() {
foo: {
__typename
... on FooInterfaceV1 {
someField
}
}
}
}
```
Error `'getExample.someField' expected type 'FooInterface', got 'map[string]interface {}'`
This is caused by the interface being generated as a `interface{}` which with JSON (and I assume map structure) will be parsed as `map[string]interface{}`. There's no custom unmarshaling generated to properly support interfaces it seems.
### versions
- `go run github.com/99designs/gqlgen version` - v0.17.20
- `go version` - go version go1.19.3 darwin/amd64
Hướng dẫn đóng góp
Đánh giá
Issue này chưa được đánh giá.