This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

gql-codegen-pydantic
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

Pydantic type generation for graphql

gql-codegen-pydantic is a plugin for graphql-codegen that generates Pydantic types from any graphql schema

Example

type Book {
  title: String
  author: Author
}
 
type Author {
  name: String
  books: [Book]
}

becomes

from typing import OptionalList
from pydantic import BaseModel
 
 
class Author(BaseModel):
    nameOptional[str]
    booksOptional[List[Optional['Book']]]
 
 
class Book(BaseModel):
    titleOptional[str]
    authorOptional['Author']

Warning

gql-codegen-pydantic is currently still very experimental and is not ready for production use

Installation

  1. Set up graphql-codegen
  2. Install gql-codegen-pydantic
yarn add gql-codegen-pydantic -D
  1. Add python file to codegen.yml
schema: http://localhost:3000/graphql
generates:
  ./src/schema.py:
    plugins:
      - gql-codegen-pydantic

Limitations

Currently very limited

  1. No configuration supported
  2. No comments included in generated code
  3. No support for documents
  4. No resolver support for eg graphene or ariadne
  5. Properties converted to snake_case

/gql-codegen-pydantic/

    Package Sidebar

    Install

    npm i gql-codegen-pydantic

    Weekly Downloads

    1

    Version

    0.1.0

    License

    MIT

    Unpacked Size

    84.8 kB

    Total Files

    16

    Last publish

    Collaborators

    • qw-in