21 lines
627 B
Rust
21 lines
627 B
Rust
use std::net::IpAddr;
|
|
use sqlx::SqlitePool;
|
|
use warp::Filter;
|
|
|
|
use crate::graphql::{
|
|
Context,
|
|
schema,
|
|
};
|
|
|
|
pub async fn web(ip_address: IpAddr, port: u16, 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)),
|
|
).run((ip_address, port)).await;
|
|
} |