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)}

Thanks!

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!

It’s actually something very close to that

Definition: ${file(schema.gql)}