The configuration file must be called
language: The target programming language for the generated code. Possible values:
schema: The file path pointing to your GraphQL schema file.
context: Points to the definition of the
contextobject that's passed through your GraphQL resolver chain.
models: A mapping from types in your GraphQL schema to the models defined in your programming language. Learn more about models.
output: Specifies where the generated type definitions and default resolver implementations should be located. Must point to a single file.
resolver-scaffolding: An object with two properties
default-resolvers: A boolean dictating if default resolvers will be generated or not. Defaults to
iresolvers-augmentation: A boolean dictating if Apollo Server IResolvers type should be augmented so that it is compatible with graphqlgen
Resolverstype. Defaults to
delegated-parent-resolvers: A boolean dictating if the resolver signatures generated should include the signature for DelegatedParentResolvers. Defaults to
Models represent domain objects in the target `language:
- Models are not necessarily 1-to-1 mappings to your database structures, but can be.
- Models are not necessarily the types from your GraphQL schema, but can be.
When starting a new project, it is often the case that models look very similar to to the SDL types in your GraphQL schema. Only as a project grows, it is often useful to decouple the TypeScript representation of an object from the way it's exposed through the API.
Consider an example where you have a
User model with a
password field. The
password field most likely should not be exposed through the API, but it's still required within your code. In that case, the model differs from the SDL type representation in the GraphQL schema.
There are four layouts that can be applied when scaffolding resolver skeletons:
file-per-type: Generates one file per SDL type and puts the corresponding resolvers into it.
single-file(coming soon): Generates all resolvers in a single file.
file-per-type-classes(coming soon): Same as
file-per-typebut generates resolvers as classes instead of plain objects.
single-file-classes(coming soon): Same as
single-filebut generates resolvers as classes instead of plain objects.
See this issue to learn more about the upcoming layouts.