From 0cb4ae42a43760025b8e21c864d67e3012fe1d36 Mon Sep 17 00:00:00 2001 From: Egor fureunoir Gorbunov Date: Wed, 7 May 2025 15:57:10 +0300 Subject: [PATCH] Add support for search results for posts Extended the search functionality to include results for posts. Updated `SearchResultsType` and related types to handle `posts`, adding a new `SearchPostsResultsType` with `uuid`, `name`, and `slug`. Adjusted mutations to populate posts in the search response. --- core/graphene/mutations.py | 1 + core/graphene/object_types.py | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/core/graphene/mutations.py b/core/graphene/mutations.py index e8ec944d..85131820 100644 --- a/core/graphene/mutations.py +++ b/core/graphene/mutations.py @@ -493,5 +493,6 @@ class Search(BaseMutation): products=data["products"], categories=data["categories"], brands=data["brands"], + posts=data["posts"], ) ) diff --git a/core/graphene/object_types.py b/core/graphene/object_types.py index 5cea32e6..bebc6603 100644 --- a/core/graphene/object_types.py +++ b/core/graphene/object_types.py @@ -454,19 +454,29 @@ class LanguageType(ObjectType): class SearchProductsResultsType(ObjectType): uuid = UUID() name = String() + slug = String() class SearchCategoriesResultsType(ObjectType): uuid = UUID() name = String() + slug = String() class SearchBrandsResultsType(ObjectType): uuid = UUID() name = String() + slug = String() + + +class SearchPostsResultsType(ObjectType): + uuid = UUID() + name = String() + slug = String() class SearchResultsType(ObjectType): products = List(description=_("products search results"), of_type=SearchProductsResultsType) categories = List(description=_("products search results"), of_type=SearchCategoriesResultsType) brands = List(description=_("products search results"), of_type=SearchBrandsResultsType) + posts = List(description=_("posts search results"), of_type=SearchPostsResultsType)