Skip to content

Commit c7a261a

Browse files
authored
Update routes.rs
1 parent f6673e9 commit c7a261a

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/graphql/routes.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@ use async_graphql_actix_web::{GraphQLRequest, GraphQLResponse};
33
use async_graphql::http::{playground_source, GraphQLPlaygroundConfig};
44
use super::AppState;
55

6+
// Handles POST /graphql requests for executing GraphQL queries and mutations
67
#[post("/graphql")]
78
pub async fn graphql(state: web::Data<AppState>, request: GraphQLRequest) -> GraphQLResponse {
9+
// Execute the GraphQL request using the schema stored in the application state
810
state.schema.execute(request.into_inner()).await.into()
911
}
1012

13+
// Handles GET /graphql requests to serve the GraphiQL UI
1114
#[get("/graphql")]
1215
pub async fn graphiql() -> HttpResponse {
16+
// Return an HTML response with the GraphiQL interface, configured to query the /graphql endpoint
1317
HttpResponse::Ok()
1418
.content_type("text/html; charset=utf-8")
1519
.body(playground_source(GraphQLPlaygroundConfig::new("/graphql")))

0 commit comments

Comments
 (0)