Metadata-Version: 2.1
Name: graphql2python
Version: 0.0.1
Summary: Tools for GraphQL client in python.
Home-page: https://github.com/denisart/graphql2python
Author: Denis A. Artyushin
Maintainer: Denis A. Artyushin
Maintainer-email: artyushinden@gmail.com
License: MIT
Platform: UNKNOWN
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: graphql-core (<3.3,>=3.2)
Requires-Dist: jinja2 (<3.2,>=3.1)
Requires-Dist: pydantic (<1.11,>=1.10)
Provides-Extra: dev
Requires-Dist: isort (<5.11,>=5.10) ; extra == 'dev'
Requires-Dist: mypy (<0.992,>=0.991) ; extra == 'dev'
Requires-Dist: pylint-pydantic (<0.2,>=0.1) ; extra == 'dev'
Requires-Dist: pylint (<2.16,>=2.15) ; extra == 'dev'
Requires-Dist: wheel (<0.39,>=0.38) ; extra == 'dev'
Provides-Extra: test
Requires-Dist: pytest-cov (<3.1,>=3.0) ; extra == 'test'
Requires-Dist: pytest-mock (<3.11,>=3.10) ; extra == 'test'
Requires-Dist: pytest (<7.3,>=7.2) ; extra == 'test'

# GRAPHQL2PYTHON

Tools for GraphQL client in python.

## Installation

Install using

```bash
pip install graphql2python
```

## A Simple Example

For the query

```graphql
query HeroForEpisode($ep: Episode!) {
  hero(episode: $ep) {
    name
    ... on Droid {
      primaryFunction
    }
    ... on Human {
      height
    }
  }
}
```

we have

```python
from graphql2python.query import InlineFragment, Operation, Query, Variable, Argument

var_ep = Variable(name="ep", type="Episode!")
arg_episode = Argument(name="episode", value=var_ep)

hero = Query(
    name="hero",
    arguments=[arg_episode],
    fields=[
        "name",
        InlineFragment(type="Droid", fields=["primaryFunction"]),
        InlineFragment(type="Human", fields=["height"]),
    ]
)

operation = Operation(
    type="query",
    name="HeroForEpisode",
    queries=[hero],
    variables=[var_ep]
)
operation.render()
# query HeroForEpisode(
#   $ep: Episode!
# ) {
#   hero(
#     episode: $ep
#   ) {
#     name
#     ... on Droid {
#       primaryFunction
#     }
#     ... on Human {
#       height
#     }
#   }
# }
```

