Skip to content

Commit

Permalink
fix binding to primitive non leaf types
Browse files Browse the repository at this point in the history
  • Loading branch information
vektah committed May 15, 2019
1 parent b0cd95a commit a512005
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
2 changes: 1 addition & 1 deletion codegen/config/binder.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ func (b *Binder) TypeReference(schemaType *ast.Type, bindTarget types.Type) (ret
} else if hasMethod(obj.Type(), "MarshalGQL") && hasMethod(obj.Type(), "UnmarshalGQL") {
ref.GO = obj.Type()
ref.IsMarshaler = true
} else if underlying := basicUnderlying(obj.Type()); underlying != nil && underlying.Kind() == types.String {
} else if underlying := basicUnderlying(obj.Type()); def.IsLeafType() && underlying != nil && underlying.Kind() == types.String {
// Special case for named types wrapping strings. Used by default enum implementations.

ref.GO = obj.Type()
Expand Down
8 changes: 1 addition & 7 deletions codegen/testserver/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion codegen/testserver/primitive_objects_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func TestPrimitiveStringObjects(t *testing.T) {
PrimitiveStringObject []struct {
Value string
Doubled string
Len int
Len int
}
}
c.MustPost(`query { primitiveStringObject { value, doubled, len } }`, &resp)
Expand Down

0 comments on commit a512005

Please sign in to comment.