graphene-codegen
Turn your GraphQL schema into Python boilerplate.
Note: doesn't output classes in the correct dependency order. Also doesn't translate directives or default arguments yet.
Usage
$ npm i -g graphene-codegen$ graphene-codegen --schema="./schema.graphql" --out="gen.py"
Example
Input file
enum Episode { NEWHOPE EMPIRE JEDI} """You can use these to get around the galaxy."""type Starship { id: ID! name: String! length(unit: String): Float} interface Character { id: ID! name: String! friends: [Character] appearsIn: [Episode]!} type Human implements Character { id: ID! name: String! friends: [Character] appearsIn: [Episode]! starships: [Starship] totalCredits: Int} type Droid implements Character { id: ID! name: String! friends: [Character] appearsIn: [Episode]! primaryFunction: String} union SearchResult = Human | Droid | Starship type Query { hero(episode: Episode): Character droid(id: ID!): Droid}
Output file
from graphene import Schema, Enum, ObjectType, NonNull, ID, String, Float, Interface, List, Int, Union, Argument, Field NEWHOPE = 0 EMPIRE = 1 JEDI = 2 '''You can use these to get around the galaxy.''' id = name = length = id = name = friends = appears_in = interfaces = (Character, ) id = name = friends = appears_in = starships = total_credits = interfaces = (Character, ) id = name = friends = appears_in = primary_function = types = (Human, Droid, Starship) hero = droid = schema =