I'm using this AppSync resolver mapping template to update a user:
{
"version": "2018-05-29",
"method": "PATCH",
"params": {
"headers": {
"Content-Type": "application/json"
},
"body": $utils.toJson(${context.arguments.input})
},
"resourcePath": $utils.toJson("/users/${context.arguments.input.id}")
}
The service in the backend accept a PATCH
request to update the user.
When I run the mutation I get this error: An internal failure occurred while resolving this field.
This are the CloudWatch logs for the Request Mapping and Response Mapping:
{
"logType": "RequestMapping",
"path": [
"updateUser"
],
"fieldName": "updateUser",
"resolverArn": "arn:aws:appsync:us-east-1:xxxxxx:apis/xxxxx/types/Mutation/resolvers/updateUser",
"requestId": "xxxxxx",
"context": {
"arguments": {
"input": {
"id": "user1",
"firstName": "John"
}
},
"stash": {},
"outErrors": []
},
"fieldInError": false,
"errors": [],
"parentType": "Mutation",
"graphQLAPIId": "xxxxxx",
"transformedTemplate": "{\n \"version\": \"2018-05-29\",\n \"method\": \"PATCH\",\n \"params\": {\n \"headers\": {\n \"Content-Type\": \"application/json\"\n },\n \"body\": {\"id\":\"user1\",\"firstName\":\"John\"}\n },\n \"resourcePath\": \"/users/user1\"\n}"
}
{
"logType": "ResponseMapping",
"path": [
"updateUser"
],
"fieldName": "updateUser",
"resolverArn": "arn:aws:appsync:us-east-1:xxxxx:apis/xxxxx/types/Mutation/resolvers/updateUser",
"requestId": "xxxxxx",
"context": {
"arguments": {
"input": {
"id": "user1",
"firstName": "John"
}
},
"stash": {},
"error": {
"message": "An internal failure occurred while resolving this field.",
"type": "InternalFailure"
},
"outErrors": []
},
"fieldInError": true,
"errors": [
"CustomTemplateException(message=A custom error was thrown from a mapping template., errorType=$context.result.statusCode, data=null, errorInfo=null)"
],
"parentType": "Mutation",
"graphQLAPIId": "xxxxxx"
}
The request is not forwarded to the backend service (I'm monitoring incoming requests), however if I change the method in the mapping to POST
or PUT
I can see the request arriving to the service.
I have other requests that require a PATCH
method and they have the same issue.
Am I missing something in the resolver for PATCH
requests or this is an AppSync bug?