Closed OmarAbaroa closed 2 years ago
Hi @OmarAbaroa 👋 thanks for raising this issue. Can also you share the schema for your FinancialModelType
?
It seems that you might've been running into a known limitation of the AppSync service. There is a fetch limit of 1000 records because of the service quota for Iterations in a foreach loop in mapping templates.
Including a limit
and nextToken
in subsequent queries until nextToken
is no longer returned (meaning there are no more records that meet filter criteria to fetch) is the correct approach to this limitation.
P.S. For customers using DataStore, there is the DataStore.observeQuery
method which works similarly, fetching records in a paginated way until all records have been fetched and 'isSyncedis
true`.
https://docs.amplify.aws/lib/datastore/real-time/q/platform/js/
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.
Before opening, please confirm:
JavaScript Framework
React Native
Amplify APIs
GraphQL API
Amplify Categories
api
Environment information
Describe the bug
We have a graphql API and we need to list objects using the list queries with a secondary index that helps us to sort the data by date.
In the graphql schema we wrote the auth rules to allow owners to create, read, delete and update their data.
However since last week the list queries are retrieving an empty array of items for our users, even if we know the user has objects that they own.
We recently learned that we might need to add a limit (eg 1000) to the queries and page through results via the nextToken. Strangely, these queries were working fine before a couple of weeks ago and without the use of the limit or nextToken. When we add the limit 1000 and nextToken, we see results for our users.
We're on graphql transformer v2.
Expected behavior
We would expect the list queries to retrieve the expected items without the need for the limit and paging described above and as it was working a couple of weeks ago.
Reproduction steps
type FinancialModel @model @auth(rules: [{ allow: owner }, { allow: groups, groups: ["Admin"] }]) { type: FinancialModelType! @index( name: "listFinancialModelsByDate" queryField: "listFinancialModelsByDate" sortKeyFields: ["createdAt"] ) id: ID! @primaryKey }
query MyQuery { listFinancialModelsByDate(type: FinancialModel, sortDirection: ASC) { items { id } nextToken } }
Code Snippet
Log output
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