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 renames _type_definition
to __strawberry_definition__
. This doesn't change the public API of Strawberry, but if you were using _type_definition
you can still access it, but it will be removed in future.
Releases contributed by @nrbnlulu via #2836
Published by botberry over 1 year ago
This release adds resolve_async to NodeExtension to allow it to
be used together with other field async extensions/permissions.
Releases contributed by @bellini666 via #2863
Published by botberry over 1 year ago
This release fixes an issue on StrawberryField.copy_with method
not copying its extensions and overwritten _arguments
.
Also make sure that all lists/tuples in those types are copied as
new lists/tuples to avoid unexpected behavior.
Releases contributed by @bellini666 via #2865
Published by botberry over 1 year ago
In this release, we pass the default values from the strawberry.Schema through to the codegen plugins.
The default python plugin now adds these default values to the objects it generates.
Releases contributed by @mgilson via #2860
Published by botberry over 1 year ago
This release removes more parts of the Mypy plugin, since they are
not needed anymore.
Releases contributed by @patrick91 via #2852
Published by botberry over 1 year ago
This release fixes a bug causing a KeyError exception to be thrown during subscription cleanup.
Releases contributed by @rjwills28 via #2794
Published by botberry over 1 year ago
Correct a type-hinting bug with strawberry.directive
.
This may cause some consumers to have to remove a # type: ignore
comment
or unnecessary typing.cast
in order to get mypy
to pass.
Releases contributed by @mgilson via #2847
Published by botberry over 1 year ago
This release removes our custom __dataclass_transform__
decorator and replaces
it with typing-extension's one. It also removes parts of the mypy plugin, since
most of it is not needed anymore 🙌
This update requires typing_extensions>=4.1.0
Releases contributed by @patrick91 via #2227
Published by botberry over 1 year ago
This release migrates our CLI to typer, all commands
should work the same as before.
Releases contributed by @patrick91 via #2569
Published by botberry over 1 year ago
This release improves the relay.NodeID
annotation check by delaying it until after class initialization. This resolves issues with evaluating type annotations before they are fully defined and enables integrations to inject code for it in the type.
Releases contributed by @bellini666 via #2838
Published by botberry over 1 year ago
This release fixes a bug in the codegen where List
objects are currently emitted
as Optional
objects.
Releases contributed by @mgilson via #2843
Published by botberry over 1 year ago
Refactor ConnectionExtension
to copy arguments instead of extending them.
This should fix some issues with integrations which override arguments
,
like the django one, where the inserted arguments were vanishing.
Releases contributed by @bellini666 via #2839
Published by botberry over 1 year ago
This release fixes a bug where codegen would fail on mutations that have object arguments in the query.
Additionally, it does a topological sort of the types before passing it to the plugins to ensure that
dependent types are defined after their dependencies.
Releases contributed by @mgilson via #2831
Published by botberry over 1 year ago
This release fixes an issue where Strawberry would make copies
of types that were using specialized generics that were not
Strawerry types.
This issue combined with the use of lazy types was resulting
in duplicated type errors.
Releases contributed by @patrick91 via #2824
Published by botberry over 1 year ago
This release fixes an issue for parsing lazy types using forward references
when they were enclosed in an Optional[...]
type.
The following now should work properly:
from __future__ import annotations
from typing import Optional, Annotated
import strawberry
@strawberry.type
class MyType:
other_type: Optional[Annotated["OtherType", strawberry.lazy("some.module")]]
# or like this
other_type: Annotated["OtherType", strawberry.lazy("some.module")] | None
Releases contributed by @bellini666 via #2821
Published by botberry over 1 year ago
This release fixes a codegen bug. Prior to this fix,
inline fragments would only include the last field defined
within its scope and all fields common with its siblings.
After this fix, all fields will be included in the
generated types.
Releases contributed by @mgilson via #2819
Published by botberry over 1 year ago
Fields with generics support directives.
Releases contributed by @coady via #2811
Published by botberry over 1 year ago
This release fixes an issue of the new relay integration adding an id: GlobalID!
argument on all objects that inherit from relay.Node
. That should've only happened
for Query
types.
Strawberry now will not force a relay.Node
or any type that inherits it to be
inject the node extension which adds the argument and a resolver for it, meaning that
this code:
import strawberry
from strawberry import relay
@strawberry.type
class Fruit(relay.Node):
id: relay.NodeID[int]
@strawberry.type
class Query:
node: relay.Node
fruit: Fruit
Should now be written as:
import strawberry
from strawberry import relay
@strawberry.type
class Fruit(relay.Node):
id: relay.NodeID[int]
@strawberry.type
class Query:
node: relay.Node = relay.node() # <- note the "= relay.node()" here
fruit: Fruit = relay.node()
Releases contributed by @bellini666 via #2814
Published by botberry over 1 year ago
This release adds a new field extension called InputMutationExtension
, which makes
it easier to create mutations that receive a single input type called input
,
while still being able to define the arguments of that input on the resolver itself.
The following example:
import strawberry
from strawberry.field_extensions import InputMutationExtension
@strawberry.type
class Fruit:
id: strawberry.ID
name: str
weight: float
@strawberry.type
class Mutation:
@strawberry.mutation(extensions=[InputMutationExtension()])
def update_fruit_weight(
self,
info: Info,
id: strawberry.ID,
weight: Annotated[
float,
strawberry.argument(description="The fruit's new weight in grams"),
],
) -> Fruit:
fruit = ... # retrieve the fruit with the given ID
fruit.weight = weight
... # maybe save the fruit in the database
return fruit
Would generate a schema like this:
input UpdateFruitInput {
id: ID!
"""
The fruit's new weight in grams
"""
weight: Float!
}
type Fruit {
id: ID!
name: String!
weight: Float!
}
type Mutation {
updateFruitWeight(input: UpdateFruitInput!): Fruit!
}
Releases contributed by @bellini666 via #2580
Published by botberry over 1 year ago
Initial relay spec implementation. For information on how to use
it, check out the docs in here: https://strawberry.rocks/docs/guides/relay
Releases contributed by @bellini666 via #2511