INNER CODE UNIT · Rust
create_schema_with_context
rkudryashov/graphql-rust-demo · auth-service/src/lib.rs:47
pub fn create_schema_with_context(pool: PgPool) -> Schema<Query, Mutation, EmptySubscription> {
Schema::build(Query, Mutation, EmptySubscription)
.enable_federation()
.data(pool)
.finish()
}
pub fn run_migrations(conn: &mut PooledConnection<ConnectionManager<PgConnection>>) {
conn.run_pending_migrations(MIGRATIONS)
.expect("Failed to run database migrations");
// if environment variable is set (in case of production environment), then update users' hash
if let Ok(hash) = std::env::var("SECURED_USER_PASSWORD_HASH") {
repository::update_password_hash(hash, conn).expect("Failed to update password hash");
};
}
pub fn get_conn_from_ctx(ctx: &Context<'_>) -> PooledConnection<ConnectionManager<PgConnection>> {