File tree 2 files changed +32
-1
lines changed
aws_lambda_powertools/utilities/data_classes/appsync
2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,38 @@ def aws_timestamp():
37
37
38
38
39
39
class AppSyncResolver :
40
- """AppSync resolver decorator utility"""
40
+ """
41
+ AppSync resolver decorator utility
42
+
43
+ Example
44
+ -------
45
+ **Sample usage**
46
+
47
+ from aws_lambda_powertools.utilities.data_classes import AppSyncResolverEvent
48
+ from aws_lambda_powertools.utilities.data_classes.appsync.resolver_utils import AppSyncResolver
49
+
50
+ app = AppSyncResolver()
51
+
52
+
53
+ @app.resolver(type_name="Query", field_name="listLocations", include_event=True)
54
+ def list_locations(event: AppSyncResolverEvent, page: int = 0, size: int = 10):
55
+ # Your logic to fetch locations
56
+
57
+
58
+ @app.resolver(type_name="Merchant", field_name="extraInfo", include_event=True)
59
+ def get_extra_info(event: AppSyncResolverEvent):
60
+ # Can use `event.source` to filter within the parent context
61
+
62
+
63
+ @app.resolver(field_name="commonField")
64
+ def common_field():
65
+ # Would match all fieldNames matching `commonField`
66
+
67
+
68
+ def handle(event, context):
69
+ app.resolve(event, context)
70
+
71
+ """
41
72
42
73
def __init__ (self ):
43
74
self ._resolvers : dict = {}
You can’t perform that action at this time.
0 commit comments