aws / aws/aws-appsync-community
Unit testing of resolvers: only LambdaAuthIdentity supported for context, we need Cognito support
- Dominant language
- HTML
- Stars
- 507
- Forks
- 37
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I want to unit test my resolvers but when I provide a context object with an identity object that is formed according to cognito userpool authentication, I get the following error:
```
{
'$metadata': {
httpStatusCode: 200,
requestId: 'd699c6c6-9a8e-4dc2-8bd7-70c98203e4d1',
extendedRequestId: undefined,
cfId: 'r-mlNekQJDDZrWKFs0byMvdNYSl2PBMUbkWSvKh7cvVgIDbJAj54iA==',
attempts: 1,
totalRetryDelay: 0
},
error: {
message: 'Unrecognized field "sub" (class com.amazonaws.deepdish.common.identity.LambdaAuthIdentity), not marked as ignorable (one known property: "resolverContext"])\n' +
' at [Source: UNKNOWN; line: -1, column: -1] (through reference chain: com.amazonaws.deepdish.transform.model.MappingTemplateContext$MappingTemplateContextBuilder["identity"]->com.amazonaws.deepdish.common.identity.LambdaAuthIdentity["sub"])'
}
}
```
Contributor guide
Research direction
Start by tracing the resolver unit-testing context handling and the MappingTemplateContext and LambdaAuthIdentity classes named in the error. Compare the provided Cognito user-pool identity shape with the currently accepted identity shape; done means a resolver context containing Cognito identity can be used in unit tests without the unrecognized-field error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, graphql
- Domain
- api, authentication, backend, testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100