Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't separate appsync into different file #606

Open
willa75 opened this issue Jun 25, 2023 · 2 comments
Open

Can't separate appsync into different file #606

willa75 opened this issue Jun 25, 2023 · 2 comments

Comments

@willa75
Copy link

willa75 commented Jun 25, 2023

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.

@bboure
Copy link
Collaborator

bboure commented Jun 26, 2023

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.

@willa75
Copy link
Author

willa75 commented Jun 26, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants