File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,13 +3,17 @@ use async_graphql_actix_web::{GraphQLRequest, GraphQLResponse};
33use async_graphql:: http:: { playground_source, GraphQLPlaygroundConfig } ;
44use super :: AppState ;
55
6+ // Handles POST /graphql requests for executing GraphQL queries and mutations
67#[ post( "/graphql" ) ]
78pub 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" ) ]
1215pub 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" ) ) )
You can’t perform that action at this time.
0 commit comments