Tools for GraphQL client in python.
Project description
GRAPHQL2PYTHON
Tools for GraphQL client in python.
Installation
Install using
pip install graphql2python
A Simple Example
For the query
query HeroForEpisode($ep: Episode!) {
hero(episode: $ep) {
name
... on Droid {
primaryFunction
}
... on Human {
height
}
}
}
we have
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
# }
# }
# }
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for graphql2python-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c06e189531732ea514ce051b48aae19d0b660d0da4dc1aca6a3c3e5a39a08eb |
|
MD5 | 9c52661e56ac6ee08b339c5447631758 |
|
BLAKE2b-256 | 52ab57741e3f6127bd18dd8c091ae77bfd2344da6d2a296e865025741322757f |