-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UInt fields now always require to write a getter resolver #2550
Comments
Hi @mdestagnol, can you provide code example of your issue? |
Can you also verify if your scenario is not covered in the scalars example nor in the integration tests? |
I confirm I don't think it is |
Can you provide an example of your One thing I am thinking of, does your model have a property as uint, and in your Example: // Go
type MyObject struct {
AttributeOne uint `json:"attributeOne"`
} # GraphQL
type MyObject {
attributeOne Int!
} |
@mdestagnol Any follow up on your side? |
I believe I'm encountering the same issue, after upgrading from 0.17.1 to 0.17.24. The following was working correctly in 0.17.1. # gqlgen.yaml
models:
Uint:
model:
- github.com/99designs/gqlgen/graphql.Uint32
- github.com/99designs/gqlgen/graphql.Uint
- github.com/99designs/gqlgen/graphql.Uint64 # schema.graphqls
scalar Uint
type PagedList {
totalCount: Uint!
pageNumber: Uint!
pageSize: Uint!
items: [Item!]!
}
type Query{
tableItems: PagedList!
}
In the new version, a func (r *pagedListResolver) TotalCount(ctx context.Context, obj *model.PagedList) (uint32, error) {
panic(fmt.Errorf("not implemented: TotalCount - totalCount"))
}
// etc... |
Further investigation shows the version that introduces the new behavior is 0.17.23. |
@ryan-lang The change was to not need a scalar for For your code, are you able to detect what fields are uint and uint32, and put them as Int in your graphqls file? Also remove them from gqlgen.yaml under model of scalar Uint. Let me know if it works: ex: # gqlgen.yaml
models:
Uint:
model:
- github.com/99designs/gqlgen/graphql.Uint64 # schema.graphqls
scalar Uint
type PagedList {
totalCount: Uint!
pageNumber: Int!
pageSize: Int!
items: [Item!]!
}
type Query{
tableItems: PagedList!
} |
Thank you, I think I understand. So it sounds like this change breaks the ability to have generated models with uint32 fields? It seems with your suggested change, modelgen will always build PageNumber and PageSize as plain int fields in the generated go code, precluding any use of uint32 values, unless I explicitly define & bind a PagedList struct. |
I confirmed that the issue has been resolved by migrating from version 0.17.24 to 0.17.30. |
The behavior is a regression between 0.17.22 and 0.17.24.
On 0.17.24, everytime an object contain an UInt, that field requires to write a resolver getter (even though I have a custom marshaller) or it triggers the following error:
UInt is incompatible with uint
orID is incompatible with uint
On 0.17.22, it was able to figure it out.
The scalar are pointing to the following custom marshaller I have for UInt:
The text was updated successfully, but these errors were encountered: