Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 6 additions & 27 deletions src/pages/graphql/schema/live-search/queries/product-search.md
Original file line number Diff line number Diff line change
Expand Up @@ -384,42 +384,21 @@ filter:[
]
```

##### Error handling for categoryPath and categoryIds
##### Error handling for categories, categoryPath, and categoryIds

When sorting by category `position` with an empty or invalid `categoryPath` or `categoryIDs`, the Search service gracefully handles the request to prevent `FAILED_PRECONDITION` errors. This scenario commonly occurs when attempting to sort by position at the root category level, where category paths are not standardized across store views.
When sorting by category `position` with an empty or invalid `categories`, `categoryPath`, or `categoryIDs`, the Search service gracefully handles the request to prevent `FAILED_PRECONDITION` errors. This scenario commonly occurs when attempting to sort by position at the root category level, where category paths are not standardized across store views.

**Behavior when an empty or invalid `categoryPath` is detected with position sorting:**
**Behavior when an empty or invalid `categories`, `categoryPath`, or `categoryIDs` is detected with position sorting:**

- Category position sort is ignored
- The system falls back to relevance-based sorting
- Products are returned successfully
- A structured GraphQL warning is included in the response

**Warning message:**

The following warning is returned in the `errors` array alongside the product data:

```json
{
"errors": [
{
"message": "Sort ignored due to empty or invalid categoryPath or categoryIds. Default sorting by relevance applied.",
"locations": [],
"extensions": {
"severity": "WARNING",
"code": "EMPTY_CATEGORY_PATH_OR_CATEGORY_IDS",
"classification": "DataFetchingException"
}
}
]
}
```

<InlineAlert variant="info" slots="text"/>

Despite the warning, the query executes successfully and returns product data in the `data` object, sorted by relevance instead of position.
Despite the empty or invalid `categories`, `categoryPath`, or `categoryIDs`, the query executes successfully and returns product data in the `data` object, sorted by relevance instead of position.

**Example query that triggers the warning:**
**Example query:**

```graphql
{
Expand Down Expand Up @@ -449,7 +428,7 @@ Despite the warning, the query executes successfully and returns product data in
}
```

In this example, the system returns products sorted by relevance with the warning message included in the response.
In this example, the system returns products sorted by relevance.

#### categories

Expand Down