vektah/gqlparser

invalid memory address or nil pointer dereference calling `arg2map` with `f.Definition` `nil`!

frederikhors opened this issue · 1 comments

Upgrading from github.com/vektah/gqlparser/v2 v2.1.0 to github.com/vektah/gqlparser/v2 v2.2.0 with the same generated (gqlgen@0.13.0) code and all the same files I get a monster error:

runtime error: invalid memory address or nil pointer dereference.

After a long time of debugging I realized the problem is here:

func (f *Field) ArgumentMap(vars map[string]interface{}) map[string]interface{} {
	return arg2map(f.Definition.Arguments, f.Arguments, vars)
}

f.Definition here is nil with v2.2.0, not with 2.1.0! Why?

How to fix this?

The code is simple:

extend type Mutation {
  playerCreate(input: PlayerInput!): Player!
}

type Player {
  id: ID!
  firstname: String!
}

input PlayerInput {
  firstname: String!
}