How client to do Graphql subcription with a provided token?

1

Hi everyone,

Currently, I get a problem when designing a system that the client needs to watch real-time graphs from Amplify Backend with a provided token (client didn't log in with AWS Cognito).

Here are the steps I want:

Step 1: Client requires to subscribe data of graph with a provided token.

Step 2: Backend checks the token is legit or not and accepts the connection.

Step 3: Any modified data in backend data will be notified to the client

Step 4: The client will upload the graph.

Currently, my design is client sends REST APIs each period to get data with provided token and the backend must check provided token each period.

It had disadvantages because the client always send requests to the back-end.

I try to make the client do GraphQL subscription data from the backend with provided token but can't think any solution can handle it.

The demo solution I can do with socket.io + NodeJS.

https://github.com/hoan-pham-duy/socket-io-with-token

In the frontend, the user can enter to token to ask for a socket connection from the backend In the backend, it checks the token provided by the user and returns a socket connection if it's valid.

Hope so much for your suggestion!

Thank you so much for your help!

demandé il y a 2 ans51 vues
Aucune réponse

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions