【问题标题】:Apollo v3 GraphQL Subscription Error: Must provide documentApollo v3 GraphQL 订阅错误:必须提供文档
【发布时间】: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


【解决方案1】:

我遇到了同样的问题。将 apollo-server-express 降级到 3.1.2。

那么一切都会正常。

【讨论】:

    猜你喜欢
    • 2018-04-01
    • 2017-08-26
    • 2021-12-15
    • 2020-04-23
    • 2019-01-11
    • 2019-06-09
    • 2019-06-02
    • 2017-09-19
    • 2017-01-09
    相关资源
    最近更新 更多