File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change 1+ use async_graphql:: http:: GraphiQLSource ;
12use async_graphql:: * ;
23use async_graphql_axum:: { GraphQLRequest , GraphQLResponse } ;
34use axum:: Extension ;
5+ use axum:: response:: { Html , IntoResponse } ;
46
57use crate :: clients:: Client ;
68use crate :: schemas:: TiledQuery ;
@@ -14,6 +16,10 @@ pub async fn graphql_handler<T: Client + Send + Sync + 'static>(
1416 schema. execute ( query) . await . into ( )
1517}
1618
19+ pub async fn graphiql_handler ( ) -> impl IntoResponse {
20+ Html ( GraphiQLSource :: build ( ) . endpoint ( "/graphql" ) . finish ( ) )
21+ }
22+
1723#[ cfg( test) ]
1824mod tests {
1925 use async_graphql:: { EmptyMutation , EmptySubscription , Schema } ;
Original file line number Diff line number Diff line change 11use std:: error;
22
33use async_graphql:: { EmptyMutation , EmptySubscription , Schema } ;
4- use axum:: routing:: post;
4+ use axum:: routing:: { get , post} ;
55use axum:: { Extension , Router } ;
66
77mod cli;
@@ -14,7 +14,7 @@ use cli::{Cli, Commands};
1414
1515use crate :: clients:: tiled_client:: TiledClient ;
1616use crate :: config:: GlazedConfig ;
17- use crate :: handlers:: graphql:: graphql_handler;
17+ use crate :: handlers:: graphql:: { graphiql_handler , graphql_handler} ;
1818use crate :: schemas:: TiledQuery ;
1919
2020#[ tokio:: main]
@@ -42,6 +42,7 @@ async fn serve(config: GlazedConfig) -> Result<(), Box<dyn error::Error>> {
4242
4343 let app = Router :: new ( )
4444 . route ( "/graphql" , post ( graphql_handler :: < TiledClient > ) )
45+ . route ( "/graphiql" , get ( graphiql_handler) )
4546 . layer ( Extension ( schema) ) ;
4647
4748 let listener = tokio:: net:: TcpListener :: bind ( config. bind_address ) . await ?;
You can’t perform that action at this time.
0 commit comments