# Loading AppSync schema file into serverless.yml (SOLVED)

**URL:** <https://forum.serverless.com/t/loading-appsync-schema-file-into-serverless-yml-solved/4482>\
**Category:** Serverless Framework\
**Created:** [May 11, 2018, 10:33pm UTC](https://forum.serverless.com/t/loading-appsync-schema-file-into-serverless-yml-solved/4482 "2018-05-11T22:33:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wordyallen](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/wordyallen/32/1020_2.png) [@wordyallen](https://forum.serverless.com/u/wordyallen)\
**Post date:** [May 11, 2018, 10:33pm UTC](https://forum.serverless.com/t/loading-appsync-schema-file-into-serverless-yml-solved/4482/1 "2018-05-11T22:33:33Z")

</div>

Hello Everyone,

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

> <https://gist.github.com/adrianhall/293d2ad4dc5e9e8588b651c1fa1e946e#file-appsyncapi-yaml-L16>

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!

---

<div class="post-metadata">

**Author:** ![wordyallen](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/wordyallen/32/1020_2.png) [@wordyallen](https://forum.serverless.com/u/wordyallen)\
**Post date:** [May 12, 2018, 2:27pm UTC](https://forum.serverless.com/t/loading-appsync-schema-file-into-serverless-yml-solved/4482/2 "2018-05-12T14:27:03Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![buggy](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/buggy/32/177_2.png) [@buggy](https://forum.serverless.com/u/buggy)\
**Post date:** [May 15, 2018, 12:27am UTC](https://forum.serverless.com/t/loading-appsync-schema-file-into-serverless-yml-solved/4482/3 "2018-05-15T00:27:03Z")

</div>

> [@wordyallen](#):
>
> Ideally I’d like something like:
> 
> `Definition: | ${file(schema.gql)}`

It’s actually something very close to that

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