question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@connect - one to many - nextToken usage

See original GitHub issue

Note: If your question is regarding the AWS Amplify Console service, please log it in the official AWS Amplify Console forum

Which Category is your question related to? API GraphQL

Amplify CLI Version

You can use amplify -v to check the amplify cli version on your system 4.45

What AWS Services are you utilizing? Lambda, AppSync, Cloudfront, DynamoDB.

Provide additional details e.g. code snippets

I set up a one-to-many relationship between a couple of model. It works fine. I’m able to query for the one model record and from that get the many model records. However, I set a limit of 10 for the many model records but it’s not obvious to me how to use the nextToken value to retrieve the other many model records.

I’ve tried using the list query for the many model and the list query for the one model but I get the invalid start key error. How can I use the nextToken value to get the other many model records?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
codeinairecommented, Mar 24, 2021

@yuth it appears to be working. Thanks for your help!

BTW, is this anywhere in the docs? I couldn’t find anything like this and not sure if it’s not there or I just didn’t look in the right places.

1reaction
yuthcommented, Mar 23, 2021

@codeinaire the mappingDatas field can take an argument called nextToken and when you pass that it would use that value to paginate the mapping data. So the updated query would look somewhat like this

export const listPageFormss = /* GraphQL */ `
  query ListPageFormss(
    $filter: ModelPageFormsFilterInput
    $limit: Int
    $nextToken: String
    $mappingDataNextToken: String
  ) {
    listPageFormss(filter: $filter, limit: $limit, nextToken: $nextToken) {
      items {
        id
        pageId
        createdAt
        updatedAt
        mappingDatas (nextToken: $mappingDataNextToken){
          items {
            id
            formName
            formId
            pageId
            # Other fields that you're interested in
          }
          nextToken
        }
      }
      nextToken
    }
  }

When trying to get the next page of mappingData pass the you will need to pass the nextToken from mappingDatas of each listPageFormss to mappingDataNextToken

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do you use "NextToken" in AWS API calls - Stack Overflow
This is how the AWS SDK handles pagination in many cases. You will see the usage of the NextToken in other service clients...
Read more >
API (GraphQL) - GraphQL pagination - JavaScript - Amplify Docs
The nextToken is what is used to handle pagination. If the nextToken is null , that means that there is no more data...
Read more >
Unable to list the connected table's fields in has many ... - GitHub
I'm trying to connect two tables with @connection(name: "ConnectionName") . But I can't able to list the connected table's data in a single...
Read more >
ListDelegatedAdministrators - AWS Organizations
Lists the AWS accounts that are designated as delegated administrators in this organization.
Read more >
Multiple Authorization methods in a single GraphQL API with ...
Now there's a much easier way, you can use multiple authorization modes in ... address is not available if I'm connecting with an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found