2021-09-26 16:59:56 +02:00
|
|
|
use sqlx::SqlitePool;
|
|
|
|
use warp::{
|
|
|
|
Filter,
|
|
|
|
};
|
|
|
|
|
|
|
|
use crate::graphql::{
|
|
|
|
Context,
|
|
|
|
schema,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
pub async fn web(db: SqlitePool){
|
|
|
|
|
|
|
|
std::env::set_var("RUST_LOG", "warp_async");
|
|
|
|
let state = warp::any().map(move || Context { db: db.clone() });
|
|
|
|
let graphql_filter = juniper_warp::make_graphql_filter(schema(), state.boxed());
|
|
|
|
|
|
|
|
warp::serve(
|
|
|
|
warp::get()
|
|
|
|
.and(warp::path("graphiql"))
|
|
|
|
.and(juniper_warp::graphiql_filter("/graphql", None))
|
|
|
|
.or(warp::path("graphql").and(graphql_filter)),
|
|
|
|
)
|
2021-10-18 14:36:11 +02:00
|
|
|
.run(([0, 0, 0, 0], 8080))
|
2021-09-26 16:59:56 +02:00
|
|
|
.await;
|
|
|
|
}
|