Skip to content

Commit

Permalink
enum directive example
Browse files Browse the repository at this point in the history
  • Loading branch information
Yamashou committed Sep 2, 2024
1 parent 748f52f commit 9c40dce
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 0 deletions.
25 changes: 25 additions & 0 deletions example/enum-directive/.gqlgenc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
schema:
- ./schema/schema.graphql
model:
filename: ./model/models_gen.go
client:
filename: ./gen/client.go
models:
EnumTyped:
model: ./model.EnumTyped
enum_values:
ONE:
value: ./model.EnumTypedOne
TWO:
value: ./model.EnumTypedTwo
EnumUntyped:
model: github.com/99designs/gqlgen/graphql.Int
enum_values:
ONE:
value: ./model.EnumUntypedOne
TWO:
value: ./model.EnumUntypedTwo
query:
- "./query/*.graphql"
generate:
clientInterfaceName: "GithubGraphQLClient"
22 changes: 22 additions & 0 deletions example/enum-directive/gen/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions example/enum-directive/model/model.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package model

type EnumTyped int

const (
EnumTypedOne EnumTyped = iota + 1
EnumTypedTwo
)

const (
EnumUntypedOne = iota + 1
EnumUntypedTwo
)
6 changes: 6 additions & 0 deletions example/enum-directive/model/models_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions example/enum-directive/schema/schema.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
directive @goModel(
model: String
models: [String!]
) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION

directive @goEnum(value: String) on ENUM_VALUE

type Query {
example(arg: EnumUntyped): EnumTyped
}

enum EnumTyped @goModel(model: "./model.EnumTyped") {
ONE @goEnum(value: "./model.EnumTypedOne")
TWO @goEnum(value: "./model.EnumTypedTwo")
}

enum EnumUntyped @goModel(model: "github.com/99designs/gqlgen/graphql.Int") {
ONE @goEnum(value: "./model.EnumUntypedOne")
TWO @goEnum(value: "./model.EnumUntypedTwo")
}

0 comments on commit 9c40dce

Please sign in to comment.