简体   繁体   中英

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?

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/

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM