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

@@ -1,11 +1,21 @@
use axum::{routing::get, Router};
use como_gql::{graphql_handler, graphql_playground};
use async_graphql::{EmptySubscription, Schema};
use axum::{routing::get, Extension, Router};
use como_gql::{
graphql::{MutationRoot, QueryRoot},
graphql_handler, graphql_playground,
};
use como_infrastructure::register::ServiceRegister;
pub struct GraphQLController;
impl GraphQLController {
pub fn new_router(_service_register: ServiceRegister) -> Router {
Router::new().route("/", get(graphql_playground).post(graphql_handler))
pub fn new_router(service_register: ServiceRegister) -> Router {
let schema = Schema::build(QueryRoot, MutationRoot, EmptySubscription)
.data(service_register)
.finish();
Router::new()
.route("/", get(graphql_playground).post(graphql_handler))
.layer(Extension(schema))
}
}