graphql – Logging error when function fails in AWS Appsync
I was trying to understand where in stash are errors stored when a function fails in AppSync.
My resolver template looks like follows:
export function request(ctx) {
// performs some operation
return {}
}
export function response(ctx) {
const { error, result } = ctx;
if (error) {
return util.appendError(error.message, error.type, result);
}
return ctx.prev.result;
}
and the function looks like this:
export function request(ctx) {
const { input, keys } = ctx.stash;
return {
operation: 'PutItem',
key: util.dynamodb.toMapValues(keys),
attributeValues: util.dynamodb.toMapValues(input)
};
}
export function response(ctx) {
const { error, result } = ctx;
if (error) { // (ctx.outError) ?
console.log("I want to log this error");
}
return util.appendError(error.message, error.type, result);
}
return {
...result
};
}
When the PutItem in above function fails, I am interested in logging the error, would the piece of code log any error or the condition in response needs to be changed to if (ctx.outError) ?
Read more here: Source link
