This repository is a plugin for GraphQL Code Generator that can be used to generate Python type hints when implementing GraphQL servers with Ariadne.
See the tests
directory for examples of what it can do currently.
- Create
typing.Enum
s from SDLenum
. - Create
typing.TypedDict
s from GraphQLtype
andinput
. - Create special
ariadne.ObjectType
with an overloadedset_field
method for type safe resolver registration. - Allow field access through attributes instead of through string dictionary keys like Ariadne (implement with
typing.protocol
and@property
, mypy docs). - Allow
Callable
for field resolvers. - Allow type-safe usage of Ariadne's decorator for resolver registration.
- Type with the custom
Enum
s that you pass to Ariadne.
Note: this plugin is more of a proof of concept in its current stage.
Set up Graphql Code Generator following the documentation.
Install graphql-codegen-ariadne
. Then add it to codegen.yml
. (Again, see documentation of Graphql Code Generator).
overwrite: true
schema: "/schema.graphql"
documents: "**/*.graphql"
generates:
graphql_types.py:
plugins:
- "graphql-codegen-ariadne"
This plugin currently has no configuration.