gqlgen generates non compilable code when schema has Entity interfaces
- Dominant language
- Go
- Stars
- 10.8k
- Forks
- 1.3k
- Avg merge
- 2d 36m
- Merged PRs (30d)
- 26
Description
### What happened?
gqlgen generates non compilable code when schema has [Entity interfaces](https://www.apollographql.com/docs/federation/federated-types/interfaces/).
I've noticed this after trying to upgrade gqlgen from `v0.17.31` -> `v0.17.34`
### What did you expect?
It should generate compilable code
### Minimal graphql.schema and models to reproduce
```graphql
interface User @key(fields: "id") {
id: ID!
name: String!
email: String!
}
type Customer implements User @key(fields: "id") {
id: ID!
name: String!
email: String!
}
extend type Query {
me: User!
}
```
gqlgen is generating this model for the interface, but it doesn't implement the `fedruntime.Entity` interface.
```go
type User interface {
IsUser()
GetID() string
GetName() string
GetEmail() string
}
```
### versions
- `go run github.com/99designs/gqlgen version`? `v0.17.34`
- `go version go1.20.5 darwin/arm64`
Contributor guide
Research direction
The issue is in the code generation for GraphQL interfaces with Apollo Federation's @key directive. Look at the gqlgen code generation logic, likely in the plugin or model generation packages, where interfaces are processed. The generated User interface must also implement fedruntime.Entity. Check existing tests for federation or entity generation to understand the expected output and add a test case for this schema.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, graphql
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100