Auth Resolvers
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
Name | Type | Required |
phone | String | false |
email | String | true |
password | String | false |
name | String | false |
picture | String | false |
- 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
Name | Type |
userId | ID |
token | String |
name | String |
phone | String |
email | String |
picture | String |
location | Location |
- Location Input Type: Location
Name | Type |
longitude | String |
latitude | String |
delivery_address | String |
- GraphQL Type: Mutation
- Input Type or Parameters
Name | Type | Required |
email | String | true |
password | String | false |
type | String | true |
- 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 withAuthData
input type. - Response Input Type or Response: AuthData
Name | Type |
userId | ID |
token | String |
name | String |
phone | String |
email | String |
picture | String |
location | Location |
- Location Input Type: Location
Name | Type |
longitude | String |
latitude | String |
delivery_address | String |
- GraphQL Type: Mutation
- Input Type or Parameters: Location
Name | Type | Required |
longitude | String | true |
latitude | String | true |
- 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
Name | Type |
_id | String |
name | String |
phone | String |
email | String |
location | Location |
picture | String |
- Location Input Type: Location
Name | Type |
longitude | String |
latitude | String |
delivery_address | String |
- GraphQL Type: Mutation
- Input Type or Parameters
Name | Type | Required |
name | String | true |
phone | String | true |
delivery_address | String | true |
- Description: Updates User information
- Response Input Type or Response: AuthData
Name | Type |
name | ID |
phone | String |
delivery_address | Location |
- Location Input Type: Location
Name | Type | Required |
longitude | String | true |
latitude | String | true |
delivery_address | String | false |
- GraphQL Type: Mutation
- Input Type or Parameters
Name | Type | Required |
Upload | Scalar | true |
- 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 fromUser
Name | Type |
picture | String |
- 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
Name | Type |
name | ID |
phone | String |
email | String |
location | Location |
picture | String |
- Location Input Type: Location
Name | Type | Required |
longitude | String | true |
latitude | String | true |
delivery_address | String | false |
- GraphQL Type: Mutation
- Input Type or Parameters
Name | Type | Required |
email | String | true |
password | String | true |
- Description: Login resolver for admin dashboard
- Response Input Type or Response: Type Admin
Name | Type |
userId | ID |
name | String |
email | String |
token | String |
- GraphQL Type: Mutation
- Input Type or Parameters
Name | Type | Required |
token | String | true |
- Description: When a token is sent user data can be queried
- Response Input Type or Response: User
Name | Type |
_id | ID |
name | String |
phone | String! |
email | String! |
password | String |
payment_type | PaymentType! |
card_information | CardInformation |
location | Location |
picture | String |
likes | [Food!]! |
orders | [Order!]! |
is_active | Boolean! |
createdAt | String! |
updatedAt | String! |
- GraphQL Type: Query
- Input Type or Parameters:
- Description: All the users are retrieved queried from admin panel
- Response Input Type or Response: [User]
Name | Type |
_id | ID |
name | String |
phone | String |
email | String |
password | String |
payment_type | PaymentType |
card_information | CardInformation |
location | Location |
picture | String |
likes | [Food!]! |
orders | [Order!]! |
is_active | Boolean |
- GraphQL Type: Mutation
- Input Type or Parameters
Name | Type | Required |
email | String | true |
- Description: Sends a link with forgot password token in email to user
- GraphQL Type: Mutation
- Input Type or Parameters
Name | Type | Required |
password | String | true |
token | String | true |
- Description: Changes user password by verifying the token first
Last modified 2yr ago