From 6ea55144afeef232f54ab8d82c8d74ad7d5f9998 Mon Sep 17 00:00:00 2001 From: Botberry Date: Fri, 13 Dec 2024 09:36:39 +0000 Subject: [PATCH] =?UTF-8?q?Release=20=F0=9F=8D=93=200.254.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 37 +++++++++++++++++++++++++++++++++++++ RELEASE.md | 32 -------------------------------- pyproject.toml | 2 +- 3 files changed, 38 insertions(+), 33 deletions(-) delete mode 100644 RELEASE.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 604fa11e3d..0c820f55e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,43 @@ CHANGELOG ========= +0.254.0 - 2024-12-13 +-------------------- + +This release adds a new `on_ws_connect` method to all HTTP view integrations. +The method is called when a `graphql-transport-ws` or `graphql-ws` connection is +established and can be used to customize the connection acknowledgment behavior. + +This is particularly useful for authentication, authorization, and sending a +custom acknowledgment payload to clients when a connection is accepted. For +example: + +```python +class MyGraphQLView(GraphQLView): + async def on_ws_connect(self, context: Dict[str, object]): + connection_params = context["connection_params"] + + if not isinstance(connection_params, dict): + # Reject without a custom graphql-ws error payload + raise ConnectionRejectionError() + + if connection_params.get("password") != "secret: + # Reject with a custom graphql-ws error payload + raise ConnectionRejectionError({"reason": "Invalid password"}) + + if username := connection_params.get("username"): + # Accept with a custom acknowledgement payload + return {"message": f"Hello, {username}!"} + + # Accept without a acknowledgement payload + return await super().on_ws_connect(context) +``` + +Take a look at our documentation to learn more. + +Contributed by [Jonathan Ehwald](https://github.com/DoctorJohn) via [PR #3720](https://github.com/strawberry-graphql/strawberry/pull/3720/) + + 0.253.1 - 2024-12-03 -------------------- diff --git a/RELEASE.md b/RELEASE.md deleted file mode 100644 index 2a0c1a0554..0000000000 --- a/RELEASE.md +++ /dev/null @@ -1,32 +0,0 @@ -Release type: minor - -This release adds a new `on_ws_connect` method to all HTTP view integrations. -The method is called when a `graphql-transport-ws` or `graphql-ws` connection is -established and can be used to customize the connection acknowledgment behavior. - -This is particularly useful for authentication, authorization, and sending a -custom acknowledgment payload to clients when a connection is accepted. For -example: - -```python -class MyGraphQLView(GraphQLView): - async def on_ws_connect(self, context: Dict[str, object]): - connection_params = context["connection_params"] - - if not isinstance(connection_params, dict): - # Reject without a custom graphql-ws error payload - raise ConnectionRejectionError() - - if connection_params.get("password") != "secret: - # Reject with a custom graphql-ws error payload - raise ConnectionRejectionError({"reason": "Invalid password"}) - - if username := connection_params.get("username"): - # Accept with a custom acknowledgement payload - return {"message": f"Hello, {username}!"} - - # Accept without a acknowledgement payload - return await super().on_ws_connect(context) -``` - -Take a look at our documentation to learn more. diff --git a/pyproject.toml b/pyproject.toml index 2bd6c353a9..f346e8176b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [tool.poetry] name = "strawberry-graphql" packages = [ { include = "strawberry" } ] -version = "0.253.1" +version = "0.254.0" description = "A library for creating GraphQL APIs" authors = ["Patrick Arminio "] license = "MIT"