In this step, we will scan all the data in the DynamoDB table.
allPost(count: Int, nextToken: String): PaginatedPosts!
type PaginatedPosts {
posts: [Post!]!
nextToken: String
}


{
"version" : "2017-02-28",
"operation" : "Scan"
#if( ${context.arguments.count} )
,"limit": $util.toJson($context.arguments.count)
#end
#if( ${context.arguments.nextToken} )
,"nextToken": $util.toJson($context.arguments.nextToken)
#end
}
This Resolver has 2 input arguments: count - specifies the maximum number of items to return in a single call, and nextToken - can be used to retrieve the next set of results.
#if($context.error)
$util.error($context.error.message, $context.error.type)
#end
{
"posts": $utils.toJson($context.result.items)
#if( ${context.result.nextToken} )
,"nextToken": $util.toJson($context.result.nextToken)
#end
}
The returned query result is a PaginatedPosts, containing a list of posts and a pagination token. The shape of this object is different from what is returned by the AWS AppSync DynamoDB Resolver.

mutation addPost {
post1: addPost(id:"1" author: "AUTHORNAME" title: "A series of posts, Volume 1" content: "Some content" url: "https://aws.amazon.com/appsync/" ) { title }
post2: addPost(id:"2" author: "AUTHORNAME" title: "A series of posts, Volume 2" content: "Some content" url: "https://aws.amazon.com/appsync/" ) { title }
post3: addPost(id:"3" author: "AUTHORNAME" title: "A series of posts, Volume 3" content: "Some content" url: "https://aws.amazon.com/appsync/" ) { title }
post4: addPost(id:"4" author: "AUTHORNAME" title: "A series of posts, Volume 4" content: "Some content" url: "https://aws.amazon.com/appsync/" ) { title }
post5: addPost(id:"5" author: "AUTHORNAME" title: "A series of posts, Volume 5" content: "Some content" url: "https://aws.amazon.com/appsync/" ) { title }
post6: addPost(id:"6" author: "AUTHORNAME" title: "A series of posts, Volume 6" content: "Some content" url: "https://aws.amazon.com/appsync/" ) { title }
post7: addPost(id:"7" author: "AUTHORNAME" title: "A series of posts, Volume 7" content: "Some content" url: "https://aws.amazon.com/appsync/" ) { title }
post8: addPost(id:"8" author: "AUTHORNAME" title: "A series of posts, Volume 8" content: "Some content" url: "https://aws.amazon.com/appsync/" ) { title }
post9: addPost(id:"9" author: "AUTHORNAME" title: "A series of posts, Volume 9" content: "Some content" url: "https://aws.amazon.com/appsync/" ) { title }
}
query scanTable {
allPost(count: 3) {
posts {
id
title
author
}
nextToken
}
}

nextToken to fetch the next pages.
Copy the value of the returned nextToken field (this is a long string code).
Add the nextToken field to the allPost query command, then assign the string value you just copied to it:
query scanTable {
allPost(count: 3, nextToken: "THE_VALUE_YOU_JUST_COPIED") {
posts {
id
title
author
}
nextToken
}
}


So you have scanned the entire table, returning your desired amount each time.