How could it be possible for a route that establishes a connection to a GrapgQL subscription to be able to inspect the header and update the req.data(...)
(like in graphql_handler
)before establishing a connection to the subscription?
Here is my router:
use async_graphql_axum::{GraphQLRequest, GraphQLResponse, GraphQLSubscription};
// Other imports ...
async fn graphql_handler(
schema: Extension<SchemaRoot>,
headers: HeaderMap,
req: GraphQLRequest,
) -> GraphQLResponse {
let mut req = req.into_inner();
if let Some(value) = headers.get("some-header") {
// ...
}
return schema.execute(req.data(headers)).await.into();
}
pub fn router<S>(schema: SchemaRoot) -> Router<S>
where
S: Clone + Send + Sync + 'static,
{
Router::new()
.route(
"/graphql",
post(graphql_handler).get_service(GraphQLSubscription::new(schema)),
)
}
Right now this works as a get_service
, but I need to be able to check some headers and update the req.data(...)
before setting up the subscription.
y3h0r is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.