Skip to content

Commit

Permalink
Add release file
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick91 committed Dec 9, 2024
1 parent 2cdbcfa commit e314998
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
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()
```

0 comments on commit e314998

Please sign in to comment.