
Security News
Deno 2.4 Brings Back deno bundle, Improves Dependency Management and Observability
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
asyncio <https://docs.python.org/3/library/asyncio.html>
_ - explicit concurrency to reduce race conditions <https://glyph.twistedmatrix.com/2014/02/unyielding.html>
_graphql <http://graphql.org/>
_ - all you need and nothing more in one request +auto docs of your apiuvloop, protocol <https://github.com/MagicStack/uvloop#performance>
_ - top performance <https://magic.io/blog/uvloop-blazing-fast-python-networking/>
_/graphql
endpointUsage::
pip install aiographql
cat <<'END' >serve.py
import asyncio, aiographql, graphene
class User(graphene.ObjectType):
id = graphene.ID(required=True)
name = graphene.String()
class Query(graphene.ObjectType):
me = graphene.Field(User)
async def resolve_me(self, info):
await asyncio.sleep(1) # DB
return User(id=42, name='John')
schema = graphene.Schema(query=Query, mutation=None)
aiographql.serve(schema, listen=[
dict(protocol='tcp', port=25100),
dict(protocol='unix', path='/tmp/worker0'),
])
END
python3 serve.py
curl http://localhost:25100/ --data-binary \
'{"query": "{
me {
id
name
}
}", "variables": null}'
# OR:
curl --unix-socket /tmp/worker0 http:/ --data-binary ...
# Result:
# 1 second async await for DB and then:
{"data":{"me":{"id":"42","name":"John"}}}
See more examples and tests <https://github.com/academicmerit/aiographql/tree/master/tests>
_ about JWT auth, concurrent slow DB queries, etc.
Config::
import aiographql; help(aiographql.serve)
serve(schema, listen, get_context=None, exception_handler=None, enable_uvloop=True, run=True)
Configure the stack and start serving requests
schema
: graphene.Schema
- GraphQL schema to serve
listen
: list
- one or more endpoints to listen for connections:
dict(protocol='tcp', port=25100, ...)
- create_server() docs <https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.AbstractEventLoop.create_server>
_dict(protocol='unix', path='/tmp/worker0', ...)
- create_unix_server() docs <https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.AbstractEventLoop.create_unix_server>
_get_context
: None
or [async] callable(loop, context: dict): mixed
- to produce GraphQL context like auth from input unified with exception_handler()
exception_handler
: None
or callable(loop, context: dict)
- default or custom exception handler as defined in the docs <https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.AbstractEventLoop.set_exception_handler>
_ +
headers
: bytes
or None
- HTTP headers, if knownrequest
: dict
or bytes
or None
- accumulated HTTP request before content length is known, then accumulated content, then GraphQL requestenable_uvloop
: bool
- enable uvloop for top performance, unless you have a better loop
run
: bool
- if True
, run the loop; False
is good for tests
return servers
: Servers
- await servers.close()
to close listening sockets - good for tests
FAQs
asyncio + graphql = fast and simple api
We found that aiographql demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.