Skip to content

Commit 8c4c237

Browse files
author
RobJellinghaus
committed
Fix ID handling
1 parent 69d2649 commit 8c4c237

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

backend/models/todo/generated.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub type ConnectionType = create_rust_app::Connection;
88

99
/// Struct representing a row in table `todo`
1010
#[tsync::tsync]
11-
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, diesel::Queryable, diesel::Selectable, diesel::QueryableByName, diesel::Identifiable, async_graphql::SimpleObject)]
11+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, diesel::Queryable, diesel::Selectable, diesel::QueryableByName, diesel::Identifiable)]
1212
#[diesel(table_name=todo, primary_key(id))]
1313
pub struct Todo {
1414
/// Field representing column `id`
@@ -21,6 +21,25 @@ pub struct Todo {
2121
pub updated_at: chrono::DateTime<chrono::Utc>,
2222
}
2323

24+
#[async_graphql::Object]
25+
impl Todo {
26+
async fn id(&self) -> async_graphql::ID {
27+
async_graphql::ID(self.id.to_string())
28+
}
29+
30+
async fn text(&self) -> &String {
31+
&self.text
32+
}
33+
34+
async fn created_at(&self) -> &chrono::DateTime<chrono::Utc> {
35+
&self.created_at
36+
}
37+
38+
async fn updated_at(&self) -> &chrono::DateTime<chrono::Utc> {
39+
&self.updated_at
40+
}
41+
}
42+
2443
/// Create Struct for a row in table `todo` for [`Todo`]
2544
#[tsync::tsync]
2645
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, diesel::Insertable)]

0 commit comments

Comments
 (0)