From b93d91528b3265bc520474d9031615371f41fdec Mon Sep 17 00:00:00 2001 From: Untone Date: Sun, 3 Dec 2023 01:22:16 +0300 Subject: [PATCH] search-resolver-fix --- resolvers/reader.py | 11 +++++++++++ schemas/core.graphql | 1 + 2 files changed, 12 insertions(+) diff --git a/resolvers/reader.py b/resolvers/reader.py index 05a6eb9b..8416a88c 100644 --- a/resolvers/reader.py +++ b/resolvers/reader.py @@ -9,6 +9,7 @@ from orm.topic import TopicFollower from orm.reaction import Reaction, ReactionKind from orm.shout import Shout, ShoutAuthor, ShoutTopic, ShoutVisibility from orm.author import AuthorFollower, Author +from services.search import SearchService from services.viewed import ViewedStorage @@ -179,6 +180,7 @@ async def load_shouts_drafts(_, info): joinedload(Shout.topics), ) .filter(Shout.deleted_at.is_(None)) + .filter(Shout.visibility == ShoutVisibility.AUTHORS.value) ) shouts = [] @@ -249,3 +251,12 @@ async def load_shouts_feed(_, info, options): shouts.append(shout) return shouts + + +@query.field("load_shouts_search") +async def load_shouts_search(_, _info, text, limit=50, offset=0): + if text and len(text) > 2: + return SearchService.search(text, limit, offset) + else: + return [] + diff --git a/schemas/core.graphql b/schemas/core.graphql index 5d17dbb7..2f7a4ef4 100644 --- a/schemas/core.graphql +++ b/schemas/core.graphql @@ -354,6 +354,7 @@ type Query { load_shouts_by(options: LoadShoutsOptions): [Shout] load_shouts_search(text: String!, limit: Int, offset: Int): [Shout] load_shouts_feed(options: LoadShoutsOptions): [Shout] + load_shouts_drafts: [Shout] # topic get_topic(slug: String!): Topic