amplify-codegen
amplify-codegen copied to clipboard
API: Improve AppSync codegen step
Is your feature request related to a problem? Please describe.
During the amplify push flow, the prompt "Do you want to generate code for your newly created GraphQL API" and the generated API file seem to confuse users when the project adopts DataStore https://github.com/aws-amplify/docs/issues/2768 as amplify codegen models also generates the actual Swift models.
Describe the solution you'd like
We should skip the AppSync flows and not generate an API.swift unless the CLI detects that the project is using AppSync, or unless the customer explicitly opts in.
Describe alternatives you've considered Improved documentation
Additional context https://github.com/aws-amplify/docs/issues/2768
Hey @rnrnstar2, Thank you for raising this. We have a follow up question, Have you deployed your backend resources? Can you verify in AppSync console and confirm listByGetInfo query exist?
Yes, appsync has listByGetInfo.
I selected multiple sortKeys for secondaryIndexes. Then I couldn't get the list.
Post: a
.model({
name: a.string().required(),
categoryId: a.id().required(),
s3ImgKey: a.string(),
message: a.string().required(),
gender: a.string().required(),
prefecture: a.string().required(),
ageGroup: a.string().required(),
category: a.belongsTo("Category", "categoryId"),
})
.secondaryIndexes((index) => [
index("categoryId")
.sortKeys(["gender", "prefecture", "ageGroup"])
.queryField("listByCategoryId"),
]),
// @ts-ignore
const { data: posts, errors } = await client.models.Post.listByCategoryId(
{
categoryId,
gender: {
eq: gender,
},
prefecture: {
eq: prefecture,
},
}
);
indexQuery.mjs:76 Uncaught (in promise) TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
Hi @rnrnstar2 thanks for raising this issue.
This seems to be a duplicate of another issue that was opened regarding composite identifiers.
Please track this issue for updates: https://github.com/aws-amplify/amplify-category-api/issues/2526
We've patched this bug in the latest release of @aws-amplify/data-schema.
Please make sure you're using at least @aws-amplify/[email protected] and [email protected] and then run npm update @aws-amplify/data-schema to consume the patch.
This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.