with graphql

This commit is contained in:
2022-10-04 12:06:00 +02:00
parent 5e9001b998
commit c7f8dc6198
8 changed files with 39 additions and 44 deletions

View File

@@ -3,8 +3,7 @@ use async_graphql::{Context, EmptySubscription, Object, Schema};
use como_domain::item::{requests::CreateItemDto, responses::CreatedItemDto};
use como_infrastructure::register::ServiceRegister;
pub type CibusSchema = Schema<QueryRoot, MutationRoot, EmptySubscription>;
pub type ComoSchema = Schema<QueryRoot, MutationRoot, EmptySubscription>;
pub struct MutationRoot;

View File

@@ -1,30 +1,17 @@
use async_graphql_axum::{GraphQLRequest, GraphQLResponse};
use axum::{
extract::Extension,
http::{StatusCode},
http::StatusCode,
response::{Html, IntoResponse},
};
use async_graphql::{
http::{playground_source, GraphQLPlaygroundConfig},
};
use axum_sessions::{
extractors::{ReadableSession},
};
use graphql::CibusSchema;
use async_graphql::http::{playground_source, GraphQLPlaygroundConfig};
use graphql::ComoSchema;
pub mod graphql;
pub async fn graphql_handler(
schema: Extension<CibusSchema>,
_session: ReadableSession,
schema: Extension<ComoSchema>,
req: GraphQLRequest,
) -> Result<GraphQLResponse, StatusCode> {
let req = req.into_inner();
@@ -33,5 +20,5 @@ pub async fn graphql_handler(
}
pub async fn graphql_playground() -> impl IntoResponse {
Html(playground_source(GraphQLPlaygroundConfig::new("/")))
Html(playground_source(GraphQLPlaygroundConfig::new("/graphql")))
}