|
1 | 1 | CHANGELOG
|
2 | 2 | =========
|
3 | 3 |
|
| 4 | +0.278.0 - 2025-07-19 |
| 5 | +-------------------- |
| 6 | + |
| 7 | +## Add GraphQL Query batching support |
| 8 | + |
| 9 | +GraphQL query batching is now supported across all frameworks (sync and async) |
| 10 | +To enable query batching, add a valid `batching_config` to the schema configuration. |
| 11 | + |
| 12 | +This makes your GraphQL API compatible with batching features supported by various |
| 13 | +client side libraries, such as [Apollo GraphQL](https://www.apollographql.com/docs/react/api/link/apollo-link-batch-http) and [Relay](https://github.com/relay-tools/react-relay-network-modern?tab=readme-ov-file#batching-several-requests-into-one). |
| 14 | + |
| 15 | +Example (FastAPI): |
| 16 | + |
| 17 | +```py |
| 18 | +import strawberry |
| 19 | + |
| 20 | +from fastapi import FastAPI |
| 21 | +from strawberry.fastapi import GraphQLRouter |
| 22 | +from strawberry.schema.config import StrawberryConfig |
| 23 | + |
| 24 | + |
| 25 | +@strawberry.type |
| 26 | +class Query: |
| 27 | + @strawberry.field |
| 28 | + def hello(self) -> str: |
| 29 | + return "Hello World" |
| 30 | + |
| 31 | + |
| 32 | +schema = strawberry.Schema( |
| 33 | + Query, config=StrawberryConfig(batching_config={"max_operations": 10}) |
| 34 | +) |
| 35 | + |
| 36 | +graphql_app = GraphQLRouter(schema) |
| 37 | + |
| 38 | +app = FastAPI() |
| 39 | +app.include_router(graphql_app, prefix="/graphql") |
| 40 | +``` |
| 41 | + |
| 42 | +Example (Flask): |
| 43 | +```py |
| 44 | +import strawberry |
| 45 | + |
| 46 | +from flask import Flask |
| 47 | +from strawberry.flask.views import GraphQLView |
| 48 | + |
| 49 | +app = Flask(__name__) |
| 50 | + |
| 51 | + |
| 52 | +@strawberry.type |
| 53 | +class Query: |
| 54 | + @strawberry.field |
| 55 | + def hello(self) -> str: |
| 56 | + return "Hello World" |
| 57 | + |
| 58 | + |
| 59 | +schema = strawberry.Schema( |
| 60 | + Query, config=StrawberryConfig(batching_config={"max_operations": 10}) |
| 61 | +) |
| 62 | + |
| 63 | +app.add_url_rule( |
| 64 | + "/graphql/batch", |
| 65 | + view_func=GraphQLView.as_view("graphql_view", schema=schema), |
| 66 | +) |
| 67 | + |
| 68 | +if __name__ == "__main__": |
| 69 | + app.run() |
| 70 | +``` |
| 71 | + |
| 72 | +Note: Query Batching is not supported for multipart subscriptions |
| 73 | + |
| 74 | +Contributed by [Aryan Iyappan](https://github.com/aryaniyaps) via [PR #3755](https://github.com/strawberry-graphql/strawberry/pull/3755/) |
| 75 | + |
| 76 | + |
4 | 77 | 0.277.1 - 2025-07-19
|
5 | 78 | --------------------
|
6 | 79 |
|
|
0 commit comments