This package has been deprecated

Author message:

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

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

0.1.1 • Public • Published

Pydantic type generation for graphql

graphql-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

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

Installation

  1. Set up graphql-codegen
  2. Install graphql-codegen-pydantic
yarn add graphql-codegen-pydantic -D
  1. Add python file to codegen.yml
schema: http://localhost:3000/graphql
generates:
  ./src/schema.py:
    plugins:
      - 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

Readme

Keywords

none

Package Sidebar

Install

npm i graphql-codegen-pydantic

Weekly Downloads

6

Version

0.1.1

License

MIT

Unpacked Size

84.8 kB

Total Files

16

Last publish

Collaborators

  • qw-in