@@ -55,13 +55,195 @@ The application will be accessible at `http://localhost:8000` by default. You ca
55
55
** Queries:**
56
56
57
57
- Get all blog posts: Retrieve a list of all blog posts with their titles and dates.
58
+ ``` graphql
59
+ query {
60
+ posts {
61
+ title
62
+ content
63
+ author {
64
+ username
65
+ }
66
+ created_at
67
+ updated_at
68
+ }
69
+ }
70
+ ```
71
+
72
+ ``` json
73
+ {
74
+ "data" : {
75
+ "posts" : [
76
+ {
77
+ "title" : " pizza" ,
78
+ "content" : " here we want to learn how make a pizza." ,
79
+ "author" : {
80
+ "username" : " AliAhmadi"
81
+ },
82
+ "created_at" : null ,
83
+ "updated_at" : null
84
+ }
85
+ ]
86
+ }
87
+ }
88
+ ```
58
89
- Get a single blog post: Retrieve detailed information about a specific blog post by its ID.
90
+ ``` graphql
91
+ query {
92
+ post (id : 2 ) {
93
+ id
94
+ title
95
+ content
96
+ created_at
97
+ updated_at
98
+ author {
99
+ name
100
+ username
101
+ email
102
+ }
103
+ }
104
+ }
105
+ ```
106
+ ``` json
107
+ {
108
+ "data" : {
109
+ "post" : {
110
+ "id" : " 2" ,
111
+ "title" : " pizza" ,
112
+ "content" : " here we want to learn how make a pizza." ,
113
+ "created_at" : null ,
114
+ "updated_at" : null ,
115
+ "author" : {
116
+ "name" : " Ali" ,
117
+ "username" : " AliAhmadi" ,
118
+ "email" : " aliahmadi82c@gmail.com"
119
+ }
120
+ }
121
+ }
122
+ }
123
+ ```
59
124
- Search blog posts: Search for blog posts based on keywords and retrieve a list of matching posts.
125
+ ``` graphql
126
+ query {
127
+ search (key : " pizza" ) {
128
+ id
129
+ title
130
+ content
131
+ created_at
132
+ updated_at
133
+ category {
134
+ description
135
+ }
136
+ }
137
+ }
138
+ ```
139
+ ``` json
140
+ {
141
+ "data" : {
142
+ "search" : [
143
+ {
144
+ "id" : " 2" ,
145
+ "title" : " pizza" ,
146
+ "content" : " here we want to learn how make a pizza." ,
147
+ "created_at" : null ,
148
+ "updated_at" : null ,
149
+ "category" : {
150
+ "description" : " posts related to food world"
151
+ }
152
+ }
153
+ ]
154
+ }
155
+ }
156
+ ```
60
157
- Get all categories: Retrieve a list of all blog categories.
158
+ ``` graphql
159
+ query {
160
+ categories {
161
+ id
162
+ name
163
+ description
164
+ created_at
165
+ updated_at
166
+ __typename
167
+ }
168
+ }
169
+ ```
170
+ ``` json
171
+ {
172
+ "data" : {
173
+ "categories" : [
174
+ {
175
+ "id" : " 1" ,
176
+ "name" : " food" ,
177
+ "description" : " posts related to food world" ,
178
+ "created_at" : null ,
179
+ "updated_at" : null ,
180
+ "__typename" : " Category"
181
+ }
182
+ ]
183
+ }
184
+ }
185
+ ```
61
186
- Get all tags: Retrieve a list of all blog tags.
62
- - Get recent posts: Retrieve a list of the most recent blog posts.
187
+ ``` graphql
188
+ query {
189
+ tags {
190
+ id
191
+ name
192
+ description
193
+ created_at
194
+ updated_at
195
+ __typename
196
+ }
197
+ }
198
+ ```
199
+ ``` json
200
+ {
201
+ "data" : {
202
+ "tags" : []
203
+ }
204
+ }
205
+ ```
63
206
- Get popular posts: Retrieve a list of the most popular blog posts based on views or comments.
64
- - Get comments for a post: Retrieve all comments associated with a specific blog post.
207
+ ``` graphql
208
+ query {
209
+ popularPosts {
210
+ id
211
+ title
212
+ content
213
+ author {
214
+ username
215
+ email
216
+ }
217
+ likes
218
+ views
219
+ isPublished
220
+ created_at
221
+ updated_at
222
+ }
223
+ }
224
+ ```
225
+ ``` json
226
+ {
227
+ "data" : {
228
+ "popularPosts" : [
229
+ {
230
+ "id" : " 2" ,
231
+ "title" : " pizza" ,
232
+ "content" : " here we want to learn how make a pizza." ,
233
+ "author" : {
234
+ "username" : " AliAhmadi" ,
235
+ "email" : " aliahmadi82c@gmail.com"
236
+ },
237
+ "likes" : 34 ,
238
+ "views" : 2974 ,
239
+ "isPublished" : true ,
240
+ "created_at" : null ,
241
+ "updated_at" : null
242
+ }
243
+ ]
244
+ }
245
+ }
246
+ ```
65
247
- Get user profile: Retrieve information about the currently logged-in user.
66
248
- Get user's own posts: Retrieve a list of blog posts created by the currently logged-in user.
67
249
- Get user's favorite posts: Retrieve a list of blog posts marked as favorites by the currently logged-in user.
0 commit comments