E
E
Egor Astreiko2019-07-29 07:22:44
Node.js
Egor Astreiko, 2019-07-29 07:22:44

How to properly use SubscriptionServer GraphQL Express?

Hello backend gurus.
I'm starting to study the backend, and I read that GraphQL's SubscriptionServer works on websockets.
Questions arose:

  1. What is the correct way to use SubscriptionServer ?
  2. Will this work in all browsers (since socket.io uses websockets if supported by the browser) ?
  3. Is it possible to completely replace SubscriptionServer with Rest api ?
  4. If it is possible, then what about access token and refresh token if front is written entirely in react ?

Or will it be correct to use SubscriptionServer only for chatting on the project, and let authorization and all that through the http server (then the question is why is it needed at all when socket.io runs on the same proxy server as the http server, and SubscriptionServer needs a separate one) ?
Please answer as informative as possible for someone new to this.
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Shitskov, 2019-07-29
@Zarom

  • Use either rest or GraphQL.
  • Why do you need GraphQL if you are only going to use subscription?
  • Authorization can also be performed through Middleware
  • Sockets will work wherever they are supported. You can see the list of supported browsers - the list is freely available.
  • The GraphQL documentation should be read and the front rewritten to work with GraphQL

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question