diff --git a/src/graphql.rs b/src/graphql.rs index 76ae1cb..b462261 100644 --- a/src/graphql.rs +++ b/src/graphql.rs @@ -373,6 +373,16 @@ impl Query { #[graphql_object(context = Context)] impl Query { + async fn get_user_id(context: &Context, username: String) -> FieldResult { + sqlx::query(format!( + r#"SELECT id FROM users WHERE user_name="{}""#, + username + ).as_str()).fetch_one(&context.db).await? + .try_get::("id") + .map(ID::new) + .map_err(FieldError::from) + } + async fn users(context: &Context) -> FieldResult> { Self::users_sqlx_result(context).await.map_err(FieldError::from) }