22 lines
476 B
Rust
22 lines
476 B
Rust
|
use async_graphql::{
|
||
|
*,
|
||
|
http::GraphiQLSource,
|
||
|
};
|
||
|
use axum::{
|
||
|
response::{Html, IntoResponse},
|
||
|
routing::get,
|
||
|
Router,
|
||
|
};
|
||
|
use crate::{entity::{UserEntity, UserModel},};
|
||
|
|
||
|
pub struct Query;
|
||
|
|
||
|
#[Object]
|
||
|
impl Query {
|
||
|
pub async fn user(&self, user_name: String) -> Result<Option<UserModel>> {
|
||
|
Ok(UserEntity::find_by_name(&user_name).await?)
|
||
|
}
|
||
|
pub async fn users(&self) -> Result<Vec<UserModel>> {
|
||
|
Ok(UserEntity::find_all().await?)
|
||
|
}
|
||
|
}
|