diff --git a/api/generate_test.go b/api/generate_test.go index 0572042ef2..c98f91e27b 100644 --- a/api/generate_test.go +++ b/api/generate_test.go @@ -34,6 +34,10 @@ func TestGenerate(t *testing.T) { name: "federation2", workDir: filepath.Join(wd, "testdata", "federation2"), }, + { + name: "worker_limit", + workDir: filepath.Join(wd, "testdata", "workerlimit"), + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/api/testdata/workerlimit/gqlgen.yml b/api/testdata/workerlimit/gqlgen.yml new file mode 100644 index 0000000000..0f0ff69c53 --- /dev/null +++ b/api/testdata/workerlimit/gqlgen.yml @@ -0,0 +1,70 @@ +# Where are all the schema files located? globs are supported eg src/**/*.graphqls +schema: + - graph/*.graphqls + +# Where should the generated server code go? +exec: + filename: graph/generated.go + package: graph + worker_limit: 1 + +# Uncomment to enable federation +# federation: +# filename: graph/federation.go +# package: graph + +# Where should any generated models go? +model: + filename: graph/model/models_gen.go + package: model + +# Where should the resolver implementations go? +resolver: + layout: follow-schema + dir: graph + package: graph + +# Optional: turn on use `gqlgen:"fieldName"` tags in your models +# struct_tag: json + +# Optional: turn on to use []Thing instead of []*Thing +# omit_slice_element_pointers: false + +# Optional: turn off to make struct-type struct fields not use pointers +# e.g. type Thing struct { FieldA OtherThing } instead of { FieldA *OtherThing } +# struct_fields_always_pointers: true + +# Optional: turn off to make resolvers return values instead of pointers for structs +# resolvers_always_return_pointers: true + +# Optional: turn on to return pointers instead of values in unmarshalInput +# return_pointers_in_unmarshalinput: false + +# Optional: wrap nullable input fields with Omittable +# nullable_input_omittable: true + +# Optional: set to speed up generation time by not performing a final validation pass. +# skip_validation: true + +# gqlgen will search for any type names in the schema in these go packages +# if they match it will use them, otherwise it will generate them. +autobind: + - "github.com/99designs/gqlgen/api/testdata/default/graph/model" + +# This section declares type mapping between the GraphQL and go type systems +# +# The first line in each type will be used as defaults for resolver arguments and +# modelgen, the others will be allowed when binding to fields. Configure them to +# your liking +models: + ID: + model: + - github.com/99designs/gqlgen/graphql.ID + - github.com/99designs/gqlgen/graphql.Int + - github.com/99designs/gqlgen/graphql.Int64 + - github.com/99designs/gqlgen/graphql.Int32 + Int: + model: + - github.com/99designs/gqlgen/graphql.Int + - github.com/99designs/gqlgen/graphql.Int64 + - github.com/99designs/gqlgen/graphql.Int32 diff --git a/api/testdata/workerlimit/graph/model/doc.go b/api/testdata/workerlimit/graph/model/doc.go new file mode 100644 index 0000000000..8b53790705 --- /dev/null +++ b/api/testdata/workerlimit/graph/model/doc.go @@ -0,0 +1 @@ +package model diff --git a/api/testdata/workerlimit/graph/schema.graphqls b/api/testdata/workerlimit/graph/schema.graphqls new file mode 100644 index 0000000000..c6a91bb480 --- /dev/null +++ b/api/testdata/workerlimit/graph/schema.graphqls @@ -0,0 +1,28 @@ +# GraphQL schema example +# +# https://gqlgen.com/getting-started/ + +type Todo { + id: ID! + text: String! + done: Boolean! + user: User! +} + +type User { + id: ID! + name: String! +} + +type Query { + todos: [Todo!]! +} + +input NewTodo { + text: String! + userId: String! +} + +type Mutation { + createTodo(input: NewTodo!): Todo! +}