diff options
| author | Santo Cariotti <santo@dcariotti.me> | 2024-08-21 10:29:23 +0000 |
|---|---|---|
| committer | Santo Cariotti <santo@dcariotti.me> | 2024-08-21 10:29:23 +0000 |
| commit | 91bfbd1abeb37ced029afba966a7134d92838baa (patch) | |
| tree | dffcbeae78b89a76120ba476aeae4dda95effd61 /src/graphql/types.rs | |
| parent | 185ba5270aaf94de9b91e4455be27db5198ec21e (diff) | |
Add users
Query must be something like '{users { id, email, password, isAdmin }}'
Diffstat (limited to 'src/graphql/types.rs')
| -rw-r--r-- | src/graphql/types.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/graphql/types.rs b/src/graphql/types.rs new file mode 100644 index 0000000..79241df --- /dev/null +++ b/src/graphql/types.rs @@ -0,0 +1,29 @@ +use async_graphql::Object; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct User { + pub id: i32, + pub email: String, + pub password: String, + pub is_admin: bool, +} + +#[Object] +impl User { + async fn id(&self) -> i32 { + self.id + } + + async fn email(&self) -> String { + self.email.clone() + } + + async fn password(&self) -> String { + String::from("******") + } + + async fn is_admin(&self) -> bool { + self.is_admin + } +} |
