aboutsummaryrefslogtreecommitdiff
path: root/examples/python/client.py
blob: 68891ab4fd3ed97c3caa4db2aae83a9a7e0fc483 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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())