You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/core/event_handler/appsync_events.md
+124-6
Original file line number
Diff line number
Diff line change
@@ -65,7 +65,7 @@ You must have an existing AppSync Events API with real-time capabilities enabled
65
65
66
66
### AppSync request and response format
67
67
68
-
AppSync Events uses a specific event format for Lambda requests and responses. In most scenarios, Powertools simplifies this interaction by automatically formatting resolver returns to match the expected AppSync response structure.
68
+
AppSync Events uses a specific event format for Lambda requests and responses. In most scenarios, Powertools for AWS simplifies this interaction by automatically formatting resolver returns to match the expected AppSync response structure.
69
69
70
70
=== "payload_request.json"
71
71
@@ -95,7 +95,7 @@ AppSync Events uses a specific event format for Lambda requests and responses. I
95
95
96
96
When processing events with Lambda, you can return errors to AppSync in three ways:
97
97
98
-
***Error per item:** Return an `error` key within each individual item's response. AppSync Events expects this format for item-specific errors.
98
+
***Item specific error:** Return an `error` key within each individual item's response. AppSync Events expects this format for item-specific errors.
99
99
***Fail entire request:** Return a JSON object with a top-level `error` key. This signals a general failure, and AppSync treats the entire request as unsuccessful.
100
100
***Unauthorized exception**: Raise the **UnauthorizedException** exception to reject a subscribe or publish request with HTTP 403.
101
101
@@ -124,7 +124,7 @@ You can define your handlers for different event types using the `app.on_publish
124
124
125
125
You can use wildcard patterns to create catch-all handlers for multiple channels or namespaces. This is particularly useful for centralizing logic that applies to multiple channels.
126
126
127
-
When multiple handlers could match the same event, the most specific pattern takes precedence.
127
+
When an event matches with multiple handlers, the most specific pattern takes precedence.
128
128
129
129
=== "working_with_wildcard_resolvers.py"
130
130
@@ -197,11 +197,28 @@ When processing batch of items with `aggregate=True`, you must format the payloa
If instead you want to fail the entire batch, you can throw an exception. This will cause the Event Handler to return an error response to AppSync and fail the entire batch.
201
201
202
-
??? warning "Raising `UnauthorizedException` will cause the Lambda invocation to fail."
You can also reject the entire payload by raising an `UnauthorizedException`. This prevents Powertools from processing any messages and causes the Lambda invocation to fail, returning an error to AppSync.
216
+
!!! warning "Raising `UnauthorizedException` will cause the Lambda invocation to fail."
217
+
218
+
You can also do content based authorization for channel by raising the `UnauthorizedException` exception. This can cause two situations:
219
+
220
+
-**When working with publish events** Powertools for AWS stop processing messages and subscribers will not receive any message.
221
+
-**When working with subscribe events** the subscription won't be established.
205
222
206
223
=== "working_with_error_handling.py"
207
224
@@ -240,6 +257,107 @@ You can access to the original Lambda event or context for additional informatio
0 commit comments