public override async Task <GetBySearchResponse> GetBySearch(GetBySearchRequest request, ServerCallContext context) { try { var searchResult = await _queryDispatcher.DispatchAsync <FetchContentPagesBySearchQuery, SearchResult <Proto.Types.ContentPage> >(new FetchContentPagesBySearchQuery { SearchTerm = request.SearchTerm, LanguageCode = request.LanguageCode, ParentId = request.ParentId, PageCursor = request.PageCursor, PageSize = request.PageSize ?? 24, SortKey = request.SortKey, Reverse = request.Reverse ?? false, }); return(new GetBySearchResponse { Results = { searchResult.Results.Select(x => new GetBySearchResponse.Types.Result() { Cursor = x.Cursor, Node = x.Node }) }, HasNextPage = searchResult.HasNextPage, HasPreviousPage = searchResult.HasPreviousPage, StartCursor = searchResult.StartCursor ?? string.Empty, EndCursor = searchResult.EndCursor ?? string.Empty, TotalResults = searchResult.TotalResults, }); } catch (Exception e) { _logger.LogError($"Failed fetching by search '{JsonSerializer.Serialize(request)}'", e); } return(new GetBySearchResponse()); }
public override async Task <GetBySearchResponse> GetBySearch(GetBySearchRequest request, ServerCallContext context) { try { var metaFields = await _queryDispatcher.DispatchAsync <FetchMetaFieldsBySearchQuery, IList <Proto.Types.MetaField> >(new FetchMetaFieldsBySearchQuery { ParentId = request.ParentId, Namespace = request.Namespace, Name = request.Name }); return(new GetBySearchResponse { Results = { metaFields }, }); } catch (Exception e) { _logger.LogError($"Failed fetching by search '{JsonSerializer.Serialize(request)}'", e); } return(new GetBySearchResponse()); }