File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ pip install python-graphql-client
1616
1717## Usage
1818
19+ - Query/Mutation
20+
1921``` python
2022from python_graphql_client import GraphqlClient
2123
@@ -45,6 +47,31 @@ data = asyncio.run(client.execute_async(query=query, variables=variables))
4547print (data) # => {'data': {'country': {'code': 'CA', 'name': 'Canada'}}}
4648```
4749
50+ - Subscription
51+
52+ ``` python
53+ from python_graphql_client import GraphqlClient
54+
55+ # Instantiate the client with a websocket endpoint.
56+ client = GraphqlClient(endpoint = " wss://www.your-api.com/graphql" )
57+
58+ # Create the query string and variables required for the request.
59+ query = """
60+ subscription onMessageAdded {
61+ messageAdded
62+ }
63+ """
64+
65+ # Asynchronous request
66+ import asyncio
67+
68+ asyncio.run(client.subscribe(query = query, handle = print ))
69+ # => {'data': {'messageAdded': 'Error omnis quis.'}}
70+ # => {'data': {'messageAdded': 'Enim asperiores omnis.'}}
71+ # => {'data': {'messageAdded': 'Unde ullam consequatur quam eius vel.'}}
72+ # ...
73+ ```
74+
4875## Roadmap
4976
5077To start we'll try and use a Github project board for listing current work and updating priorities of upcoming features.
You can’t perform that action at this time.
0 commit comments