This directory provides various integrations for async-graphql
to various crates in the ecosystem.
This is a list of criteria for HTTP integrations with async-graphql
in order to make sure all
integrations are implemented consistently.
Integrations may provide additional functionality to better integrate with the specific library, but they must all internally use the below functions.
- Conversion from HTTP library's request to
async_graphql::BatchRequest
:- If the request is a
GET
request:- Return the request's query parameters deserialized as an
async_graphql::Request
.
- Return the request's query parameters deserialized as an
- If the request is a
POST
request:- Get the request's
Content-Type
header. - Call
async_graphql::http::receive_batch_body
on the request's body. - Convert
ParseRequestError::PayloadTooLarge
to a 413 Payload Too Large response. - Convert all other errors to a 400 Bad Request response.
- Get the request's
- Otherwise return a 405 Method Not Allowed.
- If the request is a
- Conversion from HTTP library's request to
async_graphql::Request
:- Call the above function to convert the request to an
async_graphql::BatchRequest
. - Call
BatchRequest::into_single
on the result. - Convert all errors to a 400 Bad Request response.
- Call the above function to convert the request to an
- Conversion from
async_graphql::BatchResponse
to HTTP library's response:- Create a 200 OK response.
- If the GraphQL response is ok, set the response's
Cache-Control
header to the response's cache control value. - Set the response's body to the GraphQL response serialized as JSON, also setting the
Content-Type
header toapplication/json
.
- GraphQL over websocket support:
- Create an
async_graphql::http:WebSocket
usingasync_graphql::http::WebSocket::with_data
. - Support the basics of the websocket protocol:
- Respond to ping messages with pong messages.
- Treat continuation messages identically to data messages.
- Stream all websocket messages that send data (bytes/text/continuations) to the
async_graphql::http::WebSocket
. - Convert all responses to websocket text responses.
- Create an
- Poem: Complete integration.
- Actix-web: Complete integration.
- Rocket: Missing websocket support (blocked on support in Rocket itself).
- Warp: Complete integration.
- Axum: Complete integration.