@@ -20,7 +20,7 @@ table! {
2020 id -> Integer ,
2121 author -> Nullable<Integer >,
2222 title -> Text ,
23- datetime -> Timestamp ,
23+ datetime -> Nullable< Timestamp > ,
2424 content -> Nullable<Text >,
2525 }
2626}
@@ -44,8 +44,8 @@ allow_tables_to_appear_in_same_query!(
4444#[primary_key(id)]
4545pub struct Comment {
4646 id : i32 ,
47- post : Option <i32 >,
48- commenter: Option<i32 >,
47+ post : Option < HasOne < i32 , Post > > ,
48+ commenter : Option < HasOne < i32 , User > > ,
4949 content : String ,
5050}
5151
@@ -54,10 +54,11 @@ pub struct Comment {
5454#[primary_key(id)]
5555pub struct Post {
5656 id : i32 ,
57- author : Option <i32 >,
57+ author : Option < HasOne < i32 , User > > ,
5858 title : String ,
59- datetime: chrono::naive::NaiveDateTime,
59+ datetime : Option < chrono ::naive ::NaiveDateTime > ,
6060 content : Option <String >,
61+ comments: HasMany<Comment, comments::post>,
6162}
6263
6364#[derive(Clone, Debug, Identifiable, WundergraphEntity)]
@@ -66,6 +67,8 @@ pub struct Post {
6667pub struct User {
6768 id : i32 ,
6869 name : String ,
70+ comments : HasMany < Comment , comments ::commenter > ,
71+ posts : HasMany < Post , posts ::author > ,
6972}
7073
7174
@@ -83,7 +86,6 @@ wundergraph::query_object!{
8386#[graphql(scalar = "WundergraphScalarValue")]
8487#[table_name = "comments"]
8588pub struct NewComment {
86- id : i32 ,
8789 post : Option <i32 >,
8890 commenter: Option<i32 >,
8991 content: String,
@@ -104,9 +106,9 @@ pub struct CommentChangeset {
104106#[graphql(scalar = "WundergraphScalarValue")]
105107#[table_name = "posts"]
106108pub struct NewPost {
107- id : i32 ,
108109 author : Option <i32 >,
109110 title: String,
111+ datetime: Option<chrono::naive::NaiveDateTime>,
110112 content: Option<String >,
111113}
112114
@@ -118,15 +120,14 @@ pub struct PostChangeset {
118120 id : i32 ,
119121 author : Option <i32 >,
120122 title: String,
121- datetime: chrono::naive::NaiveDateTime,
123+ datetime: Option< chrono::naive::NaiveDateTime> ,
122124 content: Option<String >,
123125}
124126
125127#[derive(Insertable, juniper::GraphQLInputObject, Clone, Debug)]
126128#[graphql(scalar = "WundergraphScalarValue")]
127129#[table_name = "users"]
128130pub struct NewUser {
129- id : i32 ,
130131 name : String ,
131132}
132133
@@ -147,4 +148,3 @@ wundergraph::mutation_object!{
147148 }
148149}
149150
150-
0 commit comments