1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-07-29 22:01:14 +03:00

Initial GraphQL API

This commit is contained in:
Quentin Gliech
2022-11-04 18:59:25 +01:00
parent 35e5a5a7a7
commit c13b0478e6
10 changed files with 518 additions and 9 deletions

View File

@ -203,6 +203,8 @@ impl Options {
.context("could not watch for templates changes")?;
}
let graphql_schema = mas_handlers::graphql_schema(&pool);
let state = Arc::new(AppState {
pool,
templates,
@ -212,6 +214,7 @@ impl Options {
mailer,
homeserver,
policy_factory,
graphql_schema,
});
let mut fd_manager = listenfd::ListenFd::from_env();

View File

@ -31,7 +31,7 @@ use rustls::ServerConfig;
pub fn build_router<B>(state: &Arc<AppState>, resources: &[HttpResource]) -> Router<AppState, B>
where
B: HttpBody + Send + 'static,
<B as HttpBody>::Data: Send,
<B as HttpBody>::Data: Into<axum::body::Bytes> + Send,
<B as HttpBody>::Error: std::error::Error + Send + Sync,
{
let mut router = Router::with_state_arc(state.clone());
@ -50,6 +50,9 @@ where
mas_config::HttpResource::Human => {
router.merge(mas_handlers::human_router(state.clone()))
}
mas_config::HttpResource::GraphQL { playground } => {
router.merge(mas_handlers::graphql_router(state.clone(), *playground))
}
mas_config::HttpResource::Static { web_root } => {
let handler = mas_static_files::service(web_root);
router.nest(mas_router::StaticAsset::route(), handler)