strawberry

A GraphQL library for Python that leverages type annotations 🍓

MIT License

Downloads
1.1M
Stars
3.8K
Committers
260
strawberry - 🍓 0.77.12

Published by botberry about 3 years ago

This release adds support for Sanic v21

strawberry - 🍓 0.77.11

Published by botberry about 3 years ago

Fixes returning "500 Internal Server Error" responses to requests with malformed json when running with ASGI integration.

strawberry - 🍓 0.77.10

Published by botberry about 3 years ago

This release adds python_name to the Info type.

strawberry - 🍓 0.77.9

Published by botberry about 3 years ago

Fix the Pydantic conversion method for Enum values, and add a mechanism to specify an interface type when converting from Pydantic. The Pydantic interface is really a base dataclass for the subclasses to extend. When you do the conversion, you have to use strawberry.experimental.pydantic.interface to let us know that this type is an interface. You also have to use your converted interface type as the base class for the sub types as normal.

strawberry - 🍓 0.77.8

Published by botberry about 3 years ago

Fixes a bug with the selected_fields property on info when an operation
variable is not defined.

Issue #1248.

strawberry - 🍓 0.77.7

Published by botberry about 3 years ago

Fix issues (#1158 and #1104) where Generics using LazyTypes
and Enums would not be properly resolved

These now function as expected:

Enum

T = TypeVar("T")

@strawberry.enum
class VehicleMake(Enum):
    FORD = 'ford'
    TOYOTA = 'toyota'
    HONDA = 'honda'

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

@strawberry.type
class SomeType:
    field: GenericForEnum[VehicleMake]

LazyType

another_file.py

@strawberry.type
class TypeFromAnotherFile:
    something: bool

this_file.py

T = TypeVar("T")

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

@strawberry.type
class RealType:
    lazy: GenericType[LazyType["TypeFromAnotherFile", "another_file.py"]]
strawberry - 🍓 0.77.6

Published by botberry about 3 years ago

This release adds fragment and input variable information to the
selected_fields attribute on the Info object.

strawberry - 🍓 0.77.5

Published by botberry about 3 years ago

Fixes a bug in the Pydantic conversion code around Union values.

strawberry - 🍓 0.77.4

Published by botberry about 3 years ago

Fixes a bug in the export-schema command around the handling of local modules.

strawberry - 🍓 0.77.3

Published by botberry about 3 years ago

Fixes a bug in the Pydantic conversion code around complex Optional values.

strawberry - 🍓 0.77.2

Published by botberry about 3 years ago

This release adds a new exception called InvalidFieldArgument which is raised when a Union or Interface is used as an argument type.
For example this will raise an exception:

import strawberry

@strawberry.type
class Noun:
    text: str

@strawberry.type
class Verb:
    text: str

Word = strawberry.union("Word", types=(Noun, Verb))

@strawberry.field
def add_word(word: Word) -> bool:
	...
strawberry - 🍓 0.77.1

Published by botberry about 3 years ago

Fix type resolution when inheriting from types from another module using deferred annotations.

strawberry - 🍓 0.77.0

Published by botberry about 3 years ago

This release adds support for Pyright and Pylance, improving the
integration with Visual Studio Code!

strawberry - 🍓 0.76.1

Published by botberry about 3 years ago

Change the version constraint of opentelemetry-sdk and opentelemetry-api to <2

strawberry - 🍓 0.76.0

Published by botberry about 3 years ago

This release adds support for enabling subscriptions in GraphiQL
on Django by setting a flag subscriptions_enabled on the BaseView class.

from strawberry.django.views import AsyncGraphQLView

from .schema import schema

urlpatterns = [path("graphql", AsyncGraphQLView.as_view(schema=schema, graphiql=True, subscriptions_enabled=True))]
strawberry - 🍓 0.75.1

Published by botberry about 3 years ago

This release fixes an issue with the MyPy plugin that prevented using
TextChoices from django in strawberry.enum.

strawberry - 🍓 0.75.0

Published by botberry about 3 years ago

This release improves how we deal with custom scalars. Instead of being global
they are now scoped to the schema. This allows you to have multiple schemas in
the same project with different scalars.

Also you can now override the built in scalars with your own custom
implementation. Out of the box Strawberry provides you with custom scalars for
common Python types like datetime and Decimal. If you require a custom
implementation of one of these built in scalars you can now pass a map of
overrides to your schema:

from datetime import datetime, timezone
import strawberry

EpochDateTime = strawberry.scalar(
    datetime,
    serialize=lambda value: int(value.timestamp()),
    parse_value=lambda value: datetime.fromtimestamp(int(value), timezone.utc),
)

@strawberry.type
class Query:
    @strawberry.field
    def current_time(self) -> datetime:
        return datetime.now()

schema = strawberry.Schema(
  Query,
  scalar_overrides={
    datetime: EpochDateTime,
  }
)
result = schema.execute_sync("{ currentTime }")
assert result.data == {"currentTime": 1628683200}
strawberry - 🍓 0.74.1

Published by botberry about 3 years ago

This release allows to install Strawberry along side click version 8.

strawberry - 🍓 0.74.0

Published by botberry about 3 years ago

This release add full support for async directives and fixes and issue when
using directives and async extensions.

@strawberry.type
class Query:
    name: str = "Banana"

@strawberry.directive(
    locations=[DirectiveLocation.FIELD], description="Make string uppercase"
)
async def uppercase(value: str):
    return value.upper()

schema = strawberry.Schema(query=Query, directives=[uppercase])
strawberry - 🍓 0.73.9

Published by botberry about 3 years ago

Fix issue where strawberry.Private fields on converted Pydantic types were not added to the resulting dataclass.

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