Skip to content

Releases: strawberry-graphql/strawberry

🍓 0.256.1

23 Dec 09:03
Compare
Choose a tag to compare

This release updates Strawberry internally to no longer pass keywords arguments
to pathlib.PurePath. Support for supplying keyword arguments to
pathlib.PurePath is deprecated and scheduled for removal in Python 3.14

Releases contributed by @DoctorJohn via #3738

🍓 0.256.0

21 Dec 13:29
Compare
Choose a tag to compare

This release drops support for Python 3.8, which reached its end-of-life (EOL)
in October 2024. The minimum supported Python version is now 3.9.

We strongly recommend upgrading to Python 3.9 or a newer version, as older
versions are no longer maintained and may contain security vulnerabilities.

Releases contributed by @bellini666 via #3730

🍓 0.255.0

20 Dec 13:23
Compare
Choose a tag to compare

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:

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()

Releases contributed by @patrick91 via #3707

🍓 0.254.1

20 Dec 13:04
Compare
Choose a tag to compare

This release updates the Context and RootValue vars to have
a default value of None, this makes it easier to use the views
without having to pass in a value for these vars.

Releases contributed by @patrick91 via #3732

🍓 0.254.0

13 Dec 09:37
Compare
Choose a tag to compare

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:

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.

Releases contributed by @DoctorJohn via #3720

🍓 0.253.1

03 Dec 23:25
Compare
Choose a tag to compare

Description:
Fixed a bug in the OpenTelemetryExtension class where the _span_holder dictionary was incorrectly shared across all instances. This was caused by defining _span_holder as a class-level attribute with a mutable default value (dict()).

Releases contributed by @conglei via #3716

🍓 0.253.0

23 Nov 15:49
Compare
Choose a tag to compare

In this release, the return types of the get_root_value and get_context
methods were updated to be consistent across all view integrations. Before this
release, the return types used by the ASGI and Django views were too generic.

Releases contributed by @DoctorJohn via #3712

🍓 0.252.0

22 Nov 11:40
Compare
Choose a tag to compare

The view classes of all integrations now have a decode_json method that allows
you to customize the decoding of HTTP JSON requests.

This is useful if you want to use a different JSON decoder, for example, to
optimize performance.

Releases contributed by @DoctorJohn via #3709

🍓 0.251.0

21 Nov 11:00
Compare
Choose a tag to compare

Starting with this release, the same JSON encoder is used to encode HTTP
responses and WebSocket messages.

This enables developers to override the encode_json method on their views to
customize the JSON encoder used by all web protocols.

Releases contributed by @DoctorJohn via #3708

🍓 0.250.1

19 Nov 10:45
Compare
Choose a tag to compare

This release refactors part of the legacy graphql-ws protocol implementation, making it easier to read, maintain, and extend.

Releases contributed by @DoctorJohn via #3704