[edit]

Configuration

How to configure gqlgen using gqlgen.yml

gqlgen can be configured using a gqlgen.yml file, by default it will be loaded from the current directory, or any parent directory.

Example:

schema: schema.graphql

# Let gqlgen know where to put the generated server
exec:
  filename: graph/generated/generated.go
  package: generated

# Let gqlgen know where to the generated models (if any)
model:
  filename: models/generated.go
  package: models

# Optional, turns on resolver stub generation
resolver:
  filename: resolver.go # where to write them
  type: Resolver  # whats the resolver root implementation type called?

# Optional, turns on binding to field names by tag provided
struct_tag: json

# Tell gqlgen about any existing models you want to reuse for
# graphql. These normally come from the db or a remote api.
models:
  User:
    model: github.com/my/app/models.User
  Todo:
    model: github.com/my/app/models.Todo
    fields:
      id:
        resolver: true # force a resolver to be generated
        fieldName: todoId # bind to a different go field name 

Everything has defaults, so add things as you need.