Ok. I got it working. I wrote a small utility function to convert schema.gql
to the appropriate JSON file.
prepSchema: () => readFile('./schema.gql', 'utf8', (e, Definition) => e
? console.error(e)
: writeFile(
'./.serverless/schema.json',
JSON.stringify({ Definition }),
'utf8',
e => console.error(e)
)
)
Then I added the it to the serverless.yml
Schema:
Type: "AWS::AppSync::GraphQLSchema"
Properties:
ApiId:
Fn::GetAtt: [ GraphQLApi, ApiId]
Definition: ${file(.serverless/schema.json):Definition}
Lastly, I added the script to my deployment workflow
{
"scripts": {
"build":"node -e 'require(\"./utils\").prepSchema()'",
"deploy": "yarn build && sls deploy"
}
}
Feedback is appreciated!