Skip to content

Commit

Permalink
Subscriptions: SSE distinct connection support (#1195)
Browse files Browse the repository at this point in the history
  • Loading branch information
danplischke authored Jan 29, 2025
1 parent e23f6b1 commit b64a9d3
Show file tree
Hide file tree
Showing 7 changed files with 847 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# CHANGELOG


## 0.25 (UNRELEASED)

- Added support for GraphQL subscriptions over the Server-Sent Events (SSE).


## 0.24 (2024-12-19)

- Added validation for directive declarations in `make_executable_schema` to prevent schema creation with undeclared directives.
Expand Down
14 changes: 14 additions & 0 deletions ariadne/asgi/handlers/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ async def handle(self, scope: Scope, receive: Receive, send: Send) -> None:
response = await self.handle_request(request)
await response(scope, receive, send)

async def handle_request_override(self, _: Request) -> Optional[Response]:
"""Override the default request handling logic in subclasses.
Is called in the `handle_request` method before the default logic.
If None is returned, the default logic is executed.
# Required arguments:
`_`: the `Request` instance from Starlette or FastAPI.
"""
return None

async def handle_request(self, request: Request) -> Response:
"""Handle GraphQL request and return response for the client.
Expand All @@ -115,6 +125,10 @@ async def handle_request(self, request: Request) -> Response:
`request`: the `Request` instance from Starlette or FastAPI.
"""
response = await self.handle_request_override(request)
if response is not None:
return response

if request.method == "GET":
if self.execute_get_queries and request.query_params.get("query"):
return await self.graphql_http_server(request)
Expand Down
Loading

0 comments on commit b64a9d3

Please sign in to comment.