Description
Key information
- RFC PR: feat(data-classes): AppSync Resolver Event #323
- Related issue(s), if known:
- Area: Utilities
- Meet tenets: Yes
Summary
One paragraph explanation of the feature.
Motivation
Why are we doing this? What use cases does it support? What is the expected outcome?
Make it easier to map multiple AppSync resolvers to a single lambda. Also to have a collection of useful utility functions.
Proposal
Something like : https://github.com/twkiiim/sleemo
from aws_lambda_powertools import Logger
from aws_lambda_powertools.utilities.data_classes import AppSyncResolverEvent
from aws_lambda_powertools.utilities.data_classes.appsync_resolver_utils import (
AppSyncResolver,
make_id,
aws_date,
aws_datetime,
aws_time,
aws_timestamp,
)
logger = Logger()
app = AppSyncResolver()
@app.resolver(field_name="locations", include_event=True, include_context: True)
def get_locations(event: AppSyncResolverEvent, context: LambdaContext, name: str = None):
logger.info(event)
return f"returning locations for {name}"
@app.resolver(type_name="Merchant", field_name="anotherField")
def another_field_resolver(count: int):
return {
"id": make_id(),
"date": aws_date(),
"date_time": aws_datetime(),
"time": aws_time(),
"ts": aws_timestamp(),
"message": f"another_field_resolver with parameter count={count}",
}
@app.resolver(type_name="Query", field_name="noParams")
def no_params():
return "no_params has no params"
def handler(event: dict, context):
return app.resolve(event, context)
This is the bulk of the RFC.
Explain the design in enough detail for somebody familiar with Powertools to understand it, and for somebody familiar with the implementation to implement it.
This should get into specifics and corner-cases, and include examples of how the feature is used. Any new terminology should be defined here.
Drawbacks
Why should we not do this?
Do we need additional dependencies? Impact performance/package size?
Rationale and alternatives
- What other designs have been considered? Why not them?
- What is the impact of not doing this?
Unresolved questions
Optional, stash area for topics that need further development e.g. TBD
Metadata
Metadata
Assignees
Type
Projects
Status