%global _empty_manifest_terminate_build 0 Name: python-py-graphql-client Version: 0.1.1 Release: 1 Summary: A dead-simple GraphQL client that supports subscriptions over websockets License: BSD3 URL: https://github.com/ecthiender/py-graphql-client Source0: https://mirrors.nju.edu.cn/pypi/web/packages/ed/7b/82dd4408dca40b545641d5024171a436e265bc1a8d17a81fe1f7725e65e9/py-graphql-client-0.1.1.tar.gz BuildArch: noarch Requires: python3-websocket-client %description # py-graphql-client Dead-simple to use GraphQL client over websocket. Using the [apollo-transport-ws](https://github.com/apollographql/subscriptions-transport-ws/blob/master/PROTOCOL.md) protocol. ## Install ```bash pip install py-graphql-client ``` ## Examples ### Setup subscriptions super easily ```python from graphql_client import GraphQLClient ws = GraphQLClient('ws://localhost:8080/graphql') def callback(_id, data): print("got new data..") print(f"msg id: {_id}. data: {data}") query = """ subscription { notifications { id title content } } """ sub_id = ws.subscribe(query, callback=callback) ... # later stop the subscription ws.stop_subscribe(sub_id) ws.close() ``` ### Variables can be passed ```python from graphql_client import GraphQLClient ws = GraphQLClient('ws://localhost:8080/graphql') def callback(_id, data): print("got new data..") print(f"msg id: {_id}. data: {data}") query = """ subscription ($limit: Int!) { notifications (order_by: {created: "desc"}, limit: $limit) { id title content } } """ sub_id = ws.subscribe(query, variables={'limit': 10}, callback=callback) ``` ### Normal queries and mutations work too ```python from graphql_client import GraphQLClient ws = GraphQLClient('ws://localhost:8080/graphql') query = """ query ($limit: Int!) { notifications (order_by: {created: "desc"}, limit: $limit) { id title content } } """ res = ws.query(query, variables={'limit': 10}) print(res) ws.close() ``` ## TODO - support http as well - should use asyncio websocket library? %package -n python3-py-graphql-client Summary: A dead-simple GraphQL client that supports subscriptions over websockets Provides: python-py-graphql-client BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-pip %description -n python3-py-graphql-client # py-graphql-client Dead-simple to use GraphQL client over websocket. Using the [apollo-transport-ws](https://github.com/apollographql/subscriptions-transport-ws/blob/master/PROTOCOL.md) protocol. ## Install ```bash pip install py-graphql-client ``` ## Examples ### Setup subscriptions super easily ```python from graphql_client import GraphQLClient ws = GraphQLClient('ws://localhost:8080/graphql') def callback(_id, data): print("got new data..") print(f"msg id: {_id}. data: {data}") query = """ subscription { notifications { id title content } } """ sub_id = ws.subscribe(query, callback=callback) ... # later stop the subscription ws.stop_subscribe(sub_id) ws.close() ``` ### Variables can be passed ```python from graphql_client import GraphQLClient ws = GraphQLClient('ws://localhost:8080/graphql') def callback(_id, data): print("got new data..") print(f"msg id: {_id}. data: {data}") query = """ subscription ($limit: Int!) { notifications (order_by: {created: "desc"}, limit: $limit) { id title content } } """ sub_id = ws.subscribe(query, variables={'limit': 10}, callback=callback) ``` ### Normal queries and mutations work too ```python from graphql_client import GraphQLClient ws = GraphQLClient('ws://localhost:8080/graphql') query = """ query ($limit: Int!) { notifications (order_by: {created: "desc"}, limit: $limit) { id title content } } """ res = ws.query(query, variables={'limit': 10}) print(res) ws.close() ``` ## TODO - support http as well - should use asyncio websocket library? %package help Summary: Development documents and examples for py-graphql-client Provides: python3-py-graphql-client-doc %description help # py-graphql-client Dead-simple to use GraphQL client over websocket. Using the [apollo-transport-ws](https://github.com/apollographql/subscriptions-transport-ws/blob/master/PROTOCOL.md) protocol. ## Install ```bash pip install py-graphql-client ``` ## Examples ### Setup subscriptions super easily ```python from graphql_client import GraphQLClient ws = GraphQLClient('ws://localhost:8080/graphql') def callback(_id, data): print("got new data..") print(f"msg id: {_id}. data: {data}") query = """ subscription { notifications { id title content } } """ sub_id = ws.subscribe(query, callback=callback) ... # later stop the subscription ws.stop_subscribe(sub_id) ws.close() ``` ### Variables can be passed ```python from graphql_client import GraphQLClient ws = GraphQLClient('ws://localhost:8080/graphql') def callback(_id, data): print("got new data..") print(f"msg id: {_id}. data: {data}") query = """ subscription ($limit: Int!) { notifications (order_by: {created: "desc"}, limit: $limit) { id title content } } """ sub_id = ws.subscribe(query, variables={'limit': 10}, callback=callback) ``` ### Normal queries and mutations work too ```python from graphql_client import GraphQLClient ws = GraphQLClient('ws://localhost:8080/graphql') query = """ query ($limit: Int!) { notifications (order_by: {created: "desc"}, limit: $limit) { id title content } } """ res = ws.query(query, variables={'limit': 10}) print(res) ws.close() ``` ## TODO - support http as well - should use asyncio websocket library? %prep %autosetup -n py-graphql-client-0.1.1 %build %py3_build %install %py3_install install -d -m755 %{buildroot}/%{_pkgdocdir} if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi pushd %{buildroot} if [ -d usr/lib ]; then find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/lib64 ]; then find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/bin ]; then find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/sbin ]; then find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst fi touch doclist.lst if [ -d usr/share/man ]; then find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst fi popd mv %{buildroot}/filelist.lst . mv %{buildroot}/doclist.lst . %files -n python3-py-graphql-client -f filelist.lst %dir %{python3_sitelib}/* %files help -f doclist.lst %{_docdir}/* %changelog * Wed May 10 2023 Python_Bot - 0.1.1-1 - Package Spec generated