gqlgen generates non compilable federation.go code when schema uses @requires directive with attribute referring inside array for dependency
- 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?
gqlgen generates non compilable code when schema has uses @requires directive with array nested attribute dependency for federation. in **federation.go** file i.e. see the sample schema that is mentioned below
### What did you expect?
It should generate compilable code
### Minimal graphql.schema and models to reproduce
```
type Query {
reviews(bookID: ID!): [Review]
}
type Book @key(fields: "id", resolvable: false ) {
id: ID! @external
publishers:[Publishers] @external
reviews: [Review] @requires(fields: "publishers {name}" )
}
type Publishers @key(fields: "id", resolvable: false) {
id: ID! @external
name: String @external
}
type Review @key(fields: "id") {
id: ID! @external
name: String
}
```
### versions
- `go run github.com/99designs/gqlgen version`? v0.17.31
- `go version`? go1.20.3 darwin/amd64
if you try to run ----
`it will generate error validation failed: packages.Load: /graph/generated/federation.go:100 : 23: entity.Publishers.Name undefined (type []*model.Publishers has no field or method Name)`
on this line in **federation.go** file
`entity.Publishers.Name, err = ec.unmarshalOString2ᚖstring(ctx, rep["publishers"].(map[string]interface{})["name"])`
This is because Publishers.Name is incorrect ... Publishers is array
Hướng dẫn đóng góp
Đánh giá
Issue này chưa được đánh giá.