-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
generate enums with graphql-go and template file (#497)
* generate enums with graphql-go and template file * rename schema string * gitignore schema graphql
- Loading branch information
1 parent
7966427
commit 746a637
Showing
7 changed files
with
385 additions
and
285 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
.DS_Store | ||
coverage.out | ||
coverage.txt | ||
schema.graphql |
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 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,16 @@ | ||
{{- define "enum" }} | ||
|
||
// {{.Name | title}} {{.Desc | clean | endSentence}} | ||
type {{.Name}} string | ||
|
||
const ( | ||
{{- range .EnumValuesDefinition }} | ||
{{$.Name}}{{.EnumValue | enumIdentifier}} {{$.Name}} = {{.EnumValue | quote}} // {{ .Desc | clean | fullSentence }} | ||
{{- end }} | ||
) | ||
// All {{$.Name}} as []string | ||
var All{{$.Name}} = []string { | ||
{{range .EnumValuesDefinition}}string({{$.Name}}{{.EnumValue | enumIdentifier}}), | ||
{{end}} | ||
} | ||
{{- end -}} |