-
Notifications
You must be signed in to change notification settings - Fork 402
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
feat(event-handler): add appsync batch resolvers #1998
feat(event-handler): add appsync batch resolvers #1998
Conversation
1ceecf7
to
ccdbbea
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1998 +/- ##
===========================================
+ Coverage 96.38% 96.45% +0.07%
===========================================
Files 214 223 +9
Lines 10030 10723 +693
Branches 1846 1995 +149
===========================================
+ Hits 9667 10343 +676
- Misses 259 268 +9
- Partials 104 112 +8 ☔ View full report in Codecov by Sentry. |
ccdbbea
to
d0fe867
Compare
72dc94f
to
524d054
Compare
524d054
to
bc45703
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for the change, that's much better! Made one comment about favouring composition instead of multiple inheritance (it'll bite us!).
One super helpful change would be to update PR description with a sample UX, so that customers could easily spot what's coming, we could reuse in our docs, and release notes :-)
I'll do a proper review next week
efcb664
to
5668cba
Compare
tests/functional/event_handler/required_dependencies/appsync/test_appsync_batch_resolvers.py
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a few changes in GIVEN/WHEN/THEN and usage of response[0]
.
I'll run the docs locally this afternoon for a proper review!
…other subsections
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOW IT IS COMPLETED! SHIP!
stateDiagram-v2
direction LR
LambdaInit: Lambda invocation
EventHandler: Event Handler
EventHandlerResolver: Route event based on GraphQL type/field keys
Client: Client query (listPosts)
YourLogic: Run your registered resolver function
EventHandlerResolverBuilder: Verifies response is a list
AppSyncBatchPostsResolution: query listPosts
AppSyncBatchPostsItems: get all posts data <em>(id, title, relatedPosts)</em>
AppSyncBatchRelatedPosts: get related posts <em>(id, title, relatedPosts)</em>
AppSyncBatchAggregate: aggregate batch resolver event
AppSyncBatchLimit: reached batch size limit
LambdaResponse: Lambda response
Client --> AppSyncBatchResolverMode
state AppSyncBatchResolverMode {
[*] --> AppSyncBatchPostsResolution
AppSyncBatchPostsResolution --> AppSyncBatchPostsItems
AppSyncBatchPostsItems --> AppSyncBatchRelatedPosts: <strong>N additional queries</strong>
AppSyncBatchRelatedPosts --> AppSyncBatchRelatedPosts
AppSyncBatchRelatedPosts --> AppSyncBatchAggregate
AppSyncBatchRelatedPosts --> AppSyncBatchAggregate
AppSyncBatchRelatedPosts --> AppSyncBatchAggregate
AppSyncBatchAggregate --> AppSyncBatchLimit
}
AppSyncBatchResolverMode --> LambdaInit: 1x Invoke with N events
LambdaInit --> EventHandler
state EventHandler {
[*] --> EventHandlerResolver: app.resolve(event, context)
EventHandlerResolver --> YourLogic
YourLogic --> EventHandlerResolverBuilder
EventHandlerResolverBuilder --> LambdaResponse
}
* develop: chore(ci): changelog rebuild (aws-powertools#4631) chore(deps-dev): bump mypy-boto3-ssm from 1.34.91 to 1.34.132 in the boto-typing group (aws-powertools#4623) chore(ci): new pre-release 2.39.2a4 (aws-powertools#4629) chore(deps-dev): bump cfn-lint from 1.3.3 to 1.3.5 (aws-powertools#4628) chore(deps-dev): bump filelock from 3.15.3 to 3.15.4 (aws-powertools#4626) chore(deps-dev): bump mypy from 1.10.0 to 1.10.1 (aws-powertools#4624) chore(deps-dev): bump cdklabs-generative-ai-cdk-constructs from 0.1.194 to 0.1.198 (aws-powertools#4627) Signed-off-by: heitorlessa <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
APPROVED @heitorlessa! ❤️
Issue Number: #1303
Summary
Support Appsync batching mechanism for Lambda Resolvers
Changes
User experience
If batch processing is used for specific method, user can access AppSyncResolver events directly in their annotated method and do appropriate processing. Appsync resolver calls method for every event from the coming list of events.
Processing Batch items individually
Processing Batch items at once
Under the hood, Router:
batch_resolver
.type_name
andfield_name
and calls it for every event in the list. It passes the event itself to it as parameter argument. Optionally it pass user specified parameters if they are present - they are taken from the inside of the event itself. We pass user specified parameters to keep similar UX as with baseresolver
.Checklist
If your change doesn't seem to apply, please leave them unchecked.
Is this a breaking change?
RFC issue number:
Checklist:
Acknowledgment
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.