@@ -20,7 +20,7 @@ table! {
20
20
id -> Integer ,
21
21
author -> Nullable<Integer >,
22
22
title -> Text ,
23
- datetime -> Timestamp ,
23
+ datetime -> Nullable< Timestamp > ,
24
24
content -> Nullable<Text >,
25
25
}
26
26
}
@@ -44,8 +44,8 @@ allow_tables_to_appear_in_same_query!(
44
44
#[primary_key(id)]
45
45
pub struct Comment {
46
46
id : i32 ,
47
- post : Option <i32 >,
48
- commenter: Option<i32 >,
47
+ post : Option < HasOne < i32 , Post > > ,
48
+ commenter : Option < HasOne < i32 , User > > ,
49
49
content : String ,
50
50
}
51
51
@@ -54,10 +54,11 @@ pub struct Comment {
54
54
#[primary_key(id)]
55
55
pub struct Post {
56
56
id : i32 ,
57
- author : Option <i32 >,
57
+ author : Option < HasOne < i32 , User > > ,
58
58
title : String ,
59
- datetime: chrono::naive::NaiveDateTime,
59
+ datetime : Option < chrono ::naive ::NaiveDateTime > ,
60
60
content : Option <String >,
61
+ comments: HasMany<Comment, comments::post>,
61
62
}
62
63
63
64
#[derive(Clone, Debug, Identifiable, WundergraphEntity)]
@@ -66,6 +67,8 @@ pub struct Post {
66
67
pub struct User {
67
68
id : i32 ,
68
69
name : String ,
70
+ comments : HasMany < Comment , comments ::commenter > ,
71
+ posts : HasMany < Post , posts ::author > ,
69
72
}
70
73
71
74
@@ -83,7 +86,6 @@ wundergraph::query_object!{
83
86
#[graphql(scalar = "WundergraphScalarValue")]
84
87
#[table_name = "comments"]
85
88
pub struct NewComment {
86
- id : i32 ,
87
89
post : Option <i32 >,
88
90
commenter: Option<i32 >,
89
91
content: String,
@@ -104,9 +106,9 @@ pub struct CommentChangeset {
104
106
#[graphql(scalar = "WundergraphScalarValue")]
105
107
#[table_name = "posts"]
106
108
pub struct NewPost {
107
- id : i32 ,
108
109
author : Option <i32 >,
109
110
title: String,
111
+ datetime: Option<chrono::naive::NaiveDateTime>,
110
112
content: Option<String >,
111
113
}
112
114
@@ -118,15 +120,14 @@ pub struct PostChangeset {
118
120
id : i32 ,
119
121
author : Option <i32 >,
120
122
title: String,
121
- datetime: chrono::naive::NaiveDateTime,
123
+ datetime: Option< chrono::naive::NaiveDateTime> ,
122
124
content: Option<String >,
123
125
}
124
126
125
127
#[derive(Insertable, juniper::GraphQLInputObject, Clone, Debug)]
126
128
#[graphql(scalar = "WundergraphScalarValue")]
127
129
#[table_name = "users"]
128
130
pub struct NewUser {
129
- id : i32 ,
130
131
name : String ,
131
132
}
132
133
@@ -147,4 +148,3 @@ wundergraph::mutation_object!{
147
148
}
148
149
}
149
150
150
-
0 commit comments