Skip to content

Better Codegen: Pagination Support #187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
karrettgelley opened this issue Apr 29, 2020 · 2 comments
Open

Better Codegen: Pagination Support #187

karrettgelley opened this issue Apr 29, 2020 · 2 comments
Labels
feature-request New feature or request type-gen Issues on graphql-type-generator

Comments

@karrettgelley
Copy link

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.

@Amplifiyer
Copy link
Contributor

Transferring to the codegen team's repo

@Amplifiyer Amplifiyer transferred this issue from aws-amplify/amplify-js Apr 29, 2020
@renebrandel renebrandel transferred this issue from aws-amplify/amplify-cli Jun 15, 2021
@stale
Copy link

stale bot commented Jul 21, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@phani-srikar phani-srikar added feature-request New feature or request type-gen Issues on graphql-type-generator labels Mar 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request type-gen Issues on graphql-type-generator
Projects
None yet
Development

No branches or pull requests

4 participants