# Category Resolver

## Category

**File Name**: `category.js`&#x20;

**File Path**: `food-delivery-api/graphql/resolvers/category.js`&#x20;

This Resolver is used for managing categories mainly for web dashboard use. CRUD operations are performed over here namely creating category, fetching categories, editing categories and deleting categories.

### createCategory

* **GraphQL Type**: Mutation
* **Input Type or Parameters**: categoryInput

| **Name**    | **Type** | **Required** |
| ----------- | -------- | ------------ |
| \_id        | String   | false        |
| title       | String   | true         |
| description | String   | true         |
| img\_menu   | Upload   | false        |
| img\_header | Upload   | false        |

* **Description**: Creates a category with img menu for the image for menu screen and img header for the menu items screen
* **Response Input Type or Response:** Category!

| Name        | Type    |
| ----------- | ------- |
| \_id        | ID      |
| token       | String  |
| title       | String  |
| description | String  |
| img\_menu   | String  |
| img\_header | String  |
| is\_active  | Boolean |

### categories

* **GraphQL Type**: Query
* **Input Type or Parameters** Not needed
* **Description**: Fetches all the categories
* **Response Input Type or Response:** \[Category!]!

| Name        | Type   |
| ----------- | ------ |
| \_id        | ID     |
| title       | String |
| description | String |
| img\_menu   | String |
| img\_header | String |
| is\_active  | String |

### editCategory

* **GraphQL Type**: Mutation
* **Input Type or Parameters:** CategoryInput

| **Name**    | **Type** | **Required** |
| ----------- | -------- | ------------ |
| \_id        | String   | false        |
| title       | String   | true         |
| description | String   | true         |
| img\_menu   | Upload   | false        |
| img\_header | Upload   | false        |

* **Description**: Edits category for given \_id.&#x20;
* **Response Input Type or Response:** Category!

| Name        | Type   |
| ----------- | ------ |
| \_id        | ID     |
| title       | String |
| description | String |
| img\_menu   | String |
| img\_header | String |
| is\_active  | String |

### deleteCategory

* **GraphQL Type**: Mutation
* **Input Type or Parameters:** id

| **Name** | **Type** | **Required** |
| -------- | -------- | ------------ |
| id       | String   | true         |

* **Description**: Deletes Category for given id deleting doesn't delete it from database but only sets the is\_active flag to false
* **Response Input Type or Response:** Category!

| Name        | Type   |
| ----------- | ------ |
| \_id        | ID     |
| title       | String |
| description | String |
| img\_menu   | String |
| img\_header | String |
| is\_active  | String |
