1
votes

I have a JS project that uses aws services as a backend (Cognito, AppSync, S3, etc).

I use AWS Amplify to access these services but do not use the amplify CLI; all aws services are configuredd manually.

Regarding AppSync, I have a little script that reads the schema (downloaded manually from the appsync console) and then generates Typescript operations and operation types files (using amplify-graphql-docs-generator and amplify-graphql-types-generator).

Is it possible to do the same for models, ie generate a models file in typescript based on a local schema file ? Or in other words how can I replicate amplify codegen models inside a project that was not setup with the amplify-cli ?

1

1 Answers

1
votes

You can probably check the implementation of the amplify codegen and find its inner workings https://github.com/aws-amplify/amplify-cli/tree/master/packages/amplify-codegen

Or if you don't mind using the Amplify CLI, you can hook up an existing AppSync project running the following commands in sequence at the project root:

amplify init amplify add codegen --apiId xxxx amplify codegen