diff options
| author | Fuwn <[email protected]> | 2022-03-20 01:51:50 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2022-03-20 01:51:50 -0700 |
| commit | a88b17d50ec2c63bcb64d87859ef17a122edbe44 (patch) | |
| tree | 6894f0b8689ade07c018dc6a968a5ea48ae97174 /examples | |
| parent | feat: 0.1.0 :star: (diff) | |
| download | graphql-api-a88b17d50ec2c63bcb64d87859ef17a122edbe44.tar.xz graphql-api-a88b17d50ec2c63bcb64d87859ef17a122edbe44.zip | |
feat(examples): python
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/python/client.py | 23 | ||||
| -rw-r--r-- | examples/python/requirements.txt | 1 |
2 files changed, 24 insertions, 0 deletions
diff --git a/examples/python/client.py b/examples/python/client.py new file mode 100644 index 0000000..68891ab --- /dev/null +++ b/examples/python/client.py @@ -0,0 +1,23 @@ +import asyncio + +from gql import gql, Client +from gql.transport.aiohttp import AIOHTTPTransport + + +async def main() -> None: + transport: AIOHTTPTransport = AIOHTTPTransport(url="https://graphql.senpy.club") + + async with Client(transport=transport, fetch_schema_from_transport=True) as client: + query = gql( + """ + query { + random: random { + image + } + } + """ + ) + + print((await client.execute(query))["random"]["image"]) + +asyncio.run(main()) diff --git a/examples/python/requirements.txt b/examples/python/requirements.txt new file mode 100644 index 0000000..f0b622e --- /dev/null +++ b/examples/python/requirements.txt @@ -0,0 +1 @@ +gql==3.1.0 |