-
Notifications
You must be signed in to change notification settings - Fork 573
Description
Problem
AppSyncResolverTemplate doesn't describe what is sent to Lambda resolvers (see also #150). Since it doesn't actually describe what is sent to the Lambdas, I think it should be updated to a true reflection of the passed value, or removed. It is misleading because using it as your event will make it impossible to get the proper arguments and values, and it doesn't describe the payload at all.
Solution
Interestingly, we can now send the entire object through direct to lambda resolvers by turning off the request and response mapping templates:
This seems to forward through an object that (in my opinion) is what AppSyncResolverTemplate should be.
The only problem with that is the object that is passed looks something like the following (this is an assumption given that the following JSON is provided when I select appsync-resolver as a test event for my lambda):
Expand for full JSON object
{
"arguments": {
"id": "my identifier"
},
"identity": {
"claims": {
"sub": "192879fc-a240-4bf1-ab5a-d6a00f3063f9",
"email_verified": true,
"iss": "https://cognito-idp.us-west-2.amazonaws.com/us-west-xxxxxxxxxxx",
"phone_number_verified": false,
"cognito:username": "jdoe",
"aud": "7471s60os7h0uu77i1tk27sp9n",
"event_id": "bc334ed8-a938-4474-b644-9547e304e606",
"token_use": "id",
"auth_time": 1599154213,
"phone_number": "+19999999999",
"exp": 1599157813,
"iat": 1599154213,
"email": "jdoe@email.com"
},
"defaultAuthStrategy": "ALLOW",
"groups": null,
"issuer": "https://cognito-idp.us-west-2.amazonaws.com/us-west-xxxxxxxxxxx",
"sourceIp": [
"1.1.1.1"
],
"sub": "192879fc-a240-4bf1-ab5a-d6a00f3063f9",
"username": "jdoe"
},
"source": null,
"request": {
"headers": {
"x-forwarded-for": "1.1.1.1, 2.2.2.2",
"cloudfront-viewer-country": "US",
"cloudfront-is-tablet-viewer": "false",
"via": "2.0 xxxxxxxxxxxxxxxx.cloudfront.net (CloudFront)",
"cloudfront-forwarded-proto": "https",
"origin": "https://us-west-1.console.aws.amazon.com",
"content-length": "217",
"accept-language": "en-US,en;q=0.9",
"host": "xxxxxxxxxxxxxxxx.appsync-api.us-west-1.amazonaws.com",
"x-forwarded-proto": "https",
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36",
"accept": "*/*",
"cloudfront-is-mobile-viewer": "false",
"cloudfront-is-smarttv-viewer": "false",
"accept-encoding": "gzip, deflate, br",
"referer": "https://us-west-1.console.aws.amazon.com/appsync/home?region=us-west-1",
"content-type": "application/json",
"sec-fetch-mode": "cors",
"x-amz-cf-id": "3aykhqlUwQeANU-HGY7E_guV5EkNeMMtwyOgiA==",
"x-amzn-trace-id": "Root=1-5f512f51-fac632066c5e848ae714",
"authorization": "eyJraWQiOiJScWFCSlJqYVJlM0hrSnBTUFpIcVRXazNOW...",
"sec-fetch-dest": "empty",
"x-amz-user-agent": "AWS-Console-AppSync/",
"cloudfront-is-desktop-viewer": "true",
"sec-fetch-site": "cross-site",
"x-forwarded-port": "443"
}
},
"prev": null,
"info": {
"selectionSetList": [
"id",
"field1",
"field2"
],
"selectionSetGraphQL": "{\n id\n field1\n field2\n}",
"parentTypeName": "Mutation",
"fieldName": "createSomething",
"variables": {}
},
"stash": {}
}I confirmed that this was the object by creating the following event struct to see if some of the specific fields existed:
type (
AppSyncResolverEvent struct {
Info AppSyncResolverEventInfo
Arguments AppSyncResolverEventArguments
}
AppSyncResolverEventInfo struct {
ParentTypeName string
}
AppSyncResolverEventArguments struct {
ID string
}
)I believe that this is what the definition for AppSyncResolverTemplate should be.
