> ## Documentation Index
> Fetch the complete documentation index at: https://developer.jtl-software.com/llms.txt
> Use this file to discover all available pages before exploring further.

# QueryCategoriesByItemId

> Queries the categories an item is directly assigned to. Parent categories are only included if the item is assigned to them as well. Inactive categories are included. An item without categories returns an empty list; an unknown item is rejected as not found. The categories are ordered by their ID.



**query** `QueryCategoriesByItemId(itemId: ID!, first: Int, after: String, last: Int, before: String): QueryCategoriesByItemIdConnection`

## Arguments

**`itemId`**: `ID!` (required)

---

**`first`**: `Int`

Returns the first _n_ elements from the list.

---

**`after`**: `String`

Returns the elements in the list that come after the specified cursor.

---

**`last`**: `Int`

Returns the last _n_ elements from the list.

---

**`before`**: `String`

Returns the elements in the list that come before the specified cursor.

## Returns

`QueryCategoriesByItemIdConnection`

**`pageInfo`**: `PageInfo!`

Information to aid in pagination.

---

**`edges`**: `[QueryCategoriesByItemIdEdge!]`

A list of edges.

---

**`nodes`**: `[CategoryListItem!]`

A flattened list of the nodes.

---

**`totalCount`**: `Int!`

Identifies the total count of items in the connection.

## Examples

```graphql Query
query QueryCategoriesByItemId($itemId: ID!) {
  QueryCategoriesByItemId(itemId: $itemId) {
    pageInfo {
      hasNextPage
      hasPreviousPage
      startCursor
      endCursor
    }
    edges {
      cursor
      node {
        id
        parentId
        sortNumber
        name
      }
    }
    nodes {
      id
      parentId
      sortNumber
      name
    }
    totalCount
  }
}
```

```json Variables
{
  "itemId": "id"
}
```

```json Response
{
  "data": {
    "QueryCategoriesByItemId": {
      "pageInfo": {
        "hasNextPage": true,
        "hasPreviousPage": true,
        "startCursor": "string",
        "endCursor": "string"
      },
      "edges": [
        {
          "cursor": "string",
          "node": {
            "id": "id",
            "parentId": "id",
            "sortNumber": 1,
            "name": "string"
          }
        }
      ],
      "nodes": [
        {
          "id": "id",
          "parentId": "id",
          "sortNumber": 1,
          "name": "string"
        }
      ],
      "totalCount": 1
    }
  }
}
```
