Graphql Subscriptions field must return Async Iterable. Received: { pubsub

Graphql Subscriptions field must return Async Iterable. Received: { pubsub


0

I’m trying go use subscriptions in graphql, but I’m receiving this weird error:

subscription {
  notification {
    type
     message
  }
}

I’m using import { PubSub } from "graphql-subscriptions";

import { Inject } from "@nestjs/common";
import { Resolver, Subscription } from "@nestjs/graphql";
import { PubSub } from "graphql-subscriptions";
import { Notification } from "./models/notification";

@Resolver(() => Notification)
export class NotificationResolver {
  constructor(@Inject('PUB_SUB') private pubSub: PubSub) {}

  @Subscription(() => Notification, {
    resolve: (payload) => payload?.notification || {}
  })
  notification() {
    return this.pubSub.asyncIterator('notification');
  }
}

Error:
{ "error": { "message": "Subscription field must return Async Iterable. Received: { pubsub: { ee: [Object], subscriptions: {}, subIdCounter: 0 }, pullQueue: [], pushQueue: [], running: true, allSubscribed: null, eventsArray: ["notification"] }." } }

I tryied to use, but the error was the same:

subscriptions: {
    'graphql-ws': true
  },


Load 3 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *