File tree 2 files changed +12
-3
lines changed
examples/event_handler_graphql/src
2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ You can nest `app.resolver()` decorator multiple times when resolving fields wit
108
108
109
109
=== "nested_mappings.py"
110
110
111
- ```python hl_lines="2 8 11-12 14 21 "
111
+ ```python hl_lines="2 8 18-19 21 28 "
112
112
--8<-- "examples/event_handler_graphql/src/nested_mappings.py"
113
113
```
114
114
Original file line number Diff line number Diff line change
1
+ from typing import TypedDict
2
+
1
3
from aws_lambda_powertools import Logger , Tracer
2
4
from aws_lambda_powertools .event_handler import AppSyncResolver
3
5
from aws_lambda_powertools .logging import correlation_paths
8
10
app = AppSyncResolver ()
9
11
10
12
13
+ class Location (TypedDict ):
14
+ id : str # noqa AA03 VNE003, required due to GraphQL Schema
15
+ name : str
16
+ description : str
17
+ address : str
18
+
19
+
11
20
@app .resolver (field_name = "listLocations" )
12
21
@app .resolver (field_name = "locations" )
13
22
@tracer .capture_method
14
- def get_locations (name : str , description : str = "" ): # match GraphQL Query arguments
15
- return name + description
23
+ def get_locations (name : str , description : str = "" ) -> list [ Location ] : # match GraphQL Query arguments
24
+ return [{ " name" : name , " description" : description }]
16
25
17
26
18
27
@logger .inject_lambda_context (correlation_id_path = correlation_paths .APPSYNC_RESOLVER )
You can’t perform that action at this time.
0 commit comments