Skip to content

Instantly share code, notes, and snippets.

@hisham
hisham / modifyAmplifyCF.js
Created February 28, 2020 17:59
Modify Amplify CLI Generated Cloudformation File to Support a GraphQL Interface
/**
* Example script to change amplify cli-generated cloudformation stack to support a graphql interface. See https://github.com/aws-amplify/amplify-cli/issues/202.
* Run this before every amplify push command (e.g. create your own bash script that does something like: amplify api gql-compile && node ./scripts/modifyAmplifyCF.js && ./amplify/backend/api/<your_app_name>/build/cloudformtion-template.json && amplify push --no-gql-override)
* Everytime you run amplify api gql-compile, the cloudformation files will be overwritten and this script would need to be run again.
*
* As an example for this script, it assumes you have a custom User table built (through custom stacks - User.json for the AppSync resolvers and UserTable.json for the dynamodb table) and a Doctor and Patient model that implement this interface, e.g.
*
* interface User {
* id: ID!
*. email: AWSEmail!