WhatsApp-Clone-Server icon indicating copy to clipboard operation
WhatsApp-Clone-Server copied to clipboard

PubSub Issues

Open hfgn opened this issue 2 years ago • 0 comments

I don't know why the subscription is not working

Mutation: {
    async test(root, args, { injector}){      
          injector.get(PubSub).publish('NUMBER_INCREMENTEDD',  {messageAdded:{id:"testsuscription"}});
    }
}


Subscription: {
    messageAdded: {
      subscribe: (root, args, { injector }) => {
          return injector.get(PubSub).asyncIterator('NUMBER_INCREMENTEDD');
      }
}

if i print the injector.get(PubSub) the result is

PostgresPubSub {
  ee: EventEmitter {
    _events: [Object: null prototype] {
      newListener: [Function (anonymous)],
      removeListener: [Function (anonymous)],
      NUMBER_INCREMENTEDD: [Function: pushValue]
    },
    _eventsCount: 3,
    _maxListeners: undefined,
    notify: [Function (anonymous)],
    send: [Function (anonymous)],
    end: [Function (anonymous)],
    [Symbol(kCapture)]: false
  },
  subscriptions: {},
  subIdCounter: 0,
  client: Client {
    _events: [Object: null prototype] { notification: [Function (anonymous)] },
    _eventsCount: 1,
    _maxListeners: undefined,
    connectionParameters: ConnectionParameters {
      user: 'testuser',
      database: 'whatsapp',
      port: 25432,
      host: 'localhost',
      password: 'testpassword',
      binary: false,
      ssl: false,
      client_encoding: '',
      replication: undefined,
      isDomainSocket: false,
      application_name: undefined,
      fallback_application_name: undefined,
      statement_timeout: false,
      idle_in_transaction_session_timeout: false,
      query_timeout: false,
      connect_timeout: 0
    },
    user: 'testuser',
    database: 'whatsapp',
    port: 25432,
    host: 'localhost',
    password: 'testpassword',
    replication: undefined,
    _Promise: [Function: Promise],
    _types: TypeOverrides { _types: [Object], text: {}, binary: {} },
    _ending: false,
    _connecting: true,
    _connected: false,
    _connectionError: false,
    _queryable: true,
    connection: Connection {
      _events: [Object: null prototype],
      _eventsCount: 14,
      _maxListeners: undefined,
      stream: [Socket],
      _keepAlive: false,
      _keepAliveInitialDelayMillis: 0,
      lastBuffer: false,
      lastOffset: 0,
      buffer: null,
      offset: null,
      encoding: 'utf8',
      parsedStatements: {},
      writer: [Object],
      ssl: false,
      _ending: false,
      _mode: 0,
      _emitMessage: false,
      _reader: [Object],
      [Symbol(kCapture)]: false
    },
    queryQueue: [ [Query] ],
    binary: false,
    processID: null,
    secretKey: null,
    ssl: false,
    _connectionTimeoutMillis: 0,
    [Symbol(kCapture)]: false
  },
  commonMessageHandler: [Function: defaultCommonMessageHandler]
}

the subscriptions: {} is empty

hfgn avatar Dec 09 '22 12:12 hfgn