Skip to main content

graphql-schema -> pydantic models

Project description

Qlligraphy. GraphQL Schema -> Pydantic models

Qlligraphy is a simple CLI tool, that generates pydantic models based on graphQL schema.

Installation

pip install qlligraphy

Usage:

Consider the following schema written in example.gql

enum Episode {
 NEWHOPE
 EMPIRE
 JEDI
}

type Character {
  name: String!
  appearsIn: [Episode]!
}

Running:

qlligraphy example.gql -o example.py

Results in the following python file:

from enum import Enum
from typing import List, Optional

from pydantic import BaseModel


class Episode(str, Enum):
    NEWHOPE = "NEWHOPE"
    EMPIRE = "EMPIRE"
    JEDI = "JEDI"


class Character(BaseModel):
    name: str
    appearsIn: List[Optional[Episode]]

Please note: This package is still in WIP state.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qlligraphy-0.1.3.tar.gz (7.2 kB view hashes)

Uploaded Source

Built Distribution

qlligraphy-0.1.3-py3-none-any.whl (8.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page