【发布时间】:2021-12-15 02:33:55
【问题描述】:
我正在使用文档中的示例设置测试 Apollo v3 上的订阅。但我收到上述错误。我不确定我错过了什么。
这是完整的reproducible code on Github gist
const typeDefs = gql`
type Subscription {
incremented: Int
}
`;
const resolvers = {
Subscription: {
incremented: {
subscribe: () => pubsub.asyncIterator('NUMINCREMENTED'),
},
},
};
(async function () {
const schema = makeExecutableSchema({
typeDefs,
resolvers,
});
const subscriptionServer = SubscriptionServer.create(
{
schema,
execute,
subscribe,
},
{ server: httpServer }
);
const server = new ApolloServer({
schema,
plugins: [
{
async serverWillStart() {
return {
async drainServer() {
subscriptionServer.close();
},
};
},
},
],
});
})();
这是我在 Apollo Studio 上尝试订阅时出现的错误。
【问题讨论】:
-
你解决了吗?
标签: graphql apollo apollo-server graphql-subscriptions