generated from amazon-archives/__template_MIT-0
-
Notifications
You must be signed in to change notification settings - Fork 455
Closed
Copy link
Labels
bugSomething isn't workingSomething isn't workinghelp wantedCould use a second pair of eyes/handsCould use a second pair of eyes/hands
Description
Expected Behaviour
When accessing the router.context in a resolver, with async resolvers, it should not be an empty dict, but much rather expose the context injected with app.append_context
Current Behaviour
When using router.context in async resolvers, the router.context is an empty dict
Code snippet
def lambda_handler(event, context):
token = extract_auth_token_from_event(event)
logger.info("token", extra={"token": token})
app.append_context(
isAdmin=True,
)
result = app.resolve(event, context)
return asyncio.run(result)
@router.resolver(type_name="Mutation", field_name="addPet")
async def addPet(pet: dict):
logger.info("Handling add pet mutation")
logger.info("Context", extra={"resolver_context": router.context}) // this shows that router.context is an empty dict.
return { "name": "Peter", "type": "Cat" }
Possible Solution
No response
Steps to Reproduce
Just plug in the lambda_handler and mutation I attached above, deploy it and run the mutation via the AppSync console
Powertools for AWS Lambda (Python) version
latest
AWS Lambda function runtime
3.8
Packaging format used
Lambda Layers
Debugging logs
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinghelp wantedCould use a second pair of eyes/handsCould use a second pair of eyes/hands
Type
Projects
Status
Shipped