Skip to content
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

Returning a uint in a Resolve function for a GraphQLNonNull(GraphQLInt) field responds with 0 #22

Closed
bbuck opened this issue Oct 15, 2015 · 0 comments · Fixed by #83
Closed
Labels

Comments

@bbuck
Copy link
Collaborator

bbuck commented Oct 15, 2015

I have a simple test server set up to run off todos in a database. I'm using the gorm ORM and it's default gorm.Model that defines common fields for models. One of which happens to be the ID field which is of type uint.

todoType := graphql.NewObject(graphql.ObjectConfig{
        Name: "Todo",
        Fields: types.Fields{
                "id": &types.Field{
                        Type: graphql.NewNonNull(graphql.Int),
                        Resolve: func(params graphql.ResolveParams) (interface{}, error) {
                                todo := params.Source.(*data.Todo)

                                return todo.ID
                        },
                },
                // Shortened for brevity
        },
})

When I make a query to this, I get back "id": 0 for all records. If I change the return to int(todo.ID) then I get back the expected ID value.

It appears the reason is that coerceInt does not support the uint type. Also missing are int8, int16, int32, int64, and the uint series as well. When I get the opportunity I'll see about making a pull request to address this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants