amplify-category-api icon indicating copy to clipboard operation
amplify-category-api copied to clipboard

Referencing Enums Directly from GraphQL Client

Open MattWlodarski opened this issue 9 months ago • 1 comments

Describe the feature you'd like to request

We need a way to directly reference an enum we created in our schema in our frontend app code. Currently, I have been running: npx ampx generate graphql-client-code and putting the resulting API.ts file in a shared folder and then importing the desired enum from there, but it would be nice to be able to import the enum directly from graphQLClient like we do with mutations and queries.

Describe the solution you'd like

Currently, you can import the schema like so: import type { Schema } from '../amplify/data/resource';

so the simplest solution would be something like this: import enum { someEnumName } from '../amplify/data/resource';

Describe alternatives you've considered

I have been running: npx ampx generate graphql-client-code and putting the resulting API.ts file in a shared folder and then importing the desired enum from there, but this is a bit clunky since you have to regenerate this file whenever you make a change to your schema.

Additional context

No response

Is this something that you'd be interested in working on?

  • [ ] 👋 I may be able to implement this feature request

Would this feature include a breaking change?

  • [ ] ⚠️ This feature might incur a breaking change

MattWlodarski avatar Jan 06 '25 13:01 MattWlodarski