A GraphQL library for Python that leverages type annotations 🍓
MIT License
Published by botberry over 3 years ago
This release fixes an issue when using nested lists, this now works properly:
def get_polygons() -> List[List[float]]:
return [[2.0, 6.0]]
@strawberry.type
class Query:
polygons: List[List[float]] = strawberry.field(resolver=get_polygons)
schema = strawberry.Schema(query=Query)
query = "{ polygons }"
result = schema.execute_sync(query, root_value=Query())
Published by botberry over 3 years ago
This release fixes support for generic types so that now we can also use generics for input types:
T = typing.TypeVar("T")
@strawberry.input
class Input(typing.Generic[T]):
field: T
@strawberry.type
class Query:
@strawberry.field
def field(self, input: Input[str]) -> str:
return input.field
Published by botberry over 3 years ago
This release fixes a bug that prevented from extending a generic type when
passing a type, like here:
T = typing.TypeVar("T")
@strawberry.interface
class Node(typing.Generic[T]):
id: strawberry.ID
def _resolve(self) -> typing.Optional[T]:
return None
@strawberry.type
class Book(Node[str]):
name: str
@strawberry.type
class Query:
@strawberry.field
def books(self) -> typing.List[Book]:
return list()
Published by botberry over 3 years ago
Fix converting pydantic objects to strawberry types using from_pydantic
when having a falsy value like 0 or ''.
Published by botberry over 3 years ago
Add a process_errors
method to strawberry.Schema
which logs all exceptions during execution to a strawberry.execution
logger.
Published by botberry over 3 years ago
This release fixes the return type value from info argument of resolver.
Published by botberry over 3 years ago
This release improves Pydantic support to support default values and factories.
Published by botberry over 3 years ago
This release fixes the pydantic integration where you couldn't
convert objects to pydantic instance when they didn't have a
default value.
Published by botberry over 3 years ago
Add --app-dir CLI option to specify where to find the schema module to load when using
the debug server.
For example if you have a schema module in a my_app package under ./src, then you
can run the debug server with it using:
strawberry server --app-dir src my_app.schema
Published by botberry over 3 years ago
Add support for default
and default_factory
arguments in strawberry.field
@strawberry.type
class Droid:
name: str = strawberry.field(default="R2D2")
aka: List[str] = strawberry.field(default_factory=lambda: ["Artoo"])
Published by botberry over 3 years ago
Internal refactoring.
StrawberryArgument
to StrawberryArgumentAnnotation
ArgumentDefinition
to StrawberryArgument
ArgumentDefinition(type: ...)
argument toStrawberryArgument(type_: ...)
Published by botberry over 3 years ago
Fixed issue with django multipart/form-data uploads
Published by botberry over 3 years ago
Fix issue where StrawberryField.graphql_name would always be camelCased
Published by botberry over 3 years ago
This relases fixes an issue with the generated __eq__
and __repr__
methods when defining
fields with resolvers.
This now works properly:
@strawberry.type
class Query:
a: int
@strawberry.field
def name(self) -> str:
return "A"
assert Query(1) == Query(1)
assert Query(1) != Query(2)
Published by botberry over 3 years ago
Gracefully handle user-induced subscription errors.
Published by botberry over 3 years ago
FieldDefinition
has been absorbed into StrawberryField
and now no longer exists.
FieldDefinition.origin_name
and FieldDefinition.name
have been replaced with
StrawberryField.python_name
and StrawberryField.graphql_name
. This should help
alleviate some backend confusion about which should be used for certain situations.
strawberry.types.type_resolver.resolve_type
has been split into
resolve_type_argument
and _resolve_type
(for arguments) until StrawberryType
is
implemented to combine them back together. This was done to reduce the scope of this
PR and defer changing ArgumentDefinition
(future StrawberryArgument
) until a
different PR.
Note: The constructor signature for
StrawberryField
hastype_
as an argument
instead oftype
as was the case forFieldDefinition
. This is done to prevent
shadowing of builtins.
Note:
StrawberryField.name
still exists because of the way dataclassField
s
work, but is an alias forStrawberryField.python_name
.
Published by botberry over 3 years ago
Include field_nodes
in Strawberry info object.
Published by botberry over 3 years ago
Change get_context
to be async for sanic integration
Published by botberry over 3 years ago
Configures GraphiQL to attach CSRF cookies as request headers sent to the GQL server.
Published by botberry over 3 years ago
Expose Strawberry Info object instead of GraphQLResolveInfo in resolvers