abn / aiographql-client Goto Github PK
View Code? Open in Web Editor NEWAn asynchronous GraphQL client built on top of aiohttp and graphql-core-next
Home Page: https://aiographql-client.readthedocs.io/
License: MIT License
An asynchronous GraphQL client built on top of aiohttp and graphql-core-next
Home Page: https://aiographql-client.readthedocs.io/
License: MIT License
Hello!
I have a use case that requires the serialization of uuid.UUID
s and Python's json
cannot serialize them.
While I can str(uuid)
before-hand, I think adding support for multiple json
serializers is a plus (e.g. orjson
is much faster and supports more types).
Would this be a feature you're interested in?
Dependabot couldn't reach https://nexus.eng.twyla.ai/repository/pypi-private/simple/ as it timed out.
Is https://nexus.eng.twyla.ai/repository/pypi-private/simple/ accessible over the internet? If it is then this may be a transitory issue and can be ignored - Dependabot will close it on its next successful update run.
Apologies if this is somewhere in the documentation and I've missed it, but I am trying to parse a GraphQLResponse
, and convert it into proper typed object from the schema definition that is in the client. I can call schema.get_type("my_type")
from graphql-core
but not sure how to deserialise the dict
contained into GraphQLResponse
to that. If we are passing schema in the client is this something that could be natively done?
Hi,
The graphql server I'm querying has introspection disabled. I'd like to still be able to use aiograhql.
Thanks!
Example of the code:
client = GraphQLClient(
endpoint=graphql_endpoint,
headers=self.auth_headers
)
request = GraphQLRequest(
query="""
query doSearchIdentities($person: Person!, $address: Address!) {
normalize(person: $person, address: $address) {
<stripped>
}
}
"""
)
response: GraphQLResponse = await client.query(
request=request,
variables={
'person': person,
'address': address
}
)
return response.json
Exception:
logger: asyncio
message:
return await self._http_request(
TypeError: 'async with' received an object from __aexit__ that does not implement __await__: type
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7f3de80d3990>
python --version
Python 3.8.5
pip freeze
aiographql-client==1.0.2
uname -a
Linux 5.4.0-42-generic #46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
helpers.py could be like this
import aiohttp
def aiohttp_client_session():
connector = aiohttp.TCPConnector(
force_close=True, limit=1, enable_cleanup_closed=True
)
return aiohttp.ClientSession(connector=connector)
I'm receiving this error trying to install it
> pip install aiographql-client
ERROR: Could not find a version that satisfies the requirement aiographql-client (from versions: none)
ERROR: No matching distribution found for aiographql-client
Originally raised in #166 by @serializingme
Another issue I had was the need to have some extra data on the CONNECTION_INIT
payload. I modified the connection_init_request
in client\subscription.py:138
to add extra content to the returned dictionary:
return {
"type": GraphQLSubscriptionEventType.CONNECTION_INIT.value,
"payload": {**extra_data, "headers": {**self.request.headers}},
}
Hello everyone! Thanks for the great package!
I need support for ujson
version 4. My repositories already use version 4.x and I can't install this library because of this.
In a virtualenv: /tmp/venv/bin/pip install "aiographql-client>=1.0.3"
gives:
…
Installing build dependencies ... done
Getting requirements to build wheel ... error
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [54 lines of output]
running egg_info
writing lib3/PyYAML.egg-info/PKG-INFO
writing dependency_links to lib3/PyYAML.egg-info/dependency_links.txt
writing top-level names to lib3/PyYAML.egg-info/top_level.txt
Traceback (most recent call last):
File "/tmp/venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
main()
File "/tmp/venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
return hook(config_settings)
^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-2j9_0ad1/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 325, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=['wheel'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-2j9_0ad1/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires
self.run_setup()
File "/tmp/pip-build-env-2j9_0ad1/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 311, in run_setup
exec(code, locals())
File "<string>", line 271, in <module>
File "/tmp/pip-build-env-2j9_0ad1/overlay/lib/python3.11/site-packages/setuptools/__init__.py", line 103, in setup
return distutils.core.setup(**attrs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-2j9_0ad1/overlay/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 185, in setup
return run_commands(dist)
^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-2j9_0ad1/overlay/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
dist.run_commands()
File "/tmp/pip-build-env-2j9_0ad1/overlay/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
self.run_command(cmd)
File "/tmp/pip-build-env-2j9_0ad1/overlay/lib/python3.11/site-packages/setuptools/dist.py", line 963, in run_command
super().run_command(command)
File "/tmp/pip-build-env-2j9_0ad1/overlay/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
cmd_obj.run()
File "/tmp/pip-build-env-2j9_0ad1/overlay/lib/python3.11/site-packages/setuptools/command/egg_info.py", line 321, in run
self.find_sources()
File "/tmp/pip-build-env-2j9_0ad1/overlay/lib/python3.11/site-packages/setuptools/command/egg_info.py", line 329, in find_sources
mm.run()
File "/tmp/pip-build-env-2j9_0ad1/overlay/lib/python3.11/site-packages/setuptools/command/egg_info.py", line 551, in run
self.add_defaults()
File "/tmp/pip-build-env-2j9_0ad1/overlay/lib/python3.11/site-packages/setuptools/command/egg_info.py", line 589, in add_defaults
sdist.add_defaults(self)
File "/tmp/pip-build-env-2j9_0ad1/overlay/lib/python3.11/site-packages/setuptools/command/sdist.py", line 112, in add_defaults
super().add_defaults()
File "/tmp/pip-build-env-2j9_0ad1/overlay/lib/python3.11/site-packages/setuptools/_distutils/command/sdist.py", line 251, in add_defaults
self._add_defaults_ext()
File "/tmp/pip-build-env-2j9_0ad1/overlay/lib/python3.11/site-packages/setuptools/_distutils/command/sdist.py", line 336, in _add_defaults_ext
self.filelist.extend(build_ext.get_source_files())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<string>", line 201, in get_source_files
File "/tmp/pip-build-env-2j9_0ad1/overlay/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 107, in __getattr__
raise AttributeError(attr)
AttributeError: cython_sources
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
Hi,
I have been trying to integrate the library and found some problems. After much debugging 😅 follows the two issues and the solutions I found:
Sec-WebSocket-Protocol
HeaderWhen establishing the Web Socket connection to the Apollo server the server will reject the connection without any feedback if the header Sec-WebSocket-Protocol
is not provided. The expected value for the header is graphql-ws
. I worked around this by modifying the code with (client\subscription.py:201
):
headers = {
'Sec-WebSocket-Protocol': 'graphql-ws'
}
async with session.ws_connect(endpoint, headers=headers) as ws:
CONNECTION_INIT
Another issue I had was the need to have some extra data on the CONNECTION_INIT
payload. I modified the connection_init_request
in client\subscription.py:138
to add extra content to the returned dictionary:
return {
"type": GraphQLSubscriptionEventType.CONNECTION_INIT.value,
"payload": {**extra_data, "headers": {**self.request.headers}},
}
I would be very thankful if this could be fixed / supported. Let me know if I can help, thank you in advance! 😃
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.