graphql-dataclass


Namegraphql-dataclass JSON
Version 1.0.4 PyPI version JSON
download
home_pagehttps://github.com/nikikuzi/graphql-dataclass/tree/1.0.0
SummaryA python library to generate dataclasses for GraphQL types
upload_time2024-03-18 23:25:10
maintainer
docs_urlNone
authorMikita Kuzniatsou, Alex Dap
requires_python>=3.10
licenseMIT License Copyright (c) 2024 Mikita Kuzniatsou Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords python graphql mapping dataclass
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # graphql-dataclass

A python library to generate dataclasses for graphql schema.

## Introduction

This library generates dataclasses which corresponding python code convention. Library is not working as client for graphql, only dataclasses mappers for GraphQL types

This document contains a quick overview of the functionalities, for more details and options you can read here:

* [Code Generation](https://github.com/nikikuzi/graphql-dataclass/blob/develop/codegen/README.MD)

The package using [clean-py](https://github.com/samhardyhey/clean-py) library for generateed code formatting and also python 3 (3.10+) standard libraries.


## Usage in a nutshell

### Installation

Available in PyPI, the following command will install the library:

```
pip install graphql-dataclass
```


### Generate python code from schema

To generate the code execute the following command:

```
gqldataclass generate ./pathToOutputFolder -apiArgs ./<pathToArgsFile>/generatorArgs.json
```

This command requires a json file containing the parameters needed to get the GraphQL schema

A sample is available in the main folder ['cli_args.json'](https://github.com/nikikuzi/graphql-dataclass/blob/develop/cli_args.json).

The following python files will be generated:

* scalars.py -> GraphQL scalar types as python type aliases
* enums.py -> GraphQL enum types as Enum classes
* gql_types.py -> GraphQL object types as classes
* gql_simple_types.py -> GraphQL object types as classes not using other object types
* unions.py -> GraphQL Unions as python Unions
* gql_forward_reference.py -> file with types forward references, [dacite](https://github.com/konradhalas/dacite)-compatible
* ${class_name}.py -> GraphQL object types as classes, which affected by circular dependencies

These links show code generated using the library [Github GraphQL API](https://github.com/nikikuzi/graphql-dataclass/blob/develop/tests/output/github), and [GeoDBCities API](https://github.com/nikikuzi/graphql-dataclass/blob/develop/tests/output/gdbc)

More command options are available [here](https://github.com/nikikuzi/graphql-dataclass/blob/develop/codegen/README.MD#usage-via-command-line)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/nikikuzi/graphql-dataclass/tree/1.0.0",
    "name": "graphql-dataclass",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "",
    "keywords": "python,graphql,mapping,dataclass",
    "author": "Mikita Kuzniatsou, Alex Dap",
    "author_email": "Mikita Kuzniatsou <nikikuzi@gmail.com>, Alex Dap <shlisi2017@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/93/31/8bd2a9f36ae0b4eb6654f6d8ac08b3f0915d79de5e07ace5aa3dcf5dc32c/graphql-dataclass-1.0.4.tar.gz",
    "platform": null,
    "description": "# graphql-dataclass\n\nA python library to generate dataclasses for graphql schema.\n\n## Introduction\n\nThis library generates dataclasses which corresponding python code convention. Library is not working as client for graphql, only dataclasses mappers for GraphQL types\n\nThis document contains a quick overview of the functionalities, for more details and options you can read here:\n\n* [Code Generation](https://github.com/nikikuzi/graphql-dataclass/blob/develop/codegen/README.MD)\n\nThe package using [clean-py](https://github.com/samhardyhey/clean-py) library for generateed code formatting and also python 3 (3.10+) standard libraries.\n\n\n## Usage in a nutshell\n\n### Installation\n\nAvailable in PyPI, the following command will install the library:\n\n```\npip install graphql-dataclass\n```\n\n\n### Generate python code from schema\n\nTo generate the code execute the following command:\n\n```\ngqldataclass generate ./pathToOutputFolder -apiArgs ./<pathToArgsFile>/generatorArgs.json\n```\n\nThis command requires a json file containing the parameters needed to get the GraphQL schema\n\nA sample is available in the main folder ['cli_args.json'](https://github.com/nikikuzi/graphql-dataclass/blob/develop/cli_args.json).\n\nThe following python files will be generated:\n\n* scalars.py -> GraphQL scalar types as python type aliases\n* enums.py -> GraphQL enum types as Enum classes\n* gql_types.py -> GraphQL object types as classes\n* gql_simple_types.py -> GraphQL object types as classes not using other object types\n* unions.py -> GraphQL Unions as python Unions\n* gql_forward_reference.py -> file with types forward references, [dacite](https://github.com/konradhalas/dacite)-compatible\n* ${class_name}.py -> GraphQL object types as classes, which affected by circular dependencies\n\nThese links show code generated using the library [Github GraphQL API](https://github.com/nikikuzi/graphql-dataclass/blob/develop/tests/output/github), and [GeoDBCities API](https://github.com/nikikuzi/graphql-dataclass/blob/develop/tests/output/gdbc)\n\nMore command options are available [here](https://github.com/nikikuzi/graphql-dataclass/blob/develop/codegen/README.MD#usage-via-command-line)\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 Mikita Kuzniatsou  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "A python library to generate dataclasses for GraphQL types",
    "version": "1.0.4",
    "project_urls": {
        "Bug Tracker": "https://github.com/nikikuzi/graphql-dataclass/issues",
        "Homepage": "https://github.com/nikikuzi/graphql-dataclass/",
        "Release Notes": "https://github.com/nikikuzi/graphql-dataclass/tree/1.0.0/RELEASE_NOTES.MD",
        "Source Code": "https://github.com/nikikuzi/graphql-dataclass/tree/1.0.0"
    },
    "split_keywords": [
        "python",
        "graphql",
        "mapping",
        "dataclass"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0203270adc1241d0d86015e4d0bcdde78536edada0d06bdf357ac8c410147999",
                "md5": "df6732c48d2bafdcc2224f06d875297b",
                "sha256": "b5344e39121b80bd363f68a95cc5ca34f5bde0b12b6742871df3cce59f2fb447"
            },
            "downloads": -1,
            "filename": "graphql_dataclass-1.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "df6732c48d2bafdcc2224f06d875297b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 43834,
            "upload_time": "2024-03-18T23:25:08",
            "upload_time_iso_8601": "2024-03-18T23:25:08.875014Z",
            "url": "https://files.pythonhosted.org/packages/02/03/270adc1241d0d86015e4d0bcdde78536edada0d06bdf357ac8c410147999/graphql_dataclass-1.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "93318bd2a9f36ae0b4eb6654f6d8ac08b3f0915d79de5e07ace5aa3dcf5dc32c",
                "md5": "f8c2d146893d5503133024215060855f",
                "sha256": "38257983743f8371a56987f05c43a4446bae1ecd66c59b9ab327642e865acf8f"
            },
            "downloads": -1,
            "filename": "graphql-dataclass-1.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "f8c2d146893d5503133024215060855f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 36722,
            "upload_time": "2024-03-18T23:25:10",
            "upload_time_iso_8601": "2024-03-18T23:25:10.183525Z",
            "url": "https://files.pythonhosted.org/packages/93/31/8bd2a9f36ae0b4eb6654f6d8ac08b3f0915d79de5e07ace5aa3dcf5dc32c/graphql-dataclass-1.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-18 23:25:10",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "nikikuzi",
    "github_project": "graphql-dataclass",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "graphql-dataclass"
}
        
Elapsed time: 0.21421s