{"id":14976066,"url":"https://github.com/denisart/graphql2python","last_synced_at":"2025-10-27T17:30:40.541Z","repository":{"id":63897911,"uuid":"571224158","full_name":"denisart/graphql2python","owner":"denisart","description":"A tool that generates python code out of your GraphQL schema.","archived":false,"fork":false,"pushed_at":"2023-11-27T11:55:29.000Z","size":136,"stargazers_count":15,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-09-28T21:40:21.283Z","etag":null,"topics":["code-generation","codegen","graphql","graphql-schema","python","schema"],"latest_commit_sha":null,"homepage":"https://denisart.github.io/graphql2python/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/denisart.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-11-27T15:07:34.000Z","updated_at":"2024-02-15T18:04:41.000Z","dependencies_parsed_at":"2023-11-27T12:50:51.728Z","dependency_job_id":null,"html_url":"https://github.com/denisart/graphql2python","commit_stats":{"total_commits":48,"total_committers":1,"mean_commits":48.0,"dds":0.0,"last_synced_commit":"d6b976d8ebc0ac592637a873fec41fb754415b7e"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denisart%2Fgraphql2python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denisart%2Fgraphql2python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denisart%2Fgraphql2python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denisart%2Fgraphql2python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/denisart","download_url":"https://codeload.github.com/denisart/graphql2python/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219860931,"owners_count":16556009,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code-generation","codegen","graphql","graphql-schema","python","schema"],"created_at":"2024-09-24T13:53:14.873Z","updated_at":"2025-10-27T17:30:40.154Z","avatar_url":"https://github.com/denisart.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GRAPHQL2PYTHON\n\n[![Build](https://img.shields.io/github/actions/workflow/status/denisart/graphql2python/check.yml)](https://github.com/denisart/graphql2python/actions)\n[![tag](https://img.shields.io/github/v/tag/denisart/graphql2python)](https://github.com/denisart/graphql2python)\n[![last-commit](https://img.shields.io/github/last-commit/denisart/graphql2python/master)](https://github.com/denisart/graphql2python)\n[![license](https://img.shields.io/github/license/denisart/graphql2python)](https://github.com/denisart/graphql2python/blob/master/LICENSE)\n\n---\n**NOTE.** Please use the package [datamodel-code-generator](https://github.com/koxudaxi/datamodel-code-generator) to generate data model from a GraphQL schema.\n---\n\n**graphql2python** is a tool that generates python code out of your GraphQL schema.\nIf you are using python as GraphQL client you can to generate\npydantic data-model with **graphql2python**. The documentation for **graphql2python**\ncan be found at [https://denisart.github.io/graphql2python](https://denisart.github.io/graphql2python).\n\nGraphQL query generation moved to https://github.com/denisart/graphql-query\n\nThe special example for [gql](https://gql.readthedocs.io/en/latest/index.html) users [here](https://denisart.github.io/graphql2python/gql.html).\n\n## Quickstart\n\nInstall with pip\n\n```bash\npip install graphql2python\n```\n\nCreate the following file\n\n```yaml\n# graphql2python.yaml\nschema: ./schema.graphql\noutput: ./model.py\n```\n\nand run the following command\n\n```bash\ngraphql2python generate --config ./graphql2python.yaml\n```\n\n## Config reference\n\nGlobal keywords\n\n| keyword        | description                                                   |\n|----------------|---------------------------------------------------------------|\n| `schema`       | A path to the target GraphQL schema file.                     |\n| `output`       | A file name for output `py` file.                             |\n| `license_file` | An optional path to a file with license for output `py` file. |\n| `options`      | Optional options for generate of output `py` file.            |\n\nOptions keywords\n\n| keywords              | description                                                                                                            |\n|-----------------------|------------------------------------------------------------------------------------------------------------------------|\n| `max_line_len`        | The maximum of line length of output `py` file. Default is `120`.                                                      |\n| `name_suffix`         | A suffix for invalid field name (as python object name). Default is `\"_\"`.                                             |\n| `each_field_optional` | Each fields of interfaces and objects are optional. Default is `false`.                                                |\n| `add_from_dict`       | Add `from_dict` (dict -\u003e model) method to the general class. Default is `false`.                                       |\n| `add_to_dict`         | Add `to_dict` (model -\u003e dict) method to the general class. Default is `false`.                                         |\n| `scalar_pytypes`      | A dict with python types for custom GraphQL scalars. Maps from scalar name to python type name. Default is empty dict. |\n| `fields_setting`      | Settings for interfaces or objects fields. Maps from object name to a dict with setting. Default is empty dict.        |\n\n`fields_setting` keywords for some object name\n\n| keywords   | desciption                                                            |\n|------------|-----------------------------------------------------------------------|\n| `alias`    | An alias for a field (see Field.alias for pydantic). Default is null. |\n| `new_name` | A new name for a field. Default is null.                              |\n\nAn example for `graphql2python.yaml` config:\n\n```yaml\n# graphql2python.yaml\nschema: ./schema/schema.graphql\noutput: ./model/model.py\nlicense_file: ./LICENSE\noptions:\n  scalar_pytypes:\n    String: str\n    Float: float\n    Int: int\n    ID: str\n    Boolean: bool\n    DateTime: datetime\n    Date: date\n  max_line_len: 79\n  each_field_optional: true\n  fields_setting:\n    MyObjectName:\n      from:\n        alias: from\n        new_name: correct_from\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdenisart%2Fgraphql2python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdenisart%2Fgraphql2python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdenisart%2Fgraphql2python/lists"}