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 個回答
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
已回答 1 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南