INNER CODE UNIT · Rust
index
rkudryashov/graphql-rust-demo · satellites-service/src/lib.rs:26
async fn index(schema: web::Data<AppSchema>, req: GraphQLRequest) -> GraphQLResponse {
schema.execute(req.into_inner()).await.into()
}
async fn index_playground() -> HttpResponse {
HttpResponse::Ok()
.content_type("text/html; charset=utf-8")
.body(playground_source(GraphQLPlaygroundConfig::new("/")))
}
pub fn create_schema_with_context(pool: PgPool) -> Schema<Query, EmptyMutation, EmptySubscription> {
Schema::build(Query, EmptyMutation, EmptySubscription)
.data(pool)
.finish()
}
pub fn run_migrations(conn: &mut PooledConnection<ConnectionManager<PgConnection>>) {
conn.run_pending_migrations(MIGRATIONS)