A GraphQL library for Python that leverages type annotations 🍓
MIT License
Bot releases are hidden (Show)
Published by botberry 5 months ago
This release fixes a bug in release 0.227.3 where FragmentSpread nodes
were not resolving edges.
Releases contributed by @euriostigue via #3487
Published by botberry 6 months ago
This release adds an optimization to ListConnection
such that only queries with
edges
or pageInfo
in their selected fields triggers resolve_edges
.
This change is particularly useful for the strawberry-django
extension's
ListConnectionWithTotalCount
and the only selected field is totalCount
. An
extraneous SQL query is prevented with this optimization.
Releases contributed by @euriostigue via #3480
Published by botberry 6 months ago
This release fixes a minor issue where the docstring for the relay util to_base64
described the return type incorrectly.
Releases contributed by @gbannerman via #3467
Published by botberry 6 months ago
This release fixes an issue where annotations on @strawberry.type
s were overridden
by our code. With release all annotations should be preserved.
This is useful for libraries that use annotations to introspect Strawberry types.
Releases contributed by @patrick91 via #3003
Published by botberry 6 months ago
This release improves the schema codegen, making it more robust and easier to
use.
It does this by introducing a directed acyclic graph for the schema codegen,
which should reduce the amount of edits needed to make the generated code work,
since it will be able to generate the code in the correct order (based on the
dependencies of each type).
Releases contributed by @patrick91 via #3116
Published by botberry 6 months ago
This release updates our Mypy plugin to add support for Pydantic >= 2.7.0
Releases contributed by @patrick91 via #3462
Published by botberry 6 months ago
This releases fixes a bug in the mypy plugin where the from_pydantic
method
was not correctly typed.
Releases contributed by @Corentin-Br via #3368
Published by botberry 6 months ago
Starting with this release, any error raised from within schema
extensions will abort the operation and is returned to the client.
This corresponds to the way we already handle field extension errors
and resolver errors.
This is particular useful for schema extensions performing checks early
in the request lifecycle, for example:
class MaxQueryLengthExtension(SchemaExtension):
MAX_QUERY_LENGTH = 8192
async def on_operation(self):
if len(self.execution_context.query) > self.MAX_QUERY_LENGTH:
raise StrawberryGraphQLError(message="Query too large")
yield
Published by botberry 6 months ago
This change fixes GET request queries returning a 400 if a content_type header is supplied
Releases contributed by @vethan via #3452
Published by botberry 6 months ago
This release adds support for using FastAPI APIRouter arguments in GraphQLRouter.
Now you have the opportunity to specify parameters such as tags
, route_class
,
deprecated
, include_in_schema
, etc:
import strawberry
from fastapi import FastAPI
from strawberry.fastapi import GraphQLRouter
@strawberry.type
class Query:
@strawberry.field
def hello(self) -> str:
return "Hello World"
schema = strawberry.Schema(Query)
graphql_app = GraphQLRouter(schema, tags=["graphql"])
app = FastAPI()
app.include_router(graphql_app, prefix="/graphql")
Releases contributed by @nparamonov via #3442
Published by botberry 6 months ago
This releases fixes a bug where schema extensions where not running a LIFO order.
Releases contributed by @nrbnlulu via #3416
Published by botberry 7 months ago
This release fixes a deprecation warning when using the Apollo Tracing
Extension.
Releases contributed by @coady via #3410
Published by botberry 7 months ago
This release adds support for using both Pydantic v1 and v2, when importing from
pydantic.v1
.
This is automatically detected and the correct version is used.
Releases contributed by @patrick91 via #3426
Published by botberry 7 months ago
This release adds support for Apollo Federation in the schema codegen. Now you
can convert a schema like this:
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.3",
import: ["@key", "@shareable"])
type Query {
me: User
}
type User @key(fields: "id") {
id: ID!
username: String! @shareable
}
to a Strawberry powered schema like this:
import strawberry
@strawberry.type
class Query:
me: User | None
@strawberry.federation.type(keys=["id"])
class User:
id: strawberry.ID
username: str = strawberry.federation.field(shareable=True)
schema = strawberry.federation.Schema(query=Query, enable_federation_2=True)
By running the following command:
strawberry schema-codegen example.graphql
Releases contributed by @patrick91 via #3417
Published by botberry 7 months ago
This release adds support for Apollo Federation v2.7 which includes the @authenticated
, @requiresScopes
, @policy
directives, as well as the label
argument for @override
.
As usual, we have first class support for them in the strawberry.federation
namespace, here's an example:
from strawberry.federation.schema_directives import Override
@strawberry.federation.type(
authenticated=True,
policy=[["client", "poweruser"], ["admin"]],
requires_scopes=[["client", "poweruser"], ["admin"]],
)
class Product:
upc: str = strawberry.federation.field(
override=Override(override_from="mySubGraph", label="percent(1)")
)
Releases contributed by @TygerTaco via #3420
Published by botberry 7 months ago
This release properly allows passing one argument to the Info
class.
This is now fully supported:
import strawberry
from typing import TypedDict
class Context(TypedDict):
user_id: str
@strawberry.type
class Query:
@strawberry.field
def info(self, info: strawberry.Info[Context]) -> str:
return info.context["user_id"]
Releases contributed by @patrick91 via #3419
Published by botberry 7 months ago
This release improves the Info
type, by adding support for default TypeVars
and by exporting it from the main module. This makes it easier to use Info
in
your own code, without having to import it from strawberry.types.info
.
By exporting Info
from the main module, now you can do the follwing:
import strawberry
@strawberry.type
class Query:
@strawberry.field
def info(self, info: strawberry.Info) -> str:
# do something with info
return "hello"
The Info
type now has default TypeVars, so you can use it without having to
specify the type arguments, like we did in the example above. Make sure to use
the latest version of Mypy or Pyright for this. It also means that you can only
pass one value to it if you only care about the context type:
import strawberry
from .context import Context
@strawberry.type
class Query:
@strawberry.field
def info(self, info: strawberry.Info[Context]) -> str:
return info.context.user_id
Releases contributed by @patrick91 via #3418
Published by botberry 8 months ago
This release adds support to allow passing connection_params
as dictionary to GraphQLWebsocketCommunicator
class when testing channels integration
GraphQLWebsocketCommunicator(
application=application,
path="/graphql",
connection_params={"username": "strawberry"},
)
Releases contributed by @selvarajrajkanna via #3403
Published by botberry 9 months ago
This releases updates the dependency of python-multipart
to be at least 0.0.7
(which includes a security fix).
It also removes the upper bound for python-multipart
so you can always install the latest version (if compatible) 😊
Releases contributed by @XChikuX via #3375
Published by botberry 9 months ago
Releases contributed by @sdobbelaere via #3361