Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Oct 18, 2023. It is now read-only.

Generate pydantic types from any graphql schema

License

NotificationsYou must be signed in to change notification settings

qw-in/graphql-codegen-pydantic

Repository files navigation

Pydantic type generation for graphql

graphql-codegen-pydantic is a plugin forgraphql-codegenthat generatespydantic types from any graphql schema

Example

typeBook {title:Stringauthor:Author}typeAuthor {name:Stringbooks: [Book]}

becomes

fromtypingimportOptional,ListfrompydanticimportBaseModelclassAuthor(BaseModel):name:Optional[str]books:Optional[List[Optional['Book']]]classBook(BaseModel):title:Optional[str]author:Optional['Author']

Warning

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

Installation

  1. Set upgraphql-codegen
  2. Installgraphql-codegen-pydantic
yarn add graphql-codegen-pydantic -D
  1. Add python file tocodegen.yml
schema:http://localhost:3000/graphqlgenerates:./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 tosnake_case

About

Generate pydantic types from any graphql schema

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp