I have configured graphql server and graphql playground support using AXUM.
However, I want to support subscription. When I implement that api and call it from graphql playground, it doesn't work properly.
I implemented the functionality for subscriptions by referring to the link below.
Where the code differs slightly from the referenced code is where we added code to support playgrounds.
#[allow(clippy::unused_async)]
async fn graphql_playground() -> impl IntoResponse {
Html(playground_source(GraphQLPlaygroundConfig::new("/graphql")))
}
let app = Router::new()
.route("/graphql", get(graphiql).post(graphql_handler))
.route(
"/graphql/playground",
get(graphql_playground).post(graphql_handler),
)
.route_service("/ws", GraphQLSubscription::new(schema.clone()))
.layer(Extension(schema));
Is there any example or other way to implement a subscription that I can refer to?