Skip to content

Commit

Permalink
Warn if an interface's resolver has a ToTYPE implementation that does…
Browse files Browse the repository at this point in the history
… not return two values.

Currently this instead crashes fairly inscrutably at runtime here: https://github.com/neelance/graphql-go/blob/master/internal/exec/exec.go#L117

An alternate fix would be to check len(out) there and perhaps rely on out[0] being nil to continue if there's only one return value.
  • Loading branch information
caseymrm authored and neelance committed May 11, 2017
1 parent 00c4c57 commit 213a5d0
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/exec/resolvable/resolvable.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ func (b *execBuilder) makeObjectExec(typeName string, fields schema.FieldList, p
if methodIndex == -1 {
return nil, fmt.Errorf("%s does not resolve %q: missing method %q to convert to %q", resolverType, typeName, "to"+impl.Name, impl.Name)
}
if resolverType.Method(methodIndex).Type.NumOut() != 2 {
return nil, fmt.Errorf("%s does not resolve %q: method %q should return a value and a bool indicating success", resolverType, typeName, "to"+impl.Name)
}
a := &TypeAssertion{
MethodIndex: methodIndex,
}
Expand Down

0 comments on commit 213a5d0

Please sign in to comment.