Add a graphiql instance to /graphiql
This commit is contained in:
parent
e3cccfe5ba
commit
6f692d7a5a
1 changed files with 6 additions and 0 deletions
|
|
@ -1,6 +1,8 @@
|
||||||
|
use async_graphql::http::GraphiQLSource;
|
||||||
use async_graphql_axum::{GraphQLRequest, GraphQLResponse};
|
use async_graphql_axum::{GraphQLRequest, GraphQLResponse};
|
||||||
use axum::{
|
use axum::{
|
||||||
Router,
|
Router,
|
||||||
|
response::Html,
|
||||||
routing::{get, post},
|
routing::{get, post},
|
||||||
};
|
};
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
|
|
@ -29,6 +31,10 @@ async fn main() -> anyhow::Result<()> {
|
||||||
let schema = schema.clone();
|
let schema = schema.clone();
|
||||||
move || async move { axum::Json(schema.sdl()) }
|
move || async move { axum::Json(schema.sdl()) }
|
||||||
}),
|
}),
|
||||||
|
)
|
||||||
|
.route(
|
||||||
|
"/graphiql",
|
||||||
|
get(Html(GraphiQLSource::build().endpoint("/graphql").finish())),
|
||||||
);
|
);
|
||||||
|
|
||||||
let addr = SocketAddr::from(([0, 0, 0, 0], 3000));
|
let addr = SocketAddr::from(([0, 0, 0, 0], 3000));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue