Auth Resolvers
Last updated
Last updated
File Name: auth.js
File Path: enatega-multivendor-api/graphql/resolvers/auth.js
Auth Resolver handles queries related to User it handles creating user, login, updating location, updating user, uploading user profile picture, handling user profile, handling admin login, getting all users, forgot password functionality and password reset functionality.
GraphQL Type: Mutation
Input Type or Parameters: userInput
Description: Creates a new User with above mentioned parameters. Once a user is registered an account creation email is sent to the user. A token is also sent as a response with user id and user information.
Response Input Type or Response: AuthData
Location Input Type: Location
GraphQL Type: Mutation
Input Type or Parameters
Description: Logins a User with email and password. type
flag is used to check if the user is using social auth for authentication for example google or facebook. The response is sent with AuthData
input type.
Response Input Type or Response: AuthData
Location Input Type: Location
GraphQL Type: Mutation
Input Type or Parameters: Location
Description: Updates location of the user called when user resets app as a response user information is sent with location. User information is sent because update location is called every time app restarts. You might be wondering how did we get user data with this input parameters the reason is the app is configured with header parameters where a middleware is written to get user object from header authentication token. This middleware can be found at food-delivery-api/middleware/is-auth.js
Response Input Type or Response: User data and input type Location
Location Input Type: Location
GraphQL Type: Mutation
Input Type or Parameters
Description: Updates User information
Response Input Type or Response: AuthData
Location Input Type: Location
GraphQL Type: Mutation
Input Type or Parameters
Description: Uploads User profile picture in the settings screen the type for Upload is Scalar you can learn more about it by clicking here.
Response Input Type or Response: Input type User
only picture field is queried from User
GraphQL Type: Query
Input Type or Parameters: No user parameters is needed as auth token is sent on every request
Description: Gets User profile.
Response Input Type or Response: AuthData
Location Input Type: Location
GraphQL Type: Mutation
Input Type or Parameters
Description: Login resolver for admin dashboard
Response Input Type or Response: Type Admin
GraphQL Type: Mutation
Input Type or Parameters
Description: When a token is sent user data can be queried
Response Input Type or Response: User
GraphQL Type: Query
Input Type or Parameters:
Description: All the users are retrieved queried from admin panel
Response Input Type or Response: [User]
GraphQL Type: Mutation
Input Type or Parameters
Description: Sends a link with forgot password token in email to user
GraphQL Type: Mutation
Input Type or Parameters
Description: Changes user password by verifying the token first