From ce919dcc6eeafa9d435dd32d44fcd8af655378dd Mon Sep 17 00:00:00 2001 From: Eric Bieszczad-Stie <35773677+BeatsuDev@users.noreply.github.com> Date: Sun, 15 Sep 2024 17:52:23 +0200 Subject: [PATCH] docs: remove client part of the docs This is moved to a different project: https://github.com/BeatsuDev/simple-gql --- README.md | 74 ------------------------------------------------------- 1 file changed, 74 deletions(-) diff --git a/README.md b/README.md index 92ea148..d36d4e7 100644 --- a/README.md +++ b/README.md @@ -109,77 +109,3 @@ print(Character) # } # ``` - -Interacting with a GraphQL endpoint: - -```py -import gqlrequests -import asyncio - -# Normal query -gqlclient = gqlrequests.Client( - api_endpoint="api.example.com/gql", - authorization="abcdefghijklmnopqrstuvwxyz" -) - -schema, types = gqlclient.introspect() -character_search_query = types.Character(func_name="findCharacter") - -character = gqlclient.execute(character_search_query(name="Luke").build()) -print(character.name) - -# Asynchronous queries -RootQuery = schema.RootQuery -async def main(): - gqlclient = gqlrequests.AsyncClient( - api_endpoint="api.example.com/gql", - authorization="abcdefghijklmnopqrstuvwxyz" - ) - - queries = asyncio.gather( - gqlclient.execute(RootQuery(fields=["character"]).build()), - gqlclient.execute(RootQuery(fields=["episode"]).build()) - ) - - # Returns pydantic Models - character, episode = await queries - - # Or simply: - character = await gqlclient.execute(RootQuery().build()) - -asyncio.run(main()) -``` - -```py -"""Subscribing to a graphql websocket""" -import gqlrequests -import asyncio - -schema, types = gqlrequests.introspect() -RootMutation = schema.RootMutation - - -# Example of how the type of RootMutation.live could look like: -# -# class LiveViewers(gqlrequests.QueryBuilder): -# viewers: int -# measurementTimeUnix: int - - -async def main(): - gqlclient = gqlrequests.Client( - api_endpoint="api.example.com/gql", - authorization="abcdefghijklmnopqrstuvwxyz" - ) - - query_string = RootMutation(fields=["live"]).build() - - async with gqlclient.subscribe(query_string) as subscription: - async for data in subscription: - assert isinstance(data, LiveViewers) - - print(data.viewers, data.measurementTimeUnix) - if data.viewers < 10: break - -asyncio.run(main()) -```