lawmicha / datastoreList

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DataStore Blog Post Comment

This is a getting started with DataStore using the default Blog/Post/Comment schema from amplify add api

  1. amplify init

  2. 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”)
  1. amplify update api and choose Enable for DataStore

  2. amplify push and amplify codegen models

  3. pod install

  4. xed .

  5. Click Populate to create 10 Blogs, 10 Posts for each blog, 10s Comment for each post

  6. 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
  }
}


  1. Once the app has completed saving, when the console logging finishes, click on View to display the blogs/post/comments

About


Languages

Language:Swift 95.4%Language:Ruby 4.6%