作者:北漂123 | 来源:互联网 | 2023-08-17 19:58
When we generate a schema with underscore within field names, the gqlgen is including it as resolver.
Expected Behaviour
Generate a field in User model with name MyNumber and type *int`.
Actual Behavior
1 2 3 4 5 6
| go
type userResolver struct{ *Resolver }
func (r *userResolver) MyNumber(ctx context.Context, obj *User) (*int, error) {
panic("not implemented")
} |
Minimal graphql.schema and models to reproduce
1 2 3 4 5 6 7 8
| graphql
type Query {
user(): User
}
type User {
my_number: Int
} |
该提问来源于开源项目:99designs/gqlgen
I tried to debug it yesterday, but I don't found where it was checked. I will try to open a PR today, do you have some suspect about the issue?
I notice that fields settings on gqlgen.yml solves the problem when the name was informed directly. Ex:
1 2 3 4 5 6
| yml
User:
model: github.com/foo/bar/models.User
fields:
my_number:
fieldName: MyNumber |