好消息是您可以打开AppSync request logging 以在 CloudWatch 中获取请求级日志。使用 Cloudformation/CDK LogConfig 或直接在 AppSync 控制台中配置日志记录。
坏消息是记录的事件似乎并没有表明验证失败。看起来,格式正确和格式错误的请求都以类似的方式记录下来。日志级别 INFO 与 ERROR 似乎没有帮助。
可能有一种方法可以查找日志模式(格式错误的请求不会调用解析器)来区分好请求和坏请求,但这似乎并不简单。也许你的运气会比我好!
一个请求的日志条目示例:
Begin Request
GraphQL Query: query Labels { labelStats(topic: "cars") { name objects __typename } } , Operation: Labels,...
{"duration":201275210,"logType":"ExecutionSummary","requestId":"4f49d425-18ab-4be7-a40e-0229c17453dc","startTime":"2021-12-17T16:36:30.925216Z","e...
{"logType":"RequestSummary","requestId":"4f49d425-18ab-4be7-a40e-0229c17453dc","graphQLAPIId":"xxxxxxxxxx","statusCode":200,"lat...
Request Headers: {content-length=[148], cloudfront-viewer-country=[US], x-forwarded-proto=[https], x-amzn-r...
Response Headers: {Content-Type=application/json; charset=UTF-8}
End Request