【发布时间】:2017-05-29 08:16:18
【问题描述】:
我在我的 Angular 应用程序中使用 Apollo,现在我遇到了这个问题。我在 AWS Lambda 上有一个 GraphQL 端点,通过 API Gateway 我看到响应正确返回,但是当它通过读取它时会引发此错误。 AWS 正在使用 LAMBDA_PROXY
//setup
const client = new ApolloClient({
networkInterface: createNetworkInterface({
opts: {
mode: 'no-cors',
},
uri: "https://xxxxxxx.execute-api.ap-southeast-2.amazonaws.com/dev/graphql"
}),
});
//make the call
this.apollo.watchQuery({
forceFetch: true,
query: QueryToSend
}).subscribe(({data}) => {
...process...
}, error => {
console.log(error);
});
//the error...
Network error: Unexpected end of input
at new ApolloError (ApolloError.js:31)
at QueryManager.js:128
at t.invoke (polyfills.js:3)
at Object.onInvoke (ng_zone.js:236)
at t.invoke (polyfills.js:3)
at e.run (polyfills.js:3)
at polyfills.js:3
at t.invokeTask (polyfills.js:3)
at Object.onInvokeTask (ng_zone.js:227)
at t.invokeTask (polyfills.js:3)
请求是
const QueryToSend= gql`
query data {
getSuperDefinitionList{
id,
name,
}
}
`;
不知道出了什么问题。我从 Postman 和 SoapUI 调用相同的请求正文。我什至看到提琴手响应有正确的响应......
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: ...
Connection: keep-alive
Date: Fri, 13 Jan 2017 21:10:10 GMT
x-amzn-RequestId: ab0fghjghja-d9d4-11e6-b19a-090dsfvdgcebe
X-Amzn-Trace-Id: Root=1-58794232-c7f7157d28e033330dbbe6f2
X-Cache: Miss from cloudfront
Via: 1.1 a1d4b598e9b2fghjgfhj3991961a666a6.cloudfront.net (CloudFront)
X-Amz-Cf-Id: XHeOfghjfghjUthDPKxVbCrFoLM4iOYpf9X9mWlu2Z374grmuAv5jMjg==
{"data":{"getSuperDefinitionList":[{"id":"83d3b09f-a947-4a33-bcb0-f5c9e0446ace","name":"S","__typename":"SuperDefinitionType"}]}}
从 AWS 看来一切正常,但 Apollo 或它使用的某些 javascript 库却不行。
我能做什么?
【问题讨论】:
标签: javascript amazon-web-services angular graphql apollo