Replies: 2 comments
-
@hfoletto Have you made any headway with this? I'm in a similar scenario and not able to find much documentation on it. |
Beta Was this translation helpful? Give feedback.
-
Hello @christohill, I didn't find any kind of adapter or convention for that, so I decided to do it my own. Assuming you already have graphql login/logout/register mutations on your API, this is what I did: I created a
I also created a plugin to fetchUser on initial page load:
I could have added the login and logout actions in the store as well, but decided to have those in the login page and default layout, respectively:
This is working great to me, but I'm not sure if that's the correct way of doing it. I'm considering moving the logout function to the store actions. The login I still prefer to have in the login page since it makes error handling easier (credentials invalid and etc). |
Beta Was this translation helpful? Give feedback.
-
Hello everyone, greetings!
I'm a long time Vue developer and recently decided to start playing with GraphQL.
I'm using Nuxt 3, so this module is very useful!
In past projects I was using Nuxt 2 with a standard REST API. For authentication I used the nuxt auth module: https://auth.nuxtjs.org/
After installing, the usage was very straight-forward:
I would use the above code in the login page, and I'm done. I'd have access to many properties and methods across the whole application: https://auth.nuxtjs.org/api/auth
Now with Apollo, I'm a bit lost on how to handle it. In the backend I already have the login, logout mutations, however I think some sort of adapter or just a convention is what I'm looking for.
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions