pypi strawberry-graphql 0.278.0
🍓 0.278.0

latest releases: 0.281.0, 0.280.0, 0.279.0...
one month ago

Add GraphQL Query batching support

GraphQL query batching is now supported across all frameworks (sync and async)
To enable query batching, add a valid batching_config to the schema configuration.

This makes your GraphQL API compatible with batching features supported by various
client side libraries, such as Apollo GraphQL and Relay.

Example (FastAPI):

import strawberry

from fastapi import FastAPI
from strawberry.fastapi import GraphQLRouter
from strawberry.schema.config import StrawberryConfig


@strawberry.type
class Query:
    @strawberry.field
    def hello(self) -> str:
        return "Hello World"


schema = strawberry.Schema(
    Query, config=StrawberryConfig(batching_config={"max_operations": 10})
)

graphql_app = GraphQLRouter(schema)

app = FastAPI()
app.include_router(graphql_app, prefix="/graphql")

Example (Flask):

import strawberry

from flask import Flask
from strawberry.flask.views import GraphQLView

app = Flask(__name__)


@strawberry.type
class Query:
    @strawberry.field
    def hello(self) -> str:
        return "Hello World"


schema = strawberry.Schema(
    Query, config=StrawberryConfig(batching_config={"max_operations": 10})
)

app.add_url_rule(
    "/graphql/batch",
    view_func=GraphQLView.as_view("graphql_view", schema=schema),
)

if __name__ == "__main__":
    app.run()

Note: Query Batching is not supported for multipart subscriptions

Releases contributed by @aryaniyaps via #3755

Don't miss a new strawberry-graphql release

NewReleases is sending notifications on new releases.