Efficient way to fetch data from server using GraphQL (avoiding pagination)

0

Context: My app needs to load data from a 'Users' table on the backend. In order to do this, when User-X signs in, I make GraphQL calls to that table to find the user.

Problem: Amplify only checks 1000 records at a time. If it finds User-X in the first 1000, it will return me his data. If not, I have to make another API call to the server, and look for User-X in the next 1000 records. And so on.

Reference: https://docs.amplify.aws/lib/graphqlapi/query-data/q/platform/android/#list-items

Why this is a problem: Paginating in this way via multiple API calls to the back is obviously not optimal, since the latency of my app will increase proportionately to my userbase.

Question: I am sure there must be a more efficient way to do this. Any thoughts?

1 Answer
0

Take a look at this article: https://aws.amazon.com/graphql/graphql-dynamodb-data-modeling/

A lot has to do with table design, single vs. multi-table. Pagination is not a bad thing, especially for mobile or web clients who may not scroll through 1000's of record. I would make the pagination parameter configurable, do some testing based on how the client uses the front end. If this is an analytics apps, then a relational app with more complex SQL might be better.

profile pictureAWS
Roly
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions