Skip to content

Commit

Permalink
hint in error if method only exists on pointer type (fixes #60)
Browse files Browse the repository at this point in the history
  • Loading branch information
neelance committed Mar 10, 2017
1 parent 356ebd9 commit e9afca3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/exec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,11 @@ func (b *execBuilder) makeObjectExec(typeName string, fields map[string]*schema.
for name, f := range fields {
methodIndex := findMethod(resolverType, name)
if methodIndex == -1 {
return nil, fmt.Errorf("%s does not resolve %q: missing method for field %q", resolverType, typeName, name)
hint := ""
if findMethod(reflect.PtrTo(resolverType), name) != -1 {
hint = " (hint: the method exists on the pointer type)"
}
return nil, fmt.Errorf("%s does not resolve %q: missing method for field %q%s", resolverType, typeName, name, hint)
}

m := resolverType.Method(methodIndex)
Expand Down

0 comments on commit e9afca3

Please sign in to comment.