Skip to content
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

Records are not fetching properly in AWS GraphQl #8851

Closed
3 tasks done
Ni7iN opened this issue Sep 6, 2021 · 3 comments
Closed
3 tasks done

Records are not fetching properly in AWS GraphQl #8851

Ni7iN opened this issue Sep 6, 2021 · 3 comments
Assignees
Labels
GraphQL Related to GraphQL API issues

Comments

@Ni7iN
Copy link

Ni7iN commented Sep 6, 2021

Before opening, please confirm:

JavaScript Framework

React

Amplify APIs

GraphQL API

Amplify Categories

api

Environment information

# Put output below this line

Describe the bug

We are using graphql queries for fetching data from dynamodb but records are not fetching properly when the table data is large.
When setting the limit it returns only some of the data.
Please suggest a workaround

Expected behavior

All the records that is set by the limit should be fetched from the table.

Reproduction steps

  1. Install '...'
  2. Configure '...'
  3. Go to '...'
  4. See error

Code Snippet

// Put your code below this line.
module.exports = function getAWSAppSync(token) {
    const getFunctionToken = async () => await token;
    const client = new AWSAppSyncClient({
        url: aws_exports.aws_appsync_graphqlEndpoint,
        region: aws_exports.aws_appsync_region,
        auth: {
            type: AUTH_TYPE.AWS_LAMBDA,
            token: () => getFunctionToken()
        },
        disableOffline: true
    });
    return client;
}

    /**
     * Find the record inside the model using a filter query
     * 
     * @param {} filter - Filter(and|or)
     * @param {} entity - Model Name
     */
   async findByQuery(filter, entity) {

        // Getting graphql queries
        var query = _actions(entity, "list");

        const result = await this.client.query({
            query: gql(query),
            fetchPolicy: 'no-cache',
            variables: {
                filter: this.getQuery(filter),
                limit: 10000
            }
        });

        var method = "list" + _type(entity, true);
        return result["data"][method]["items"];
    }

Log output

// Put your logs below this line


aws-exports.js

No response

Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

@chrisbonifacio chrisbonifacio self-assigned this Sep 7, 2021
@chrisbonifacio chrisbonifacio added API Related to REST API issues GraphQL Related to GraphQL API issues pending-triage Issue is pending triage labels Sep 7, 2021
@chrisbonifacio
Copy link
Member

Hey @Ni7iN 👋 Thanks for raising this issue. From what I can find, there seems to be a 1000 record fetch limit for AppSync queries. Here is the relevant documentation

Iterations in a foreach loop in mapping templates The maximum number of iterations in a #foreach...#end loop in mapping templates 1000

The workaround seems to be querying the 1000 records and then paginating.

@chrisbonifacio chrisbonifacio added pending-response and removed pending-triage Issue is pending triage labels Sep 7, 2021
@chrisbonifacio
Copy link
Member

Hi 👋 Closing this as we have not heard back from you. If you are still experiencing this issue and in need of assistance, please feel free to comment and provide us with any information previously requested by our team members so we can re-open this issue and be better able to assist you. Thank you!

@github-actions
Copy link

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
GraphQL Related to GraphQL API issues
Projects
None yet
Development

No branches or pull requests

2 participants