Feature request: support BatchInvoke when using AppSyncResolver
See original GitHub issueUse case
Currently, an event is expected to be of type Dict[str,Any]
. When using ‘BatchInvoke’ in a direct lambda resolver, the event becomes type List[Dict[str,Any]]
. Hence, it is not possible to route the event to the expected resolver.
A use case is given by the official dev guide. Without the ability to use ‘BatchInvoke’ users will run into n + 1 problems, when using appsync-GraphQl.
Solution/User Experience
I am not 100% sure how a good solution would look like. Maybe it would be possible to use the AppSyncResolverEvent
to handle one individual event, or a list of events.
Given the described use case, the events should usually only diverge in the source.
Alternative solutions
No response
Acknowledgment
- This feature request meets Lambda Powertools Tenets
- Should this be considered in other Lambda Powertools languages? i.e. Java, TypeScript
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Resolver mapping template reference for Lambda
BatchInvoke instructs AWS AppSync to batch requests for the current GraphQL field. operation is required. For Invoke , the resolved request mapping template ......
Read more >The Benefits of Implementing Pre-Resolver Caching - Aircall
If you're using BatchInvoke , you should disable it and support both BatchInvoke and the unit one during your next rollout.
Read more >Serverless Appsync Plugin
Deploy AppSync API's in minutes using this Serverless plugin. ... maxBatchSize: # maximum number of requests for BatchInvoke operations.
Read more >GraphQL API - AWS Lambda Powertools for Python
A custom AppSync Resolver to bypass the use of Apache Velocity Template ... typing import List import requests from requests import Response ...
Read more >Newest 'aws-appsync-resolver' Questions - Stack Overflow
I'm trying to mutate an object with the help of AppSync console. when i execute my query it executes without any error but...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Sure, I can construct an example. Assume the following GraphQl-Schema:
The resolvers are attached as follows:
ParentTypeName: Query
andFieldName: getProducts
ParentTypeName: Product
andFieldName: comments
When using the usual Invoke, Appsync creates one event for the
Query
:and for every product, an additional event and lambda invocation for the comments:
Hence, for every
Product
an additional lambda invoke is executed.When using “BatchInvoke”, the first event remains the same, but the calls that return the comments for each product are “merged” into one lambda call with a list of events.
Appsync now expects a list of responses associated with the corresponding sources. The fields of the events depend on the
ResponseMappingTemplate
used for the resolver.@heitorlessa I hope this helps a bit.
Work Around
Currently, I work around this issue using the following
AppSyncResolverEvent
:I must admit that this is not clean, but for now it works.
+1 We had to build to a similar class as created by @cponfick-bhs