Skip to content

Commit

Permalink
Fix complex input types
Browse files Browse the repository at this point in the history
  • Loading branch information
vektah committed Feb 25, 2018
1 parent 1d074b8 commit 9b64dd2
Show file tree
Hide file tree
Showing 9 changed files with 845 additions and 8 deletions.
3 changes: 1 addition & 2 deletions codegen/models_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ func bindGenerated(types NamedTypes, object *Object) {
field.GoVarName = "ID"
}
} else if object.Input {
field.GoFKName = ucFirst(field.GQLName)
field.GoFKType = types[field.GQLType].GoType
field.GoVarName = ucFirst(field.GQLName)
} else {
field.GoFKName = ucFirst(field.GQLName) + "ID"
field.GoFKType = "int" // todo: use schema to determine type of id?
Expand Down
2 changes: 1 addition & 1 deletion codegen/templates/args.gotpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{{- end }}
}
} {{ if $arg.Default }} else {
tmp := {{ $arg.Default | dump }}
var tmp interface{} = {{ $arg.Default | dump }}
var err error
{{$arg.Unmarshal (print "arg" $i) "tmp" }}
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion codegen/templates/data.go

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

2 changes: 1 addition & 1 deletion example/scalars/generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (ec *executionContext) _Query_search(field graphql.CollectedField) graphql.
return graphql.Null
}
} else {
tmp := map[string]interface{}{"location": "37,144"}
var tmp interface{} = map[string]interface{}{"location": "37,144"}
var err error

arg0, err = UnmarshalSearchArgs(tmp)
Expand Down
6 changes: 3 additions & 3 deletions example/starwars/generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ func (ec *executionContext) _Human_height(field graphql.CollectedField, obj *Hum
return graphql.Null
}
} else {
tmp := "METER"
var tmp interface{} = "METER"
var err error

arg0, err = graphql.UnmarshalString(tmp)
Expand Down Expand Up @@ -590,7 +590,7 @@ func (ec *executionContext) _Query_hero(field graphql.CollectedField) graphql.Ma
return graphql.Null
}
} else {
tmp := "NEWHOPE"
var tmp interface{} = "NEWHOPE"
var err error

arg0, err = graphql.UnmarshalString(tmp)
Expand Down Expand Up @@ -884,7 +884,7 @@ func (ec *executionContext) _Starship_length(field graphql.CollectedField, obj *
return graphql.Null
}
} else {
tmp := "METER"
var tmp interface{} = "METER"
var err error

arg0, err = graphql.UnmarshalString(tmp)
Expand Down
Loading

0 comments on commit 9b64dd2

Please sign in to comment.