serverless-appsync-plugin
serverless-appsync-plugin copied to clipboard
Can't separate appsync into different file
Hey there,
I started playing around with version 2.2.1
of this plugin, and I encountered an error with it being unable to pick up authorization (unsure about other fields) when I separate the appsync config into its own file like so:
appSync:
- ${file(serverless.appsync-api.yml )}
I specifically get an error saying that Can't read 'type' of undefined
where it references this line (99):
if (config.authentication.type === 'API_KEY' ||
additionalAuthentications.some(function (auth) { return auth.type === 'API_KEY'; })) {
underneath the function/file getAppSyncConfig
.
Hi @willa75
Right now, you can't do this
appSync:
- ${file(serverless.appsync-api.yml )}
appSync
must be an object. What you're doing is the equivalent of passing an array.
This explains why config.authentication
is undefined (it would have to be be config[0].authentication.type
)
I guess what you're trying to do might make sense and allowing it would help structure the different parts of the config.
i.e.: when appSync
is an array, we could flatten/deep merge the passed objects.
I'd be happy to receive a PR if that's something you'd like to help with.
Hey @bboure
Thanks for getting back so quick, and that is understandable! I think I would like to take a shot at this change, though I will take me a bit to learn the basics of serverless framework plugin building. Will comment here when I have a working version of it