Skip to content

Commit bc6cd12

Browse files
committed
docs: fix highlights, add missing code annotation
1 parent 8f3af70 commit bc6cd12

File tree

3 files changed

+20
-70
lines changed

3 files changed

+20
-70
lines changed

docs/core/event_handler/appsync.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -379,16 +379,16 @@ In this mode, you must return results in the same order of your batch items, so
379379
2. We use `post_id` as our unique identifier of the GraphQL request.
380380

381381
=== "getting_started_with_batch_resolver_payload.json"
382-
```json hl_lines="4 16 21 29 41 46"
382+
```json hl_lines="6 16 25 35 44 54"
383383
--8<-- "examples/event_handler_graphql/src/getting_started_with_batch_resolver_payload.json"
384384
```
385385

386386
=== "getting_started_with_batch_query.graphql"
387-
```typescript hl_lines="4 16 21 29 41 46"
387+
```typescript hl_lines="3 6"
388388
--8<-- "examples/event_handler_graphql/src/getting_started_with_batch_query.graphql"
389389
```
390390

391-
#### Processing items individually
391+
##### Processing items individually
392392

393393
```mermaid
394394
stateDiagram-v2
@@ -446,20 +446,20 @@ In this mode, we will:
446446
* You can customize `nul` or error responses back to the client in the [AppSync resolver mapping templates](https://docs.aws.amazon.com/appsync/latest/devguide/tutorial-lambda-resolvers.html#returning-individual-errors){target="_blank"}
447447

448448
=== "getting_started_with_batch_resolver_individual.py"
449-
```python hl_lines="3 7 17"
449+
```python hl_lines="5 9 19"
450450
--8<-- "examples/event_handler_graphql/src/getting_started_with_batch_resolver_individual.py"
451451
```
452452

453453
1. You need to disable the aggregated event by using `aggregate` flag.
454454
The resolver receives and processes each record one at a time.
455455

456456
=== "getting_started_with_batch_resolver_payload.json"
457-
```json hl_lines="4 16 21 29 41 46"
457+
```json hl_lines="6 16 25 35 44 54"
458458
--8<-- "examples/event_handler_graphql/src/getting_started_with_batch_resolver_payload.json"
459459
```
460460

461461
=== "getting_started_with_batch_query.graphql"
462-
```typescript hl_lines="4 16 21 29 41 46"
462+
```typescript hl_lines="3 6"
463463
--8<-- "examples/event_handler_graphql/src/getting_started_with_batch_query.graphql"
464464
```
465465

@@ -520,38 +520,40 @@ You can toggle `raise_on_error` parameter in `@batch_resolver` to propagate any
520520
This is useful when you want to stop processing immediately in the event of an unhandled or unrecoverable exception.
521521

522522
=== "getting_started_with_batch_resolver_handling_error.py"
523-
```python hl_lines="3 7 17"
523+
```python hl_lines="5 9 19"
524524
--8<-- "examples/event_handler_graphql/src/getting_started_with_batch_resolver_handling_error.py"
525525
```
526526

527527
1. You can enable enable the error handling by using `raise_on_error` flag.
528528

529529
=== "getting_started_with_batch_resolver_payload.json"
530-
```json hl_lines="4 16 21 29 41 46"
530+
```json hl_lines="6 16 25 35 44 54"
531531
--8<-- "examples/event_handler_graphql/src/getting_started_with_batch_resolver_payload.json"
532532
```
533533

534534
=== "getting_started_with_batch_query.graphql"
535-
```typescript hl_lines="4 16 21 29 41 46"
535+
```typescript hl_lines="3 6"
536536
--8<-- "examples/event_handler_graphql/src/getting_started_with_batch_query.graphql"
537537
```
538538

539-
#### Async
539+
#### Async batch resolver
540540

541541
Similar to `@batch_resolver` explained in [batch resolvers](#batch-resolvers), you can use `async_batch_resolver` to handle async functions.
542542

543543
=== "getting_started_with_batch_async_resolver.py"
544-
```python hl_lines="3 7 17"
544+
```python hl_lines="5 9 23"
545545
--8<-- "examples/event_handler_graphql/src/getting_started_with_batch_async_resolver.py"
546546
```
547547

548-
=== "getting_started_with_batch_async_resolver_payload.json"
549-
```json hl_lines="4 16 21 29 41 46"
550-
--8<-- "examples/event_handler_graphql/src/getting_started_with_batch_async_resolver_payload.json"
548+
1. `async_batch_resolver` takes care of running and waiting for coroutine completion.
549+
550+
=== "getting_started_with_batch_resolver_payload.json"
551+
```json hl_lines="6 16 25 35 44 54"
552+
--8<-- "examples/event_handler_graphql/src/getting_started_with_batch_resolver_payload.json"
551553
```
552554

553555
=== "getting_started_with_batch_query.graphql"
554-
```typescript hl_lines="4 16 21 29 41 46"
556+
```typescript hl_lines="3 6"
555557
--8<-- "examples/event_handler_graphql/src/getting_started_with_batch_query.graphql"
556558
```
557559

examples/event_handler_graphql/src/getting_started_with_batch_async_resolver.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ async def search_batch_posts(posts: list) -> dict[str, Any]:
2121

2222

2323
@app.async_batch_resolver(type_name="Query", field_name="relatedPosts")
24-
async def related_posts(event: list[AppSyncResolverEvent]) -> list[Any]: # (1)!
24+
async def related_posts(event: list[AppSyncResolverEvent]) -> list[Any]:
2525
# Extract all post_ids in order
26-
post_ids: list = [record.source.get("post_id") for record in event] # (2)!
26+
post_ids: list = [record.source.get("post_id") for record in event]
2727

2828
# Get unique post_ids while preserving order
2929
unique_post_ids = list(dict.fromkeys(post_ids))
@@ -36,4 +36,4 @@ async def related_posts(event: list[AppSyncResolverEvent]) -> list[Any]: # (1)!
3636

3737

3838
def lambda_handler(event, context: LambdaContext) -> dict:
39-
return app.resolve(event, context)
39+
return app.resolve(event, context) # (1)!

examples/event_handler_graphql/src/getting_started_with_batch_async_resolver_payload.json

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)