简体   繁体   中英

AWS AppSync GraphQL API only return 20 items from DynamoDB

I'm try to run queries to AWS AppSync to fetch all list of Todos which I got around 50 items in DynamonDB but the result only return 20 items in my web, is there any limitation for AppSync?

I used amplify library to run the query:

API.graphql(
        graphqlOperation(queries.listTodos)
    )

How could I get all the 50 items from my dynamoDB?

Query:

export const listTodos = `query ListTodos(
  $filter: TableTodoFilterInput
  $limit: Int
  $nextToken: String
) {
  listTodos(filter: $filter, limit: $limit, nextToken: $nextToken) {
    items {
      id
      dateIn
      dateOut
      reservedBy
      status
      ttl
      createdON
    }
    nextToken
  }
}
`;

Sample data:

"items": [
        {
          "id": "ad2ce180-eae4-4bbd-abbc-00375e2dabd9",
          "dateIn": "2019-03-13",
          "dateOut": "2019-03-16",
          "reservedBy": "Harith",
          "status": "Pending Payment",
          "ttl": 1552357596,
          "createdON": "2019-03-11T02:26:36.608Z"
        },

In your listTodos resolver's Request mapping template probably has the following line:

"limit": $util.defaultIfNull(${ctx.args.limit}, 20), 

Change this limit to something other than 20, or make it really high if you don't want results to be limited. (Note: DynamoDB will automatically paginate once your result set reaches 1 MB.) However it's typically a good practice to have some kind of reasonable limit set for Scan operations, as a Scan operation can consume 100% of the provisioned read capacity of the table and throttle other requests to your table . This is especially important as your table grows in size, but for 50 records, this shouldn't be an issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM