use async_graphql_axum::{GraphQLRequest, GraphQLResponse}; use axum::{ extract::Extension, http::{Method, StatusCode}, response::{Html, IntoResponse}, routing::{get, post}, Json, Router, }; use axum_extra::extract::cookie::Key; use async_graphql::{ http::{playground_source, GraphQLPlaygroundConfig}, EmptySubscription, Schema, }; use axum_sessions::{ async_session::MemoryStore, extractors::{ReadableSession, WritableSession}, SessionLayer, }; use graphql::CibusSchema; use serde::{Deserialize, Serialize}; use serde_json::{json, Value}; use sqlx::PgPool; use tower_http::{cors::CorsLayer, trace::TraceLayer}; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; use crate::graphql::{MutationRoot, QueryRoot}; pub mod graphql; pub async fn graphql_handler( schema: Extension, session: ReadableSession, req: GraphQLRequest, ) -> Result { let req = req.into_inner(); Ok(schema.execute(req).await.into()) } pub async fn graphql_playground() -> impl IntoResponse { Html(playground_source(GraphQLPlaygroundConfig::new("/"))) }