Skip to content

Commit 25f0228

Browse files
authored
Merge pull request #105 from ceramicnetwork/update-guides
Update the interact with data guides
2 parents 85aeccb + b74892a commit 25f0228

1 file changed

Lines changed: 56 additions & 31 deletions

File tree

docs/composedb/interact-with-data.mdx

Lines changed: 56 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ In the [Create your composite](./create-your-composite.mdx) guide, we fetched tw
4444

4545
```graphql
4646
query{
47-
postIndex(first: 2) {
47+
postsIndex(first: 2) {
4848
edges {
4949
node {
50-
text
50+
body
5151
}
5252
}
5353
}
@@ -67,16 +67,16 @@ You should see a response similar to the one below. Here, nodes correspond to st
6767
```json
6868
{
6969
"data": {
70-
"postIndex": {
70+
"postsIndex": {
7171
"edges": [
7272
{
7373
"node": {
74-
"text": "This is my first post."
74+
"text": "A Post created using composites and GraphQL"
7575
}
7676
},
7777
{
7878
"node": {
79-
"text": "My second post about ComposeDB!"
79+
"text": "This is my second post!"
8080
}
8181
}
8282
]
@@ -97,10 +97,10 @@ You have options to retrieve specific records or last `n` indexed records as wel
9797

9898
```graphql
9999
query{
100-
postIndex(last: 3) {
100+
postsIndex(last: 3) {
101101
edges {
102102
node {
103-
text
103+
body
104104
}
105105
}
106106
}
@@ -121,11 +121,15 @@ Let’s say, you would like to create a post and add it to the graph. To do that
121121

122122

123123
```graphql
124-
mutation CreateNewPost($i: CreatePostInput!){
125-
createPost(input: $i){
126-
document{
127-
id
128-
text
124+
mutation CreateNewPost($i: CreatePostsInput!){
125+
createPosts(input: $i){
126+
document{
127+
id
128+
title
129+
body
130+
tag
131+
ranking
132+
created_at
129133
}
130134
}
131135
}
@@ -141,7 +145,11 @@ mutation CreateNewPost($i: CreatePostInput!){
141145
{
142146
"i": {
143147
"content": {
144-
"text": "A Post created using composites and GraphQL"
148+
"title": "New post",
149+
"body": "My new post on Ceramic",
150+
"tag": "User post",
151+
"ranking": 5,
152+
"created_at": "2024-12-03T10:15:30Z"
145153
}
146154
}
147155
}
@@ -160,10 +168,14 @@ The result of the query above will be a new document with a unique ID and the co
160168
```json
161169
{
162170
"data": {
163-
"createPost": {
171+
"createPosts": {
164172
"document": {
165-
"id": "kjzl6kcym7w8y9xlffqruh3v7ou1vn11t8203i6te2i3pliizt65ad3vdh5nl4l",
166-
"text": "A Post created using composites and GraphQL"
173+
"id": "kjzl6kcym7w8y5ygh1fyvstbjztd69suybc4ez8bet2hun7jezrc2m0uwg5bm3q",
174+
"title": "New post",
175+
"body": "My new post on Ceramic",
176+
"tag": "User post",
177+
"ranking": 5,
178+
"created_at": "2024-12-03T10:15:30Z"
167179
}
168180
}
169181
}
@@ -173,7 +185,8 @@ The result of the query above will be a new document with a unique ID and the co
173185

174186
:::note
175187

176-
Stream IDs are unique. The “id” you will see in the response when performing the mutation above will be different.
188+
Stream IDs are unique. The “id” you will see in the response when performing the mutation above will be different. Keep that in mind
189+
as you follow this guide and update the id to the one that you see in your response.
177190

178191
:::
179192

@@ -191,11 +204,15 @@ You can find your post’s ID in the response after you ran the `CreateNewPost`
191204
**Query:**
192205

193206
```graphql
194-
mutation UpdatePost($i: UpdatePostInput!) {
195-
updatePost(input: $i) {
207+
mutation UpdatePost($i: UpdatePostsInput!) {
208+
updatePosts(input: $i) {
196209
document {
197210
id
198-
text
211+
title
212+
body
213+
tag
214+
ranking
215+
created_at
199216
}
200217
}
201218
}
@@ -208,24 +225,32 @@ mutation UpdatePost($i: UpdatePostInput!) {
208225
```json
209226
{
210227
"i": {
211-
"id": "kjzl6kcym7w8y9xlffqruh3v7ou1vn11t8203i6te2i3pliizt65ad3vdh5nl4l",
228+
"id": "kjzl6kcym7w8y5ygh1fyvstbjztd69suybc4ez8bet2hun7jezrc2m0uwg5bm3q",
212229
"content": {
213-
"text": "My best post!"
230+
"title": "New post",
231+
"body": "My new post on Ceramic using ComposeDB",
232+
"tag": "User post",
233+
"ranking": 5,
234+
"created_at": "2024-12-03T10:15:30Z"
214235
}
215236
}
216237
}
217238
```
218239

219-
This mutation will update the record with ID `kjzl6kcym7w8y9xlffqruh3v7ou1vn11t8203i6te2i3pliizt65ad3vdh5nl4l`.
240+
This mutation will update the record with ID `kjzl6kcym7w8y5ygh1fyvstbjztd69suybc4ez8bet2hun7jezrc2m0uwg5bm3q`.
220241

221242
**Response:**
222243
```json
223244
{
224245
"data": {
225-
"updatePost": {
246+
"updatePosts": {
226247
"document": {
227-
"id": "kjzl6kcym7w8y9xlffqruh3v7ou1vn11t8203i6te2i3pliizt65ad3vdh5nl4l",
228-
"text": "My best post!"
248+
"id": "kjzl6kcym7w8y5ygh1fyvstbjztd69suybc4ez8bet2hun7jezrc2m0uwg5bm3q",
249+
"title": "New post",
250+
"body": "My new post on Ceramic using ComposeDB",
251+
"tag": "User post",
252+
"ranking": 5,
253+
"created_at": "2024-12-03T10:15:30Z"
229254
}
230255
}
231256
}
@@ -241,8 +266,8 @@ mutation with the `shouldIndex` option set to `true`, and the post ID as variabl
241266
**Query:**
242267

243268
```graphql
244-
mutation EnableIndexingPost($input: EnableIndexingPostInput!) {
245-
enableIndexingPost(input: $input) {
269+
mutation EnableIndexingPost($i: EnableIndexingPostsInput!) {
270+
enableIndexingPosts(input: $i) {
246271
document {
247272
id
248273
}
@@ -257,19 +282,19 @@ mutation EnableIndexingPost($input: EnableIndexingPostInput!) {
257282
```json
258283
{
259284
"i": {
260-
"id": "kjzl6kcym7w8y9xlffqruh3v7ou1vn11t8203i6te2i3pliizt65ad3vdh5nl4l",
285+
"id": "kjzl6kcym7w8y5ygh1fyvstbjztd69suybc4ez8bet2hun7jezrc2m0uwg5bm3q",
261286
"shouldIndex": false
262287
}
263288
}
264289
```
265290

266-
This mutation will un-index the record with ID `kjzl6kcym7w8y9xlffqruh3v7ou1vn11t8203i6te2i3pliizt65ad3vdh5nl4l`.
291+
This mutation will un-index the record with ID `kjzl6kcym7w8y5ygh1fyvstbjztd69suybc4ez8bet2hun7jezrc2m0uwg5bm3q`.
267292

268293
**Response:**
269294
```json
270295
{
271296
"data": {
272-
"enableIndexingPost": {
297+
"enableIndexingPosts": {
273298
"document": null
274299
}
275300
}

0 commit comments

Comments
 (0)