Skip to content

Commit

Permalink
docs(data-classes): Added sample usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Brewer committed Mar 12, 2021
1 parent 9315f81 commit 8ba4495
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
Expand Up @@ -37,7 +37,38 @@ def aws_timestamp():


class AppSyncResolver:
"""AppSync resolver decorator utility"""
"""
AppSync resolver decorator utility
Example
-------
**Sample usage**
from aws_lambda_powertools.utilities.data_classes import AppSyncResolverEvent
from aws_lambda_powertools.utilities.data_classes.appsync.resolver_utils import AppSyncResolver
app = AppSyncResolver()
@app.resolver(type_name="Query", field_name="listLocations", include_event=True)
def list_locations(event: AppSyncResolverEvent, page: int = 0, size: int = 10):
# Your logic to fetch locations
@app.resolver(type_name="Merchant", field_name="extraInfo", include_event=True)
def get_extra_info(event: AppSyncResolverEvent):
# Can use `event.source` to filter within the parent context
@app.resolver(field_name="commonField")
def common_field():
# Would match all fieldNames matching `commonField`
def handle(event, context):
app.resolve(event, context)
"""

def __init__(self):
self._resolvers: dict = {}
Expand Down
Empty file added examples/__init__.py
Empty file.

0 comments on commit 8ba4495

Please sign in to comment.