forked from arsmn/fastgql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request 99designs#19 from vektah/generate-input-types
Generate input models too
- Loading branch information
Showing
14 changed files
with
112 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,15 @@ | ||
{{- range $i, $arg := . }} | ||
var arg{{$i}} {{$arg.Signature }} | ||
{{- if eq $arg.GoType "map[string]interface{}" }} | ||
if tmp, ok := field.Args[{{$arg.GQLName|quote}}]; ok { | ||
{{- if $arg.Type.IsPtr }} | ||
tmp2 := tmp.({{$arg.GoType}}) | ||
arg{{$i}} = &tmp2 | ||
if tmp, ok := field.Args[{{$arg.GQLName|quote}}]; ok { | ||
var err error | ||
{{$arg.Unmarshal (print "arg" $i) "tmp" }} | ||
if err != nil { | ||
ec.Error(err) | ||
{{- if $arg.Object.Stream }} | ||
return nil | ||
{{- else }} | ||
arg{{$i}} = tmp.({{$arg.GoType}}) | ||
return graphql.Null | ||
{{- end }} | ||
} | ||
{{- else}} | ||
if tmp, ok := field.Args[{{$arg.GQLName|quote}}]; ok { | ||
var err error | ||
{{$arg.Unmarshal (print "arg" $i) "tmp" }} | ||
if err != nil { | ||
ec.Error(err) | ||
{{- if $arg.Object.Stream }} | ||
return nil | ||
{{- else }} | ||
return graphql.Null | ||
{{- end }} | ||
} | ||
} | ||
{{- end}} | ||
} | ||
{{- end -}} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package graphql | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"io" | ||
) | ||
|
||
func MarshalMap(val map[string]interface{}) Marshaler { | ||
return WriterFunc(func(w io.Writer) { | ||
err := json.NewEncoder(w).Encode(val) | ||
if err != nil { | ||
panic(err) | ||
} | ||
}) | ||
} | ||
|
||
func UnmarshalMap(v interface{}) (map[string]interface{}, error) { | ||
if m, ok := v.(map[string]interface{}); ok { | ||
return m, nil | ||
} | ||
|
||
return nil, fmt.Errorf("%T is not a map", v) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters