A GraphQL library for Python that leverages type annotations 🍓
MIT License
Bot releases are hidden (Show)
Published by botberry over 2 years ago
Add is_auto
utility for checking if a type is strawberry.auto
,
considering the possibility of it being a StrawberryAnnotation
or
even being used inside Annotated
.
Published by botberry over 2 years ago
This release moves the console plugin for the codegen command
to be last one, allowing to run code before writing files to
disk.
Published by botberry over 2 years ago
This release adds a python_type
to the codegen GraphQLEnum
class
to allow access to the original python enum when generating code
Published by botberry over 2 years ago
Fix an issue where there was no clean way to mark a Pydantic field as deprecated, add permission classes, or add directives. Now you can use the short field syntax to do all three.
import pydantic
import strawberry
class MyModel(pydantic.BaseModel):
age: int
name: str
@strawberry.experimental.pydantic.type(MyModel)
class MyType:
age: strawberry.auto
name: strawberry.auto = strawberry.field(
deprecation_reason="Because",
permission_classes=[MyPermission],
directives=[MyDirective],
)
Published by botberry over 2 years ago
This release adds a missing __init__.py
inside cli/commands
Published by botberry over 2 years ago
This release fixes an issue that prevented using generic types
with interfaces.
Published by botberry over 2 years ago
This release fixes a couple of more issues with codegen:
Published by botberry over 2 years ago
The return type annotation for DataLoader.load
and load_many
no longer
includes any exceptions directly returned by the load_fn
. The ability to
handle errors by returning them as elements from load_fn
is now documented too.
Published by botberry over 2 years ago
This release add supports for LazyType
s in the codegen command
Published by botberry over 2 years ago
This release adds support for MyPy 0.941 under Python 3.10
Published by botberry over 2 years ago
This release adds an experimental codegen feature for queries.
It allows to combine a graphql query and Strawberry schema to generate
Python types or TypeScript types.
You can use the following command:
strawberry codegen --schema schema --output-dir ./output -p python query.graphql
to generate python types that correspond to your GraphQL query.
Published by botberry over 2 years ago
This release makes StrawberryOptional and StrawberryList hashable,
allowing to use strawberry types with libraries like dacite and
dataclasses_json.
Published by botberry over 2 years ago
Add support for postponed evaluation of annotations
(PEP-563) to strawberry.Private
annotated fields.
This release fixes Issue #1586 using schema-conversion time filtering of
strawberry.Private
fields for PEP-563. This means the following is now
supported:
@strawberry.type
class Query:
foo: "strawberry.Private[int]"
Forward references are supported as well:
from __future__ import annotations
from dataclasses import dataclass
@strawberry.type
class Query:
private_foo: strawberry.Private[SensitiveData]
@strawberry.field
def foo(self) -> int:
return self.private_foo.visible
@dataclass
class SensitiveData:
visible: int
not_visible int
Published by botberry over 2 years ago
This PR improves the support for scalars when using MyPy.
Published by botberry over 2 years ago
Added the response object to get_context
on the flask
view. This means that in fields, something like this can be used;
@strawberry.field
def response_check(self, info: Info) -> bool:
response: Response = info.context["response"]
response.status_code = 401
return True
Published by botberry over 2 years ago
This release adds support for graphql-transport-ws
single result operations.
Single result operations allow clients to execute queries and mutations over an existing WebSocket connection.
Published by botberry over 2 years ago
Change strawberry.auto
to be a type instead of a sentinel.
This not only removes the dependency on sentinel from the project, but also fixes
some related issues, like the fact that only types can be used with Annotated
.
Also, custom scalars will now trick static type checkers into thinking they
returned their wrapped type. This should fix issues with pyright 1.1.224+ where
it doesn't allow non-type objects to be used as annotations for dataclasses and
dataclass-alike classes (which is strawberry's case). The change to strawberry.auto
also fixes this issue for it.
Published by botberry over 2 years ago
This release adds support for flask 2.x and also relaxes the requirements for Django, allowing to install newer version of Django without having to wait for Strawberry to update its supported dependencies list.
Published by botberry over 2 years ago
This fixes the schema printer to add support for schema
directives on input types.
Published by botberry over 2 years ago
This release fixed a false positive deprecation warning related to our AIOHTTP class based view.