0

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.

https://github.com/async-graphql/examples/blob/7eee23ad4e005ac180df8111e6940cebb7c1f52f/axum/subscription/src/main.rs

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?

hbkim
  • 11
  • 1

0 Answers0