From 0981661d0f3480372018a5d42cf65daa98b617a5 Mon Sep 17 00:00:00 2001 From: Botberry Date: Fri, 20 Dec 2024 13:23:33 +0000 Subject: [PATCH] =?UTF-8?q?Release=20=F0=9F=8D=93=200.255.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++ RELEASE.md | 51 --------------------------------------------- pyproject.toml | 2 +- 3 files changed, 57 insertions(+), 52 deletions(-) delete mode 100644 RELEASE.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 1860c83b46..71e9c96740 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,62 @@ CHANGELOG ========= +0.255.0 - 2024-12-20 +-------------------- + +This release adds support for making Relay connection optional, this is useful +when you want to add permission classes to the connection and not fail the whole +query if the user doesn't have permission to access the connection. + +Example: + +```python +import strawberry +from strawberry import relay +from strawberry.permission import BasePermission + + +class IsAuthenticated(BasePermission): + message = "User is not authenticated" + + # This method can also be async! + def has_permission( + self, source: typing.Any, info: strawberry.Info, **kwargs + ) -> bool: + return False + + +@strawberry.type +class Fruit(relay.Node): + code: relay.NodeID[int] + name: str + weight: float + + @classmethod + def resolve_nodes( + cls, + *, + info: strawberry.Info, + node_ids: Iterable[str], + ): + return [] + + +@strawberry.type +class Query: + node: relay.Node = relay.node() + + @relay.connection( + relay.ListConnection[Fruit] | None, permission_classes=[IsAuthenticated()] + ) + def fruits(self) -> Iterable[Fruit]: + # This can be a database query, a generator, an async generator, etc + return all_fruits.values() +``` + +Contributed by [Patrick Arminio](https://github.com/patrick91) via [PR #3707](https://github.com/strawberry-graphql/strawberry/pull/3707/) + + 0.254.1 - 2024-12-20 -------------------- diff --git a/RELEASE.md b/RELEASE.md deleted file mode 100644 index b099974c24..0000000000 --- a/RELEASE.md +++ /dev/null @@ -1,51 +0,0 @@ -Release type: minor - -This release adds support for making Relay connection optional, this is useful -when you want to add permission classes to the connection and not fail the whole -query if the user doesn't have permission to access the connection. - -Example: - -```python -import strawberry -from strawberry import relay -from strawberry.permission import BasePermission - - -class IsAuthenticated(BasePermission): - message = "User is not authenticated" - - # This method can also be async! - def has_permission( - self, source: typing.Any, info: strawberry.Info, **kwargs - ) -> bool: - return False - - -@strawberry.type -class Fruit(relay.Node): - code: relay.NodeID[int] - name: str - weight: float - - @classmethod - def resolve_nodes( - cls, - *, - info: strawberry.Info, - node_ids: Iterable[str], - ): - return [] - - -@strawberry.type -class Query: - node: relay.Node = relay.node() - - @relay.connection( - relay.ListConnection[Fruit] | None, permission_classes=[IsAuthenticated()] - ) - def fruits(self) -> Iterable[Fruit]: - # This can be a database query, a generator, an async generator, etc - return all_fruits.values() -``` diff --git a/pyproject.toml b/pyproject.toml index 88962ee7ab..0fa895578c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [tool.poetry] name = "strawberry-graphql" packages = [ { include = "strawberry" } ] -version = "0.254.1" +version = "0.255.0" description = "A library for creating GraphQL APIs" authors = ["Patrick Arminio "] license = "MIT"