serverless-appsync-plugin icon indicating copy to clipboard operation
serverless-appsync-plugin copied to clipboard

Feature request: Inline Lambda data sources within mappingTemplates

Open paulswail opened this issue 2 years ago • 3 comments

Hooking up Lambda functions as resolvers currently feels quite verbose and disconnected: first define the function in standard functions section, then add an item to the plugin's mappingTemplates section and then also define a separate data source. If you're using single-responsibility Lambda functions, the configuration file really grows.

Ideally it would be great if an appsync event could be defined in the standard functions.functionName.events array in serverless.yml so that the function and the resolver that triggers it are configured in the same place. However, I guess this may not be easy to hook into for a plugin, so instead would it even be possible to inline the data source within the mappingTemplates section rather than having to define it separately? I'm thinking of something like this:

mappingTemplates:
  - type: Mutation
     field: updateProfile
     dataSource:
       type: AWS_LAMBDA
       functionName: updateProfile

paulswail avatar Mar 22 '22 09:03 paulswail

Keep an eye on v2 :)

https://github.com/sid88in/serverless-appsync-plugin/blob/v2/doc/resolvers.md#inline-datasources

bboure avatar Mar 22 '22 10:03 bboure

Beautiful! 😃 Thank you @bboure I know you mightn't be able to say, but do you have a rough idea of when v2 will be ready?

paulswail avatar Mar 22 '22 12:03 paulswail

I'm expecting to launch an alpha soon (in a few weeks at most).

I'm a bit busy with client work right now :)

bboure avatar Mar 22 '22 14:03 bboure