Open loe-lobo opened 11 months ago
I believe I've found the culprit, if Amplify Studio uses the autogenerated Autocomplete from Amplify-UI. This is the code generated by Amplify-UI (Figma-to-code) for a autocomplete field:
const fetchTickerRecords = async (value) => {
setTickerLoading(true);
const newOptions = [];
let newNext = "";
while (newOptions.length < autocompleteLength && newNext != null) {
const variables = {
limit: autocompleteLength * 5,
filter: {
or: [{ name: { contains: value } }, { symbol: { contains: value } }],
},
};
if (newNext) {
variables["nextToken"] = newNext;
}
const result = (
await client.graphql({
query: listTickers.replaceAll("__typename", ""),
variables,
})
)?.data?.listTickers?.items;
var loaded = result.filter(
(item) => !tickerIdSet.has(getIDValue.ticker?.(item))
);
newOptions.push(...loaded);
newNext = result.nextToken;
}
setTickerRecords(newOptions.slice(0, autocompleteLength));
setTickerLoading(false);
};
The problem here is that
result.nextToken
doesn't exist. The nextToken
property is outside of the items
list.
I was able to reproduce the issue, marking as bug.
Before opening, please confirm:
App Id
d1thx85qzidq63
Region
sa-east-1
Environment name
dev
Figma File Version (if applicable)
No response
Amplify CLI Version
12.10.0
If applicable, what version of Node.js are you using?
v18.17.1
What operating system are you using?
Mac
Browser type?
Google Chrome
Describe the bug
Autocomplete field isn't loading all the data from DynamoDB (AppSync API).
When searching for
BB
the result box should show 23 results, but it only shows 1. I can see that the first query executed has a NextToken populated, but the UI isn't looping through the results to load all matching items from DB.Expected behavior
When searching for an Item on Autocomplete in Data Manager, I would expect to get all results that match the filter.
Reproduction steps
type PortfolioTicker @model @auth( rules: [ { allow: private, provider: iam } ] ) { portfolioId: ID! @primaryKey(sortKeyFields: ["symbol"]) @index(name: "byPortfolio") portfolio: Portfolio @belongsTo(fields: ["portfolioId"]) symbol: String! @index(name: "byTicker") ticker: Ticker @belongsTo(fields: ["symbol"]) entryDate: AWSDateTime! }
type Ticker @model @auth( rules: [ { allow: private, provider: iam } ] ) { symbol: String! @primaryKey name: String portfolioTickers: [PortfolioTicker] @hasMany(indexName: "byTicker", fields: ["symbol"]) }