DataStore Blog Post Comment
This is a getting started with DataStore using the default Blog/Post/Comment schema from amplify add api
-
amplify init
-
amplify add api
? Please select from one of the below mentioned services: GraphQL
? Provide API name: datastorelist
? Choose the default authorization type for the API API key
? Enter a description for the API key:
? After how many days from now the API key should expire (1-365): 365
? Do you want to configure advanced settings for the GraphQL API No, I am done.
? Do you have an annotated GraphQL schema? No
? Choose a schema template: One-to-many relationship (e.g., “Blogs” with “Posts” and “Comments”)
-
amplify update api
and choose Enable for DataStore -
amplify push
andamplify codegen models
-
pod install
-
xed .
-
Click Populate to create 10 Blogs, 10 Posts for each blog, 10s Comment for each post
-
amplify console api
and query for blogs, post and comments, ie.
query MyQuery {
listBlogs {
items {
createdAt
id
name
}
nextToken
}
listComments {
items {
content
id
postID
}
nextToken
}
listPosts {
items {
id
title
blogID
}
nextToken
}
}
- Once the app has completed saving, when the console logging finishes, click on View to display the blogs/post/comments