Skip to content

GraphQL Code Generator plugin for generating Python types helpful when implementing GraphQL servers with Ariadne

Notifications You must be signed in to change notification settings

enra-GmbH/graphql-codegen-ariadne

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GraphQL Code Generator Plugin for Ariadne

This repository is a plugin for GraphQL Code Generator that can be used to generate Python type hints when implementing GraphQL servers with Ariadne.

Features

See the tests directory for examples of what it can do currently.

  • Create typing.Enums from SDL enum.
  • Create typing.TypedDicts from GraphQL type and input.
  • Create special ariadne.ObjectType with an overloaded set_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 Enums that you pass to Ariadne.

Usage

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.

About

GraphQL Code Generator plugin for generating Python types helpful when implementing GraphQL servers with Ariadne

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published