我在NodeJS上运行的Appsync和ApiGateway遇到问题。我设置了一些资源,这些资源通过与rest api的passThrough定义了多个端点。我也有Stage
,它定义了资源路径并启用了缓存。例如,我有一个资源,其路径与以下阶段MethodSetting
- ResourcePath: "/~1v1~1item~1{seasonCode}~1{itemCode}"
HttpMethod: "GET"
CacheDataEncrypted: false
CacheTtlInSeconds: ${self:provider.environment.ITEM_CACHE_TTL}
CachingEnabled: true
MetricsEnabled: true
据我所知,ResourcePath
必须匹配为此ApiGateway部署定义的资源中的路径。然后,我向在此阶段部署的api上的缓存/直通端点发出get请求,如下所示:
request = {
hostname: host,
path: `${pathPrefix}/v1.1/items/${seasonCode}/${itemCode}?policyCode=${
apiContext.policyCode
}`,
headers: apiGatewayHeaders(apiContext)
};
所有阶段MethodSetting
都返回以下错误:{ message: 'Internal server error' }
来自get请求。我的理解是Appsync会为特定的graphql请求触发一个lambda,而该lambda执行get方法。当lambda用cachign端点调用get方法时,出现上述错误。我正在使用cloudformation进行部署。
编辑:
ApiGateway在CloudWatch
中给了我以下日志。
{
"requestId": "57526082-dc90-4d51-867f-7cee467deacf",
"ip": "52.34.128.195",
"caller": "-",
"requestTime": "1591741653774",
"httpMethod": "GET",
"resourcePath": "/v1.1/items/{seasonCode}/{itemCode}",
"status": "500",
"protocol": "HTTP/1.1",
"responseLength": "36"
}