aws-amplify / aws-amplify/amplify-codegen
Better Codegen: Pagination Support
- Dominant language
- TypeScript
- Stars
- 59
- Forks
- 64
- PR merge metrics
- No merged PRs in 30d
Description
**Is your feature request related to a problem? Please describe.**
Is there any chance codegen can be enhanced to allow for pagination out of the box? It'd be great to not have to write my own queries.ts with this ability.
**Describe the solution you'd like**
Take a model like this:
```
type User @model {
id: ID!
todos: [Todo] @connection(fields:["id"])
}
type Todo @model {
id: ID!
userID: ID!
user: User @connection(fields:["userID"]
}
```
As codegen operates currently, a queries file will be generated that looks something lik:
```
export const getUser =
GetUser($id: ID!) {
getUser($id: ID!) {
id
todos {
items {
id
}
}
}
}
```
To my understanding, pagination can only be achieved by then implementing a custom query like so:
```
export const getUser =
GetUser($id: ID!, $limit: Int, $nextToken: String) {
getUser($id: ID!, $limit: Int, $nextToken: String) {
id
todos(limit: $limit, nextToken: $nextToken) {
items {
id
}
}
}
}
```
I think this is a fairly easy opportunity to automate this process with codegen.
**Describe alternatives you've considered**
I use string interpolation to implement this functionality but it's really annoying when the schema changes to have to re-update the query.
Contributor guide
Assessment
This issue has not been assessed yet.