From 91bfbd1abeb37ced029afba966a7134d92838baa Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Wed, 21 Aug 2024 12:29:23 +0200 Subject: Add users Query must be something like '{users { id, email, password, isAdmin }}' --- src/graphql/types.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/graphql/types.rs (limited to 'src/graphql/types.rs') 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 + } +} -- cgit v1.2.3-71-g8e6c