forked from xo/xo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
graphql.type.go.tpl
46 lines (32 loc) · 1003 Bytes
/
graphql.type.go.tpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{{- $TypeName := (.Name) -}}
{{- $IsModel := (.IsModel) -}}
{{- if eq .Template "TYPE" }}
// {{.Name}} {{.Description}}
type {{.Name}} struct {
{{- range .Fields}}
{{- if ne .Name "nid" }}
{{capitalize .Name}} {{genType .Type "struct" .Name "package"}} `json:"{{.Name}}"` // {{capitalize .Name}} {{.Description}}
{{- end}}
{{- end}}
}
// {{.Name}}Resolver resolver for {{.Name}}
type {{.Name}}Resolver struct {
{{.Name}}
}
{{ range .Fields}}
// {{capitalize .Name}} {{.Description}}
{{ genResolver . $IsModel "package"}}
{{ end}}
func (r *{{.Name}}Resolver) MarshalJSON() ([]byte, error) {
return json.Marshal(&r.{{.Name}})
}
func (r *{{.Name}}Resolver) UnmarshalJSON(data []byte) error {
return json.Unmarshal(data, &r.{{.Name}})
}
{{- end}}
{{- if eq .Template "EXTRA" }}
{{ range .Efields}}
// {{capitalize .Name}} - {{.Description}}
{{ genResolver . $IsModel "package"}}
{{ end}}
{{- end}}