aws-amplify / amplify-codegen

Amplify Codegen is a JavaScript toolkit library for frontend and mobile developers building Amplify applications.
Apache License 2.0
59 stars 59 forks source link

Unable to generate operations.graphql #838

Closed charlieforward9 closed 4 months ago

charlieforward9 commented 5 months ago

Before opening, please confirm:

How did you install the Amplify CLI?

npm

If applicable, what version of Node.js are you using?

20.9.0

Amplify CLI Version

12.11.1

What operating system are you using?

Mac

Amplify Codegen Command

other codegen <subcommand> (please mention in the issue)

Describe the bug

I would like to efficiently generate RTK Query hooks for my Amplify application using this tool.

I have not been able to figure out how to generate the code that belongs in the operations.graphql input. In other word, the files that are generated with amplify codegen statements but without the Typescript wrapped around.

Screenshot 2024-05-06 at 11 20 39 PM

Maybe I am missing a simple command, but if not it would be really helpful to have this as a codegen statement...

Expected behavior

Screenshot 2024-05-06 at 11 56 26 PM

The output I expect is the useGetAccountQuery, but properly typed with the queries definition found in graphql/queries.ts, but without the typescript wrapping it.

Screenshot 2024-05-06 at 11 25 31 PM

I would like to have an option to access these statements in their graphql syntax within my codebase via this codegen package.

Reproduction steps

  1. Install this lib
  2. Try to get a single graphql file with all of the operations the schema offers.
dpilch commented 4 months ago

Changing your codeGenTarget to graphql in .graphqlconfig.yml will generate the GraphQL statements in raw GraphQL syntax.

projects:
  Codegen Project:
    extensions:
      amplify:
        codeGenTarget: graphql
charlieforward9 commented 4 months ago

Thank you - this solved my problem.

This would be nice to have as a CLI config, or specified somewhere in docs.

Maybe I missed it. Thank you.

github-actions[bot] commented 4 months ago

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.

charlieforward9 commented 4 months ago

@dpilch Is there a plan to support this with amplify mock api?

dpilch commented 4 months ago

That is not prioritized at this time.