A GraphQL library for Python that leverages type annotations 🍓
MIT License
Bot releases are hidden (Show)
Published by botberry over 1 year ago
This release includes a performance improvement to strawberry.lazy()
to allow relative module imports to be resolved faster.
Releases contributed by @karimsa via #2926
Published by botberry over 1 year ago
This release adds a setter on StrawberryAnnotation.annotation
, this fixes
an issue on Strawberry Django.
Releases contributed by @patrick91 via #2932
Published by botberry over 1 year ago
Restore evaled type access in StrawberryAnnotation
Prior to Strawberry 192.2 the annotation
attribute of StrawberryAnnotation
would return an evaluated type when possible due reserved argument parsing.
192.2 moved the responsibility of evaluating and caching results to the
evaluate
method of StrawberryAnnotation
. This introduced a regression when
using future annotations for any code implicitely relying on the annotation
attribute being an evaluated type.
To fix this regression and mimick pre-192.2 behavior, this release adds an
annotation
property to StrawberryAnnotation
that internally calls the
evaluate
method. On success the evaluated type is returned. If a NameError
is raised due to an unresolvable annotation, the raw annotation is returned.
Releases contributed by @skilkis via #2925
Published by botberry over 1 year ago
This fixes a regression from 0.190.0 where changes to the
return type of a field done by Field Extensions would not
be taken in consideration by the schema.
Releases contributed by @bellini666 via #2922
Published by botberry over 1 year ago
This release updates the API to listen to Django Channels to avoid race conditions
when confirming GraphQL subscriptions.
Deprecations:
This release contains a deprecation for the Channels integration. The channel_listen
method will be replaced with an async context manager that returns an awaitable
AsyncGenerator. This method is called listen_to_channel
.
An example of migrating existing code is given below:
# Existing code
@strawberry.type
class MyDataType:
name: str
@strawberry.type
class Subscription:
@strawberry.subscription
async def my_data_subscription(
self, info: Info, groups: list[str]
) -> AsyncGenerator[MyDataType | None, None]:
yield None
async for message in info.context["ws"].channel_listen("my_data", groups=groups):
yield MyDataType(name=message["payload"])
# New code
@strawberry.type
class Subscription:
@strawberry.subscription
async def my_data_subscription(
self, info: Info, groups: list[str]
) -> AsyncGenerator[MyDataType | None, None]:
async with info.context["ws"].listen_to_channel("my_data", groups=groups) as cm:
yield None
async for message in cm:
yield MyDataType(name=message["payload"])
Releases contributed by @moritz89 via #2856
Published by botberry over 1 year ago
This release fixes an issue related to using typing.Annotated
in resolver
arguments following the declaration of a reserved argument such as
strawberry.types.Info
.
Before this fix, the following would be converted incorrectly:
from __future__ import annotations
import strawberry
import uuid
from typing_extensions import Annotated
from strawberry.types import Info
@strawberry.type
class Query:
@strawberry.field
def get_testing(
self,
info: Info[None, None],
id_: Annotated[uuid.UUID, strawberry.argument(name="id")],
) -> str | None:
return None
schema = strawberry.Schema(query=Query)
print(schema)
Resulting in the schema:
type Query {
getTesting(id_: UUID!): String # ⬅️ see `id_`
}
scalar UUID
After this fix, the schema is converted correctly:
type Query {
getTesting(id: UUID!): String
}
scalar UUID
Releases contributed by @skilkis via #2901
Published by botberry over 1 year ago
Add specifications in FastAPI doc if query via GET is enabled
Releases contributed by @guillaumeLepape via #2913
Published by botberry over 1 year ago
This release introduces a new command called upgrade
, this command can be used
to run codemods on your codebase to upgrade to the latest version of Strawberry.
At the moment we only support upgrading unions to use the new syntax with
annotated, but in future we plan to add more commands to help with upgrading.
Here's how you can use the command to upgrade your codebase:
strawberry upgrade annotated-union .
Releases contributed by @patrick91 via #2886
Published by botberry over 1 year ago
This release adds support for declaring union types using typing.Annotated
instead of strawberry.union(name, types=...)
.
Code using the old syntax will continue to work, but it will trigger a
deprecation warning. Using Annotated will improve type checking and IDE support
especially when using pyright
.
Before:
Animal = strawberry.union("Animal", (Cat, Dog))
After:
from typing import Annotated, Union
Animal = Annotated[Union[Cat, Dog], strawberry.union("Animal")]
Published by botberry over 1 year ago
This release refactors the way we resolve field types to to make it
more robust, resolving some corner cases.
One case that should be fixed is when using specialized generics
with future annotations.
Releases contributed by @devkral via #2868
Published by botberry over 1 year ago
This release removes some usage of deprecated functions from GraphQL-core.
Releases contributed by @kristjanvalur via #2894
Published by botberry over 1 year ago
The graphql-transport-ws
protocol allows for subscriptions to error during execution without terminating
the subscription. Non-fatal errors produced by subscriptions now produce Next
messages containing
an ExecutionResult
with an error
field and don't necessarily terminate the subscription.
This is in accordance to the behaviour of Apollo server.
Releases contributed by @kristjanvalur via #2876
Published by botberry over 1 year ago
This release fixes a depreaction warning being triggered
by the relay integration.
Releases contributed by @patrick91 via #2858
Published by botberry over 1 year ago
This release updates create_type
to add support for all arguments
that strawberry.type
supports. This includes: description
, extend
,
directives
, is_input
and is_interface
.
Releases contributed by @patrick91 via #2880
Published by botberry over 1 year ago
This release gives codegen clients the ability to inquire about the __typename
of a GraphQLObjectType
. This information can be used to automatically select
the proper type to hydrate when working with a union type in the response.
Releases contributed by @mgilson via #2875
Published by botberry over 1 year ago
This release fixes a regression when comparing a StrawberryAnnotation
instance with anything that is not also a StrawberryAnnotation
instance,
which caused it to raise a NotImplementedError
.
This reverts its behavior back to how it worked before, where it returns
NotImplemented
instead, meaning that the comparison can be delegated to
the type being compared against or return False
in case it doesn't define
an __eq__
method.
Releases contributed by @bellini666 via #2879
Published by botberry over 1 year ago
graphql-transport-ws
handler now uses a single dict to manage active operations.
Releases contributed by @kristjanvalur via #2699
Published by botberry over 1 year ago
This release fixes a typing regression on StraberryContainer
subclasses
where type checkers would not allow non WithStrawberryObjectDefinition
types
to be passed for its of_type
argument (e.g. StrawberryOptional(str)
)
Releases contributed by @bellini666 via #2878
Published by botberry over 1 year ago
This release removes get_object_definition_strict
and instead
overloads get_object_definition
to accept an extra strct
keyword.
This is a new feature so it is unlikely to break anything.
Releases contributed by @bellini666 via #2877
Published by botberry over 1 year ago
This release bumps the minimum requirement of
typing-extensions
to 4.5
Releases contributed by @patrick91 via #2872