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!

已提問 2 年前檢視次數 51 次
沒有答案

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南