A GraphQL library for Python that leverages type annotations 🍓
MIT License
Bot releases are hidden (Show)
Published by botberry almost 2 years ago
This release adds support for generic in arguments, see the following example:
T = TypeVar('T')
@strawberry.type
class Node(Generic[T]):
@strawberry.field
def data(self, arg: T) -> T: # `arg` is also generic
return arg
Published by botberry almost 2 years ago
Allowed CustomScalar | None
syntax for python >= 3.10.
Published by botberry almost 2 years ago
This release fixes errors when using Union-of-lazy-types
Published by botberry almost 2 years ago
This release refactors the chalice integration in order to keep it consistent with
the other integrations.
Passing render_graphiql
is now deprecated, please use graphiql
instead.
info.context["response"].status_code = 418
allow_queries_via_get
(defaults to True
)Trying to access /graphql via a browser and with graphiql
set to False
will return a 404.
Published by botberry almost 2 years ago
This release adds a new MaskErrors
extension that can be used to hide error
messages from the client to prevent exposing sensitive details. By default it
masks all errors raised in any field resolver.
import strawberry
from strawberry.extensions import MaskErrors
schema = strawberry.Schema(
Query,
extensions=[
MaskErrors(),
]
)
Published by botberry about 2 years ago
This release improves the error message that you get when trying
to use an enum that hasn't been decorated with @strawberry.enum
inside a type's field.
Published by botberry about 2 years ago
This release adds support for printing schema directives on an input type object, for example the following schema:
@strawberry.schema_directive(locations=[Location.INPUT_FIELD_DEFINITION])
class RangeInput:
min: int
max: int
@strawberry.input
class CreateUserInput:
name: str
age: int = strawberry.field(directives=[RangeInput(min=1, max=100)])
prints the following:
directive @rangeInput(min: Int!, max: Int!) on INPUT_FIELD_DEFINITION
input Input @sensitiveInput(reason: "GDPR") {
firstName: String!
age: Int! @rangeInput(min: 1, max: 100)
}
Published by botberry about 2 years ago
This release fixes an issue that prevented using strawberry.lazy with relative paths.
The following should work now:
@strawberry.type
class TypeA:
b: Annotated["TypeB", strawberry.lazy(".type_b")]
Published by botberry about 2 years ago
This release adds pyupgrade to our CI and includes some minor changes to keep our codebase modern.
Published by botberry about 2 years ago
This release fixes an issue that prevented using lazy types inside
generic types.
The following is now allowed:
T = TypeVar("T")
TypeAType = Annotated["TypeA", strawberry.lazy("tests.schema.test_lazy.type_a")]
@strawberry.type
class Edge(Generic[T]):
node: T
@strawberry.type
class Query:
users: Edge[TypeAType]
Published by botberry about 2 years ago
These release allow you to define a different url
in the GraphQLTestClient
, the default is "/graphql/".
Here's an example with Starlette client:
import pytest
from starlette.testclient import TestClient
from strawberry.asgi.test import GraphQLTestClient
@pytest.fixture
def graphql_client() -> GraphQLTestClient:
return GraphQLTestClient(TestClient(app, base_url="http://localhost:8000"), url="/api/")
Published by botberry about 2 years ago
This release fixes a type issue when passing scalar_overrides
to strawberry.Schema
Published by botberry about 2 years ago
Fix support for arguments where arg.type=LazyType["EnumType"]
Published by botberry about 2 years ago
Updated unset
import, from strawberry.arguments
to strawberry.unset
in codebase.
This will prevent strawberry from triggering its own warning on deprecated imports.
Published by botberry about 2 years ago
This release fixes the type of strawberry.federation.field,
this will prevent errors from mypy and pyright when doing the following:
@strawberry.federation.type(keys=["id"])
class Location:
id: strawberry.ID
# the following field was reporting an error in mypy and pylance
celestial_body: CelestialBody = strawberry.federation.field(
resolver=resolve_celestial_body
)
Published by botberry about 2 years ago
This release allows to create a federation schema without having to pass a
Query
type. This is useful when your schema only extends some types without
adding any additional root field.
@strawberry.federation.type(keys=["id"])
class Location:
id: strawberry.ID
name: str = strawberry.federation.field(override="start")
schema = strawberry.federation.Schema(types=[Location])
Published by botberry about 2 years ago
This release fixes an issue with strawberry.federation.field
that
prevented instantiating field when passing a resolver function.
Published by botberry about 2 years ago
This release fixes an issue that prevented using strawberry.field
with
UNSET
as the default value.
Published by botberry about 2 years ago
Reduce the number of required dependencies, by marking Pygments and python-multipart as optional. These dependencies are still necessary for some functionality, and so users of that functionality need to ensure they're installed, either explicitly or via an extra:
strawberry[debug-server]
extra.strawberry.file_uploads.Upload
with FastAPI or Starlette, and is included in the strawberry[fastapi]
and strawberry[asgi]
extras, respectively.There is now also the strawberry[cli]
extra to support commands like strawberry codegen
and strawberry export-schema
.
Published by botberry about 2 years ago
Improve resolving performance by avoiding extra calls for basic fields.
This change improves performance of resolving a query by skipping Info
creation and permission checking for fields that don't have a resolver
or permission classes. In local benchmarks it improves performance of large
results by ~14%.