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.147.0

Published by botberry almost 2 years ago

This release introduces a encode_json method on all the HTTP integrations.
This method allows to customize the encoding of the JSON response. By default we
use json.dumps but you can override this method to use a different encoder.

It also deprecates json_encoder and json_dumps_params in the Django and
Sanic views, encode_json should be used instead.

strawberry - 🍓 0.146.0

Published by botberry almost 2 years ago

This release updates the Sanic integration and includes some breaking changes.
You might need to update your code if you are customizing get_context or
process_result

get_context

get_context now receives the request as the first argument and the response as
the second argument.

process_result

process_result is now async and receives the request and the GraphQL execution
result.

This change is needed to align all the HTTP integrations and reduce the amount
of code needed to maintain. It also makes the errors consistent with other
integrations.

It also brings a new feature and it allows to customize the HTTP status code
by using info.context["response"].status_code = YOUR_CODE.

It also removes the upper bound on the Sanic version, so you can use the latest
version of Sanic with Strawberry.

strawberry - 🍓 0.145.0

Published by botberry almost 2 years ago

This release introduced improved errors! Now, when you have a syntax error in
your code, you'll get a nice error message with a line number and a pointer to
the exact location of the error. ✨

This is a huge improvement over the previous behavior, which was providing a
stack trace with no clear indication of where the error was. 🙈

You can enable rich errors by installing Strawberry with the cli extra:

pip install strawberry-graphql[cli]
strawberry - 🍓 0.144.3

Published by botberry almost 2 years ago

This release fixes an issue with type duplication of generics.

You can now use a lazy type with a generic even if
the original type was already used with that generic in the schema.

Example:

@strawberry.type
class Query:
    regular: Edge[User]
    lazy: Edge[Annotated["User", strawberry.lazy(".user")]]
strawberry - 🍓 0.144.2

Published by botberry almost 2 years ago

Generic types are now allowed in the schema's extra types.

T = TypeVar('T')

@strawberry.type
class Node(Generic[T]):
    field: T

@strawberry.type
class Query:
    name: str

schema = strawberry.Schema(Query, types=[Node[int]])
strawberry - 🍓 0.144.1

Published by botberry almost 2 years ago

This release fixes a regression that prevented Generic types
from being used multiple types.

strawberry - 🍓 0.144.0

Published by botberry almost 2 years ago

Added extra validation that types used in a schema are unique.
Strawberry starts to throw an exception DuplicatedTypeName when two types defined in a schema have the same name.

strawberry - 🍓 0.143.0

Published by botberry almost 2 years ago

Added an error to be used when overriding GraphQLError in custom extensions and added a guide on how to use it.
Exposing GraphQLError from the strawberry namespace brings a better experience and will be useful in the future (when we move to something else).

strawberry - 🍓 0.142.3

Published by botberry almost 2 years ago

This release updates GraphiQL to 2.2.0 and fixes an issue with the websocket URL
being incorrectly set when navigating to GraphiQL with an URL with a hash.

strawberry - 🍓 0.142.2

Published by botberry almost 2 years ago

This release changes the dataloader batch resolution to avoid resolving
futures that were canceled, and also from reusing them from the cache.
Trying to resolve a future that was canceled would raise asyncio.InvalidStateError

strawberry - 🍓 0.142.1

Published by botberry almost 2 years ago

This release fixes a bug where using a custom scalar in a union would result
in an unclear exception. Instead, when using a custom scalar in a union,
the InvalidUnionType exception is raised with a clear message that you
cannot use that type in a union.

strawberry - 🍓 0.142.0

Published by botberry almost 2 years ago

This release adds support for typing.Self and typing_extensions.Self for types and interfaces.

from typing_extensions import Self

@strawberry.type
class Node:
    @strawberry.field
    def field(self) -> Self:
        return self
strawberry - 🍓 0.141.0

Published by botberry almost 2 years ago

This release adds support for an implicit resolve_reference method
on Federation type. This method will automatically create a Strawberry
instance for a federation type based on the input data received, for
example, the following:

@strawberry.federation.type(keys=["id"])
class Something:
    id: str

@strawberry.federation.type(keys=["upc"])
class Product:
    upc: str
    something: Something

    @staticmethod
    def resolve_reference(**data):
        return Product(
            upc=data["upc"], something=Something(id=data["something_id"])
        )

doesn't need the resolve_reference method anymore.

strawberry - 🍓 0.140.3

Published by botberry almost 2 years ago

[Internal] Update StrawberryField so that type_annotation is always an instance of StrawberryAnnotation.

strawberry - 🍓 0.140.2

Published by botberry almost 2 years ago

This release fixes an issue that prevented using enums that
were using strawberry.enum_value, like the following example:

from enum import Enum
import strawberry

@strawberry.enum
class TestEnum(Enum):
    A = strawberry.enum_value("A")
    B = "B"

@strawberry.type
class Query:
    @strawberry.field
    def receive_enum(self, test: TestEnum) -> int:
        return 0

schema = strawberry.Schema(query=Query)
strawberry - 🍓 0.140.1

Published by botberry almost 2 years ago

This release adds logging back for parsing and validation errors that was
accidentally removed in v0.135.0.

strawberry - 🍓 0.140.0

Published by botberry almost 2 years ago

This release allows to disable operation logging when running the debug server.

strawberry server demo --log-operations False
strawberry - 🍓 0.139.0

Published by botberry almost 2 years ago

This release changes the type resolution priority to prefer the field annotation over the resolver return type.

def my_resolver() -> str:
    return "1.33"

@strawberry.type
class Query:
    a: float = strawberry.field(resolver=my_resolver)

schema = strawberry.Schema(Query)

# Before:
str(schema) == """
type Query {
  a: String!
}
"""

# After:
str(schema) == """
type Query {
  a: Float!
}
"""
strawberry - 🍓 0.138.2

Published by botberry almost 2 years ago

Fix Pydantic integration for Python 3.10.0 (which was missing the kw_only
parameter for dataclasses.make_dataclass()).

strawberry - 🍓 0.138.1

Published by botberry almost 2 years ago

This release changes an internal implementation for FastAPI's
GraphQL router. This should reduce overhead when using the context,
and it shouldn't affect your code.

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