Skip to content

Commit

Permalink
now with field values
Browse files Browse the repository at this point in the history
  • Loading branch information
andrioid committed Aug 27, 2018
1 parent 08ab33b commit 7c04004
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion codegen/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type Object struct {

type Field struct {
*Type

Description string // Description of a field
GQLName string // The name of the field in graphql
GoFieldType GoFieldType // The field type in go, if any
GoReceiverName string // The name of method & var receiver in go, if any
Expand Down
1 change: 1 addition & 0 deletions codegen/object_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ func (cfg *Config) buildObject(types NamedTypes, typ *ast.Definition, imports *I
GoReceiverName: "ec",
GoFieldName: "introspectSchema",
Object: obj,
Description: field.Description,
})
continue
}
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.

3 changes: 3 additions & 0 deletions codegen/templates/models.gotpl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import (
{{- else }}
type {{.GoType}} struct {
{{- range $field := .Fields }}
{{- with .Description}}
{{.|prefixLines "// "}}
{{- end}}
{{- if $field.GoFieldName }}
{{ $field.GoFieldName }} {{$field.Signature}} `json:"{{$field.GQLName}}"`
{{- else }}
Expand Down

0 comments on commit 7c04004

Please sign in to comment.