Graphql-go: Error message missing value

Created on 13 Sep 2018  路  6Comments  路  Source: graph-gophers/graphql-go

I am actually not entirely sure this is the right place to post it, so let me know if it needs to go elsewhere.

I ran into a problem where I had

func (r *Resolver) ResolverName(args *struct {
    SomeVar SomeType
}) *ResolverNameResolver {
type SomeType struct {
    UserID int32
    SomeOtherVar int32
}

The mutation struct was

type LifeBalance {
    UserID: ID!
    SomeOtherVar: Int
}

I called ResolverName with

{
  "UserID": "2",
  "SomeVar": 4
}

And instead of getting something like UserID should be int instead of string
I got Error while fetching query: Error at path "ResolverName": missingValue

I kept looking for a missing value, so it took me a while to spot the difference in type.

help wanted

All 6 comments

The problem is in UserID int32. By graphql spec ID is a string. Changing type to graphql.ID should fix your problem

Or change the schema to

type LifeBalance {
    UserID: Int!
    SomeOtherVar: Int
}

Didn't think the graphql.ID type was Postgres friendly, but if it translates to string I guess it is fine.
I will close this

You should not use graphql.ID as your primary key in db. Just extract string from this type and use it as your wish (as uuid or convert to int, idk)

But then I still consider it a problem that the error message is confusing. If I provide an Int and it is supposed to be a String, I shouldn't get Missing Value as an error message

yea, error messages are disgusting

Thanks for reporting. PRs are welcome for fixing this issue. I'll mark it as "Help wanted".

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dengliu picture dengliu  路  5Comments

thewillhuang picture thewillhuang  路  5Comments

bsr203 picture bsr203  路  6Comments

LeeWong picture LeeWong  路  4Comments

rogchap picture rogchap  路  5Comments