File tree Expand file tree Collapse file tree 3 files changed +38
-33
lines changed Expand file tree Collapse file tree 3 files changed +38
-33
lines changed Original file line number Diff line number Diff line change 1
1
CHANGELOG
2
2
=========
3
3
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
+
4
41
0.253.1 - 2024-12-03
5
42
--------------------
6
43
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
[tool .poetry ]
2
2
name = " strawberry-graphql"
3
3
packages = [ { include = " strawberry" } ]
4
- version = " 0.253.1 "
4
+ version = " 0.254.0 "
5
5
description = " A library for creating GraphQL APIs"
6
6
authors = [
" Patrick Arminio <[email protected] >" ]
7
7
license = " MIT"
You can’t perform that action at this time.
0 commit comments