Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix complex input types #30

Merged
merged 1 commit into from
Feb 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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