{"id":14975997,"url":"https://github.com/ecthiender/py-graphql-client","last_synced_at":"2025-10-27T17:30:26.662Z","repository":{"id":47634661,"uuid":"171754532","full_name":"ecthiender/py-graphql-client","owner":"ecthiender","description":"Dead-simple GraphQL client with subscriptions over websockets","archived":false,"fork":false,"pushed_at":"2023-05-27T13:56:17.000Z","size":48,"stargazers_count":37,"open_issues_count":7,"forks_count":11,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-09-28T21:22:43.184Z","etag":null,"topics":["graphql","graphql-client","graphql-subscriptions","python","python3","websockets"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/py-graphql-client/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ecthiender.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-20T21:48:29.000Z","updated_at":"2023-09-03T16:22:40.000Z","dependencies_parsed_at":"2024-06-19T01:37:20.833Z","dependency_job_id":"b8d98ea4-f81e-48a5-a17c-74024e656393","html_url":"https://github.com/ecthiender/py-graphql-client","commit_stats":{"total_commits":27,"total_committers":7,"mean_commits":3.857142857142857,"dds":"0.33333333333333337","last_synced_commit":"9f938f3d379a8f4d8810961c87baf25dbe35889d"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecthiender%2Fpy-graphql-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecthiender%2Fpy-graphql-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecthiender%2Fpy-graphql-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecthiender%2Fpy-graphql-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ecthiender","download_url":"https://codeload.github.com/ecthiender/py-graphql-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219860932,"owners_count":16556009,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["graphql","graphql-client","graphql-subscriptions","python","python3","websockets"],"created_at":"2024-09-24T13:53:06.634Z","updated_at":"2025-10-27T17:30:26.351Z","avatar_url":"https://github.com/ecthiender.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# py-graphql-client\nDead-simple to use GraphQL client over websocket. Using the\n[apollo-transport-ws](https://github.com/apollographql/subscriptions-transport-ws/blob/master/PROTOCOL.md)\nprotocol.\n\n## Install\n\n```bash\npip install py-graphql-client\n```\n\n## Examples\n\n### Setup subscriptions super easily\n\n```python\nfrom graphql_client import GraphQLClient\n\nquery = \"\"\"\n  subscription {\n    notifications {\n      id\n      title\n      content\n    }\n  }\n\"\"\"\n\ndef callback(_id, data):\n  print(\"got new data..\")\n  print(f\"msg id: {_id}. data: {data}\")\n\nwith GraphQLClient('ws://localhost:8080/graphql') as client:\n  sub_id = client.subscribe(query, callback=callback)\n  # do other stuff\n  # ...\n  # later stop the subscription\n  client.stop_subscribe(sub_id)\n```\n\n### Variables can be passed\n\n```python\nfrom graphql_client import GraphQLClient\n\nquery = \"\"\"\n    subscription ($limit: Int!) {\n      notifications (order_by: {created: \"desc\"}, limit: $limit) {\n        id\n        title\n        content\n      }\n    }\n  \"\"\"\n\ndef callback(_id, data):\n  print(\"got new data..\")\n  print(f\"msg id: {_id}. data: {data}\")\n\nwith GraphQLClient('ws://localhost:8080/graphql') as client:\n  sub_id = client.subscribe(query, variables={'limit': 10}, callback=callback)\n  # ...\n```\n\n### Headers can be passed too\n\n```python\nfrom graphql_client import GraphQLClient\n\nquery = \"\"\"\n    subscription ($limit: Int!) {\n      notifications (order_by: {created: \"desc\"}, limit: $limit) {\n        id\n        title\n        content\n      }\n    }\n  \"\"\"\n\ndef callback(_id, data):\n  print(\"got new data..\")\n  print(f\"msg id: {_id}. data: {data}\")\n\nwith GraphQLClient('ws://localhost:8080/graphql') as client:\n  sub_id = client.subscribe(query,\n                            variables={'limit': 10},\n                            headers={'Authorization': 'Bearer xxxx'},\n                            callback=callback)\n  ...\n  client.stop_subscribe(sub_id)\n```\n\n### Normal queries and mutations work too\n\n```python\nfrom graphql_client import GraphQLClient\n\nquery = \"\"\"\n  query ($limit: Int!) {\n    notifications (order_by: {created: \"desc\"}, limit: $limit) {\n      id\n      title\n      content\n    }\n  }\n\"\"\"\n\nwith GraphQLClient('ws://localhost:8080/graphql') as client:\n    res = client.query(query, variables={'limit': 10}, headers={'Authorization': 'Bearer xxxx'})\n    print(res)\n```\n\n### Without the context manager API\n\n```python\nfrom graphql_client import GraphQLClient\n\nquery = \"\"\"\n  query ($limit: Int!) {\n    notifications (order_by: {created: \"desc\"}, limit: $limit) {\n      id\n      title\n      content\n    }\n  }\n\"\"\"\n\nclient = GraphQLClient('ws://localhost:8080/graphql')\nres = client.query(query, variables={'limit': 10}, headers={'Authorization': 'Bearer xxxx'})\nprint(res)\nclient.close()\n```\n\n\n## TODO\n- support http as well\n- should use asyncio websocket library?\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fecthiender%2Fpy-graphql-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fecthiender%2Fpy-graphql-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fecthiender%2Fpy-graphql-client/lists"}