A GraphQL library for Python that leverages type annotations 🍓
MIT License
Bot releases are hidden (Show)
Published by botberry about 2 years ago
Support storing metadata in strawberry fields.
Published by botberry about 2 years ago
Fixes false positives with the mypy plugin.
Happened when to_pydantic
was called on a type that was converted
pydantic with all_fields=True.
Also fixes the type signature when to_pydantic
is defined by the user.
from pydantic import BaseModel
from typing import Optional
import strawberry
class MyModel(BaseModel):
email: str
password: Optional[str]
@strawberry.experimental.pydantic.input(model=MyModel, all_fields=True)
class MyModelStrawberry:
...
MyModelStrawberry(email="").to_pydantic()
# previously would complain wrongly about missing email and password
Published by botberry about 2 years ago
This release updates the mypy plugin and the typing for Pyright to treat all
strawberry fields as keyword-only arguments. This reflects a previous change to
the Strawberry API.
Published by botberry about 2 years ago
Bug fix: Do not force kw-only=False in fields specified with strawberry.field()
Published by botberry about 2 years ago
This release fixes a small issue that might happen when
uploading files and not passing the operations object.
Published by botberry about 2 years ago
Fix warnings during unit tests for Sanic's upload.
Otherwise running unit tests results in a bunch of warning like this:
DeprecationWarning: Use 'content=<...>' to upload raw bytes/text content.
Published by botberry about 2 years ago
This release improves the dataloader class with new features:
Published by botberry about 2 years ago
This release adds improved support for Pyright and Pylance, VSCode default
language server for Python.
Using strawberry.type
, strawberry.field
, strawberry.input
and
strawberry.enum
will now be correctly recognized by Pyright and Pylance and
won't show errors.
Published by botberry about 2 years ago
Fix invalid deprecation warning issued on arguments annotated
by a subclassed strawberry.types.Info
.
Thanks to @ThirVondukr for the bug report!
Example:
class MyInfo(Info)
pass
@strawberry.type
class Query:
@strawberry.field
def is_tasty(self, info: MyInfo) -> bool:
"""Subclassed ``info`` argument no longer raises deprecation warning."""
Published by botberry about 2 years ago
This release fixes the conversion of generic aliases when
using pydantic.
Published by botberry about 2 years ago
Fix version parsing issue related to dev builds of Mypy in strawberry.ext.mypy_plugin
Published by botberry about 2 years ago
Convert Tuple and Sequence types to GraphQL list types.
Example:
from collections.abc import Sequence
from typing import Tuple
@strawberry.type
class User:
pets: Sequence[Pet]
favourite_ice_cream_flavours: Tuple[IceCreamFlavour]
Published by botberry about 2 years ago
This release adds strawberry.lazy
which allows you to define the type of the
field and its path. This is useful when you want to define a field with a type
that has a circular dependency.
For example, let's say we have a User
type that has a list of Post
and a
Post
type that has a User
:
# posts.py
from typing import TYPE_CHECKING, Annotated
import strawberry
if TYPE_CHECKING:
from .users import User
@strawberry.type
class Post:
title: str
author: Annotated["User", strawberry.lazy(".users")]
# users.py
from typing import TYPE_CHECKING, Annotated, List
import strawberry
if TYPE_CHECKING:
from .posts import Post
@strawberry.type
class User:
name: str
posts: List[Annotated["Post", strawberry.lazy(".posts")]]
Published by botberry about 2 years ago
This release changes how dataclasses are created to make use of the new
kw_only
argument in Python 3.10 so that fields without a default value can now
follow a field with a default value. This feature is also backported to all other
supported Python versions.
More info: https://docs.python.org/3/library/dataclasses.html#dataclasses.dataclass
For example:
# This no longer raises a TypeError
@strawberry.type
class MyType:
a: str = "Hi"
b: int
⚠️ This is a breaking change! Whenever instantiating a Strawberry type make sure
that you only pass values are keyword arguments:
# Before:
MyType("foo", 3)
# After:
MyType(a="foo", b=3)
Published by botberry about 2 years ago
This release fixes a bug in the subscription clean up when subscribing using the
graphql-transport-ws protocol, which could occasionally cause a 'finally'
statement within the task to not get run, leading to leaked resources.
Published by botberry about 2 years ago
This release fixes a couple of small styling issues with
the GraphiQL explorer
Published by botberry about 2 years ago
This release adds support for passing schema directives to
Schema(..., types=[])
. This can be useful if using a built-inschema directive
that's not supported by a gateway.
For example the following:
import strawberry
from strawberry.scalars import JSON
from strawberry.schema_directive import Location
@strawberry.type
class Query:
example: JSON
@strawberry.schema_directive(locations=[Location.SCALAR], name="specifiedBy")
class SpecifiedBy:
name: str
schema = strawberry.Schema(query=Query, types=[SpecifiedBy])
will print the following SDL:
directive @specifiedBy(name: String!) on SCALAR
"""
The `JSON` scalar type represents JSON values as specified by [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf).
"""
scalar JSON
@specifiedBy(
url: "http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf"
)
type Query {
example: JSON!
}
Published by botberry about 2 years ago
This release fixes an issue with the updated GraphiQL
interface.
Published by botberry about 2 years ago
This release updates the built-in GraphiQL version to version 2.0,
which means you can now enjoy all the new features that come with the latest version!
Published by botberry about 2 years ago
This release restricts the backports.cached_property
dependency to only be
installed when Python < 3.8. Since version 3.8 cached_property
is included
in the builtin functools
. The code is updated to use the builtin version
when Python >= 3.8.