SnakeFoot
SnakeFoot

Reputation: 174

Get the list of all subscribers to a public graphql subscription

I'm implementing a graphql server, it must have a public subscription for public updates. My question is, how would one get the subscriber count? Is there something I'm missing about graphql subscriptions? Are graphql endpoints even supposed to be freely available?

Upvotes: 5

Views: 1438

Answers (2)

Yun LUO
Yun LUO

Reputation: 1

Very useful links for you, please follow instructions from the first link to practice pub/sub and the second link is the recommendations for production.

  1. https://docs.nestjs.com/graphql/subscriptions
  2. https://github.com/apollographql/graphql-subscriptions#pubsub-implementations

Upvotes: 0

Adam G.
Adam G.

Reputation: 306

You will need to create a Publisher/Subscriber instance. Check out this example. From there you should be able to implement the counter. So each time you add a subscriber you can increment the count.

This example might also be helpful to you: https://graphql.org/blog/subscriptions-in-graphql-and-relay/

Upvotes: 1

Related Questions