# Category Resolver

## Category

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

**File Path**: `shopping-cart-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**: Creates a category for menu screen and all main categories.
* **Response Input Type or Response:** Category!

| Name       | Type    |
| ---------- | ------- |
| \_id       | ID      |
| title      | 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 |
| is\_active | String |

### editCategory

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

| **Name** | **Type** | **Required** |
| -------- | -------- | ------------ |
| \_id     | String   | false        |
| title    | String   | true         |

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

| Name       | Type   |
| ---------- | ------ |
| \_id       | ID     |
| title      | 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 |
| is\_active | String |
