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.234.2 Latest Release

Published by botberry 4 months ago

This release fixes an issue when trying to retrieve specialized type vars from a
generic type that has been aliased to a name, in cases like:

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


SpecializedFruit = Fruit[str]

Releases contributed by @bellini666 via #3535

strawberry - 🍓 0.234.1

Published by botberry 5 months ago

Improved error message when supplying GlobalID with invalid or unknown type name component

Releases contributed by @diesieben07 via #3533

strawberry - 🍓 0.234.0

Published by botberry 5 months ago

This release separates the relay.ListConnection logic that calculates the
slice of the nodes into a separate function.

This allows for easier reuse of that logic for other places/libraries.

The new function lives in the strawberry.relay.utils and can be used by
calling SliceMetadata.from_arguments.

This has no implications to end users.

Releases contributed by @bellini666 via #3530

strawberry - 🍓 0.233.3

Published by botberry 5 months ago

This release fixes a typing issue where trying to type a root argument with
strawberry.Parent would fail, like in the following example:

import strawberry


@strawberry.type
class SomeType:
    @strawberry.field
    def hello(self, root: strawberry.Parent[str]) -> str:
        return "world"

This should now work as intended.

Releases contributed by @bellini666 via #3529

strawberry - 🍓 0.233.2

Published by botberry 5 months ago

This release fixes an introspection issue when requesting isOneOf on built-in
scalars, like String.

Releases contributed by @patrick91 via #3528

strawberry - 🍓 0.233.1

Published by botberry 5 months ago

This release exposes get_arguments in the schema_converter module to allow
integrations, such as strawberry-django, to reuse that functionality if needed.

This is an internal change with no impact for end users.

Releases contributed by @bellini666 via #3527

strawberry - 🍓 0.233.0

Published by botberry 5 months ago

This release refactors our Federation integration to create types using
Strawberry directly, instead of using low level types from GraphQL-core.

The only user facing change is that now the info object passed to the
resolve_reference function is the strawberry.Info object instead of the one
coming coming from GraphQL-core. This is a breaking change for users that
were using the info object directly.

If you need to access the original info object you can do so by accessing the
_raw_info attribute.

import strawberry


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

    @classmethod
    def resolve_reference(cls, info: strawberry.Info, upc: str) -> "Product":
        # Access the original info object
        original_info = info._raw_info

        return Product(upc=upc)

Releases contributed by @patrick91 via #3525

strawberry - 🍓 0.232.2

Published by botberry 5 months ago

This release fixes an issue that would prevent using lazy aliased connections to
annotate a connection field.

For example, this should now work correctly:

# types.py


@strawberry.type
class Fruit: ...


FruitConnection: TypeAlias = ListConnection[Fruit]
# schema.py


@strawberry.type
class Query:
    fruits: Annotated["FruitConnection", strawberry.lazy("types")] = (
        strawberry.connection()
    )

Releases contributed by @bellini666 via #3524

strawberry - 🍓 0.232.1

Published by botberry 5 months ago

This release fixes an issue where mypy would complain when using a typed async
resolver with strawberry.field(resolver=...).

Now the code will type check correctly. We also updated our test suite to make
we catch similar issues in the future.

Releases contributed by @patrick91 via #3516

strawberry - 🍓 0.232.0

Published by botberry 5 months ago

This release improves type checking for async resolver functions when used as
strawberry.field(resolver=resolver_func).

Now doing this will raise a type error:

import strawberry


def some_resolver() -> int:
    return 0


@strawberry.type
class User:
    # Note the field being typed as str instead of int
    name: str = strawberry.field(resolver=some_resolver)

Releases contributed by @bricker via #3241

strawberry - 🍓 0.231.1

Published by botberry 5 months ago

Fixes an issue where lazy annotations raised an error when used together with a List

Releases contributed by @jeich via #3388

strawberry - 🍓 0.231.0

Published by botberry 5 months ago

When calling the CLI without all the necessary dependencies installed,
a MissingOptionalDependenciesError will be raised instead of a
ModuleNotFoundError. This new exception will provide a more helpful
hint regarding how to fix the problem.

Releases contributed by @parafoxia via #3511

strawberry - 🍓 0.230.0

Published by botberry 5 months ago

This release adds support for @oneOf on input types! 🎉 You can use
one_of=True on input types to create an input type that should only have one
of the fields set.

import strawberry


@strawberry.input(one_of=True)
class ExampleInputTagged:
    a: str | None = strawberry.UNSET
    b: int | None = strawberry.UNSET

Releases contributed by @patrick91 via #3429

strawberry - 🍓 0.229.2

Published by botberry 5 months ago

This release fixes an issue when using Annotated + strawberry.lazy +
deferred annotations such as:

from __future__ import annotations
import strawberry
from typing import Annotated


@strawberry.type
class Query:
    a: Annotated["datetime", strawberry.lazy("datetime")]


schema = strawberry.Schema(Query)

Before this would only work if datetime was not inside quotes. Now it should
work as expected!

Releases contributed by @bellini666 via #3507

strawberry - 🍓 0.229.1

Published by botberry 5 months ago

This release fixes a regression from 0.229.0 where using a generic interface
inside a union would return an error.

Releases contributed by @patrick91 via #3502

strawberry - 🍓 0.229.0

Published by botberry 5 months ago

This release improves our support for generic types, now using the same the same
generic multiple times with a list inside an interface or union is supported,
for example the following will work:

import strawberry


@strawberry.type
class BlockRow[T]:
    items: list[T]


@strawberry.type
class Query:
    @strawberry.field
    def blocks(self) -> list[BlockRow[str] | BlockRow[int]]:
        return [
            BlockRow(items=["a", "b", "c"]),
            BlockRow(items=[1, 2, 3, 4]),
        ]


schema = strawberry.Schema(query=Query)

Releases contributed by @patrick91 via #3463

strawberry - 🍓 0.228.0

Published by botberry 5 months ago

This releases updates the JSON scalar definition to have the updated specifiedBy URL.

The release is marked as minor because it will change the generated schema if you're using the JSON scalar.

Releases contributed by @Birdi7 via #3478

strawberry - 🍓 0.227.7

Published by botberry 5 months ago

This releases updates the field-extensions documentation's StrawberryField stability warning to include stable features.

The release is marked as patch because it only changes documentation.

Releases contributed by @fireteam99 via #3496

strawberry - 🍓 0.227.6

Published by botberry 5 months ago

Fix AssertionError caused by the DatadogTracingExtension whenever the query is unavailable.

The bug in question was reported by issue #3150.
The datadog extension would throw an AssertionError whenever there was no query available. This could happen if,
for example, a user POSTed something to /graphql with a JSON that doesn't contain a query field as per the
GraphQL spec.

The fix consists of adding query_missing to the operation_type tag, and also adding query_missing to the resource name.
It also makes it easier to look for logs of users making invalid queries by searching for query_missing in Datadog.

Releases contributed by @serramatutu via #3483

strawberry - 🍓 0.227.5

Published by botberry 5 months ago

Deprecations: This release deprecates the Starlite integration in favour of the LiteStar integration.
Refer to the LiteStar integration for more information.
LiteStar is a renamed and upgraded version of Starlite.

Before:

from strawberry.starlite import make_graphql_controller

After:

from strawberry.litestar import make_graphql_controller

Releases contributed by @Birdi7 via #3492

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