fix GET when query is set

This commit is contained in:
41666 2022-11-27 19:03:16 -05:00
parent 1da3cd2cef
commit 7d7dd0d64c
2 changed files with 5 additions and 3 deletions

View file

@ -42,10 +42,11 @@ async fn graphql_handler_get(
Extension(schema): Extension<Schema<query::Query, EmptyMutation, EmptySubscription>>,
query: Query<Request>,
) -> axum::response::Response {
match query.operation_name {
Some(_) => Json(schema.execute(query.0).await).into_response(),
None => Redirect::to("/graphql/playground").into_response(),
if query.query == "" {
return Redirect::to("/graphql/playground").into_response();
}
Json(schema.execute(query.0).await).into_response()
}
async fn graphql_playground() -> impl IntoResponse {
Html(playground_source(GraphQLPlaygroundConfig::new("/graphql")))