Skip to content

Scalar query parameter treated as int32 #305

@airomega

Description

@airomega

I have an ID that's been generated using Go's Hash32 func

I ran into an issue using the Int type in my schema discovered that uint32 is not supported as Int in Graphql

I introduced a Uint scalar thanks to this post and updated my schema:

type User{
    hash: Uint!
    forename: String
    surname: String
    email: String!
}

scalar Uint

schema {
  query: Query
}

type Query {
  user(hash: Uint!): user
}

When I run the query
{ user(hash: 3626262620) { forename } }

I get the following error:
"message": "graphql: panic occurred: strconv.ParseInt: parsing "3111942731": value out of range"

The error is being thown here after applySelectionSet

I'm hoping that I've made a mistake. However it looks like all integer numbers passed in a query parameter will be treated as an int of size 32 - the surrounding switch uses scanner.Int as a case but has no check on size.

I understand the graphql spec treats Int as a 32 bit int - however this seems like a bug on queries/scalars? Or am I doing something wrong?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions