A GraphQL library for Python that leverages type annotations 🍓
MIT License
Published by botberry about 3 years ago
This release adds support for Sanic v21
Published by botberry about 3 years ago
Fixes returning "500 Internal Server Error" responses to requests with malformed json when running with ASGI integration.
Published by botberry about 3 years ago
This release adds python_name
to the Info
type.
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.
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:
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]
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"]]
Published by botberry about 3 years ago
This release adds fragment and input variable information to the
selected_fields
attribute on the Info
object.
Published by botberry about 3 years ago
Fixes a bug in the Pydantic conversion code around Union
values.
Published by botberry about 3 years ago
Fixes a bug in the export-schema
command around the handling of local modules.
Published by botberry about 3 years ago
Fixes a bug in the Pydantic conversion code around complex Optional
values.
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:
...
Published by botberry about 3 years ago
Fix type resolution when inheriting from types from another module using deferred annotations.
Published by botberry about 3 years ago
This release adds support for Pyright and Pylance, improving the
integration with Visual Studio Code!
Published by botberry about 3 years ago
Change the version constraint of opentelemetry-sdk and opentelemetry-api to <2
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))]
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
.
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}
Published by botberry about 3 years ago
This release allows to install Strawberry along side click
version 8.
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])
Published by botberry about 3 years ago
Fix issue where strawberry.Private
fields on converted Pydantic types were not added to the resulting dataclass.