Skip to main content

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


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

graphql2python-0.0.1-py3-none-any.whl (9.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page