strawberry

A GraphQL library for Python that leverages type annotations 🍓

MIT License

Downloads
1.1M
Stars
3.8K
Committers
260

Bot releases are hidden (Show)

strawberry - 🍓 0.132.0

Published by botberry about 2 years ago

Support storing metadata in strawberry fields.

strawberry - 🍓 0.131.5

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
strawberry - 🍓 0.131.4

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.

strawberry - 🍓 0.131.3

Published by botberry about 2 years ago

Bug fix: Do not force kw-only=False in fields specified with strawberry.field()

strawberry - 🍓 0.131.2

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.

strawberry - 🍓 0.131.1

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.
strawberry - 🍓 0.131.0

Published by botberry about 2 years ago

This release improves the dataloader class with new features:

  • Explicitly cache invalidation, prevents old data from being fetched after a mutation
  • Importing data into the cache, prevents unnecessary load calls if the data has already been fetched by other means.
strawberry - 🍓 0.130.4

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.

strawberry - 🍓 0.130.3

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."""
strawberry - 🍓 0.130.2

Published by botberry about 2 years ago

This release fixes the conversion of generic aliases when
using pydantic.

strawberry - 🍓 0.130.1

Published by botberry about 2 years ago

Fix version parsing issue related to dev builds of Mypy in strawberry.ext.mypy_plugin

strawberry - 🍓 0.130.0

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]
strawberry - 🍓 0.129.0

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")]]
strawberry - 🍓 0.128.0

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)
strawberry - 🍓 0.127.4

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.

strawberry - 🍓 0.127.3

Published by botberry about 2 years ago

This release fixes a couple of small styling issues with
the GraphiQL explorer

strawberry - 🍓 0.127.2

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!
}
strawberry - 🍓 0.127.1

Published by botberry about 2 years ago

This release fixes an issue with the updated GraphiQL
interface.

strawberry - 🍓 0.127.0

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!

strawberry - 🍓 0.126.2

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.

Package Rankings
Top 1.15% on Pypi.org
Top 16.1% on Conda-forge.org
Badges
Extracted from project README
CircleCI Discord PyPI
Related Projects