How to get the user data only in ApolloClient

Hello again, so Can you help me with this, I want to return only the data of the user when the user is logged in (return all the stuff like email, username, password, and etc.). btw I don’t usually write on the client-side so I’m not pretty sure what I’m doing. and I am using NextJs(Front-end), Next-Auth(handle authentication), and Apollo-server(API).

I am not familiar with Next-Auth and how it works. With that said, the usual flow as I understand it would be:

  1. Client makes a request (passing the username/email & password) to a “Login Service” to get an auth token (this could be short-lived or long-lived based on your use-case).
  2. In the subsequent request (to get user data), the client passes the auth token to the “user service” (apollo server).
  3. The user service needs to have a way to “validate” the auth token. If the auth token is still valid, return the data to the user. If the token validation fails, respond with an auth error.

This is a very high-level implementation. Let me know if you need clarification on any of the pieces above.

1 Like

Thanks. I already solve this a few days ago. Thanks anyway. :heart_eyes:

1 Like