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

# Filtering Catalog Items

The `getCatalogData` query supports powerful filtering capabilities, allowing users to narrow down the list of catalog items.

Within a **Standard API**, the system offers next predefined filters:

| Filter Name | Filter ID         | Purpose                                                                                                                                    |
| ----------- | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| Search      | `filter_search`   | Filters catalog items by training title or description using a free-text query.                                                            |
| Duration    | `filter_duration` | Filters by training duration, based on duration terms already associated with catalog items.                                               |
| Domains     | `filter_domain`   | Filters by training domains, based on domain terms already associated with catalog items.                                                  |
| Status      | `filter_status`   | Filters by the user's training attempt status, such as "Not started", "In progress", or "Passed". Only applicable for authenticated users. |
| Bookmarks   | `filter_bookmark` | Filters catalog items to show only bookmarked learning paths for the current user. Only available for authenticated users.                 |

Within the [**<u>Custom API</u>**](/OpignoEnterpriseAPI/CustomAPIUsage)**,** the list of filters is automatically extended with any client-defined custom fields. Please refer to the dedicated documentation for full implementation details.

The list of available filters can be fetched using the `getCatalogFilters` query:

<CodeGroup>
  ```GraphQL GraphQL theme={null}
  query getCatalogFilters {
    getCatalogFilters {
      id
      label
      options {
        key
        value
        weight
      }
      formElementType
      filterFormSection
    }
  }
  ```

  ```Query Query result [expandable] theme={null}
  {
      "data": {
          "getCatalogFilters": [
              {
                  "id": "filter_search",
                  "label": "Search",
                  "options": null,
                  "formElementType": "TEXTFIELD",
                  "filterFormSection": "filter_list"
              },
              {
                  "id": "filter_duration",
                  "label": "Duration",
                  "options": [
                      {
                          "key": "3",
                          "value": "30",
                          "weight": 0
                      },
                      {
                          "key": "4",
                          "value": "40 min",
                          "weight": 0
                      },
                      {
                          "key": "8",
                          "value": "1 min",
                          "weight": 0
                      },
                      {
                          "key": "9",
                          "value": "50 min",
                          "weight": 0
                      }
                  ],
                  "formElementType": "CHECKBOXES",
                  "filterFormSection": "filter_list"
              },
              {
                  "id": "filter_domain",
                  "label": "Domains",
                  "options": [
                      {
                          "key": "1",
                          "value": "Domain 1",
                          "weight": 0
                      },
                      {
                          "key": "2",
                          "value": "Domain 2",
                          "weight": 0
                      },
                      {
                          "key": "10",
                          "value": "Domain 1.2",
                          "weight": 0
                      }
                  ],
                  "formElementType": "CHECKBOXES",
                  "filterFormSection": "filter_list"
              },
              {
                  "id": "filter_status",
                  "label": "Status",
                  "options": [
                      {
                          "key": "TO_START",
                          "value": "Not started",
                          "weight": 0
                      },
                      {
                          "key": "IN_PROGRESS",
                          "value": "Started",
                          "weight": 1
                      },
                      {
                          "key": "PASSED",
                          "value": "Passed",
                          "weight": 2
                      },
                      {
                          "key": "FAILED",
                          "value": "Failed",
                          "weight": 3
                      }
                  ],
                  "formElementType": "CHECKBOXES",
                  "filterFormSection": "filter_list"
              },
              {
                  "id": "filter_bookmark",
                  "label": "Show bookmarked only",
                  "options": null,
                  "formElementType": "CHECKBOX",
                  "filterFormSection": "head"
              }
          ]
      }
  }
  ```
</CodeGroup>

## **UI Rendering Guidelines**

To ensure a consistent and intuitive user experience, follow these guidelines when rendering filters in the client platform:

| Field               | Usage                                                                                            |
| ------------------- | ------------------------------------------------------------------------------------------------ |
| `id`                | The filter ID. This must be passed back to the API exactly as received—do not modify or parse.   |
| `label`             | The recommended filter label. This can be renamed or localized on the client platform as needed. |
| `formElementType`   | Determines the UI control to render. Common values include `CHECKBOXES` and `TEXTFIELD`.         |
| `options`           | A list of selectable options for the filter, if applicable. Most relevant for `CHECKBOXES`.      |
| `filterFormSection` | Optional field that suggests a logical grouping or placement in the UI layout.                   |

## **Applying Filters**

Filtering is configured using the `filters` argument in the `getCatalogData` query.

<Note>
  Filtering can be combined with **sorting** and **pagination** arguments to further refine the results.
</Note>

### **Filtering Arguments**

| Argument  | Type            | Description                                                               |
| :-------- | :-------------- | :------------------------------------------------------------------------ |
| `filters` | `[FilterInput]` | A list of filter objects specifying which fields and values to filter by. |

Each `FilterInput` consists of:

### **FilterInput Fields**

| Field   | Type       | Description                                                                                                                                                                                        |
| :------ | :--------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `key`   | `ID`       | The filter field ID (e.g. `"filter_duration"`). Must match values from `getCatalogFilters`.                                                                                                        |
| `value` | `[String]` | One or more values to apply for the specified filter: <br />• For `CHECKBOXES`, use the selected **option keys**.<br />• For `TEXTFIELD`, pass the **raw input string** as a single-element array. |

## **Example: Applying Multiple Filters**

The following example applies multiple filters to the `getCatalogData` query: **duration** filter selecting specific predefined options, **search** filter using free-text input to match training by title, and **bookmark** filter to show only bookmarked.

<CodeGroup>
  ```GraphQL GraphQL theme={null}
  query {
   getCatalogData(
      first: 5,
      filters: [
        {
          key: "filter_duration",
          value: ["3", "4"]
        },
        {
          key: "filter_search",
          value: ["Anonymous"]
        },
        {
          key: "filter_bookmark",
          value: ["true"]
        }
      ]
    ) {
      edges {
        node {
          training {
            title
            duration { id, name }
          }
        }
      }
      totalItems
    }
  }
  ```

  ```Query Query result theme={null}
  {
      "data": {
          "getCatalogData": {
              "edges": [
                  {
                      "node": {
                          "training": {
                              "title": "LP Anonymous Free",
                              "duration": [
                                  {
                                      "id": "3",
                                      "name": "30"
                                  }
                              ]
                          }
                      }
                  }
              ],
              "totalItems": 1
          }
      }
  }
  ```
</CodeGroup>
