Loading AppSync schema file into serverless.yml (SOLVED)

Hello Everyone,

I’d like to pipe in a schema like seen here:

However, I’m getting the following error:

The CloudFormation template is invalid: Invalid template property or properties [Schema]

Ideally I’d like something like:

Definition: | ${file(schema.gql)}


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(
        JSON.stringify({ Definition }),
        e => console.error(e)

Then I added the it to the serverless.yml

      Type: "AWS::AppSync::GraphQLSchema"
          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!

It’s actually something very close to that

Definition: ${file(schema.gql)}