amplify-codegen icon indicating copy to clipboard operation
amplify-codegen copied to clipboard

API: Improve AppSync codegen step

Open diegocstn opened this issue 4 years ago • 0 comments
trafficstars

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

diegocstn avatar Mar 24 '21 23:03 diegocstn

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?

AnilMaktala avatar Apr 19 '24 18:04 AnilMaktala

Yes, appsync has listByGetInfo.

スクリーンショット 2024-04-22 12 10 43

rnrnstar2 avatar Apr 22 '24 03:04 rnrnstar2

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>)

rnrnstar2 avatar Apr 30 '24 04:04 rnrnstar2

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

chrisbonifacio avatar May 07 '24 18:05 chrisbonifacio

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.

iartemiev avatar May 14 '24 11:05 iartemiev

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.

github-actions[bot] avatar May 14 '24 11:05 github-actions[bot]