Skip to content

Commit 6ea5514

Browse files
committed
Release 🍓 0.254.0
1 parent e105975 commit 6ea5514

File tree

3 files changed

+38
-33
lines changed

3 files changed

+38
-33
lines changed

CHANGELOG.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,43 @@
11
CHANGELOG
22
=========
33

4+
0.254.0 - 2024-12-13
5+
--------------------
6+
7+
This release adds a new `on_ws_connect` method to all HTTP view integrations.
8+
The method is called when a `graphql-transport-ws` or `graphql-ws` connection is
9+
established and can be used to customize the connection acknowledgment behavior.
10+
11+
This is particularly useful for authentication, authorization, and sending a
12+
custom acknowledgment payload to clients when a connection is accepted. For
13+
example:
14+
15+
```python
16+
class MyGraphQLView(GraphQLView):
17+
async def on_ws_connect(self, context: Dict[str, object]):
18+
connection_params = context["connection_params"]
19+
20+
if not isinstance(connection_params, dict):
21+
# Reject without a custom graphql-ws error payload
22+
raise ConnectionRejectionError()
23+
24+
if connection_params.get("password") != "secret:
25+
# Reject with a custom graphql-ws error payload
26+
raise ConnectionRejectionError({"reason": "Invalid password"})
27+
28+
if username := connection_params.get("username"):
29+
# Accept with a custom acknowledgement payload
30+
return {"message": f"Hello, {username}!"}
31+
32+
# Accept without a acknowledgement payload
33+
return await super().on_ws_connect(context)
34+
```
35+
36+
Take a look at our documentation to learn more.
37+
38+
Contributed by [Jonathan Ehwald](https://github.com/DoctorJohn) via [PR #3720](https://github.com/strawberry-graphql/strawberry/pull/3720/)
39+
40+
441
0.253.1 - 2024-12-03
542
--------------------
643

RELEASE.md

Lines changed: 0 additions & 32 deletions
This file was deleted.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[tool.poetry]
22
name = "strawberry-graphql"
33
packages = [ { include = "strawberry" } ]
4-
version = "0.253.1"
4+
version = "0.254.0"
55
description = "A library for creating GraphQL APIs"
66
authors = ["Patrick Arminio <[email protected]>"]
77
license = "MIT"

0 commit comments

Comments
 (0)