遵循带有 Vue-Apollo 的出色 AppSync文章,但是它没有实现订阅。
我在 chrome 控制台中看到以下错误:
未处理的 GraphQL 订阅错误 TypeError:无法读取 SubscriptionHandshakeLink.request (subscription-handshake-link.js?419e:161) 处未定义的属性“订阅”
我做了以下无济于事:
import AWSAppSyncClient from "aws-appsync";
import VueApollo from "vue-apollo";
import appSyncConfig from "@/assets/AppSync";
const client = new AWSAppSyncClient(
{
url: appSyncConfig.graphqlEndpoint,
region: appSyncConfig.region,
auth: {
type: appSyncConfig.authenticationType,
apiKey: appSyncConfig.apiKey
}
},
{
defaultOptions: {
watchQuery: {
fetchPolicy: "cache-and-network"
}
}
}
);
const appsyncProvider = new VueApollo({
defaultClient: client
});
window.App = new Vue({
el: "#app",
provide: appsyncProvider.provide(),
render: h => h(App),
}); …Run Code Online (Sandbox Code Playgroud)