Exemplo n.º 1
0
        /// <summary>
        /// Resolves all queries on guest accesses
        /// </summary>
        /// <param name="graphQlQuery"></param>
        public void ResolveQuery(GraphQlQuery graphQlQuery)
        {
            // LANGUAGES: a list of all lang codes
            graphQlQuery.FieldAsync <SearchResultType>(
                "searchResults",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <StringGraphType> > {
                Name = "query"
            }
                    ),
                resolve: async(context) =>
            {
                var searchResult = await _searchUseCase.Handle(new SearchRequest(
                                                                   context.GetArgument <string>("query")
                                                                   ));

                var channelsWithTruncatedDescription =
                    TruncateChannelDescriptions(searchResult.Channels);

                var truncatedDescriptionResults = searchResult with {
                    Channels = channelsWithTruncatedDescription
                };

                // map entity to model
                return(_mapper.Map <SearchResultModel>(truncatedDescriptionResults));
            }
                );
        }
 public ActionResult Search([FromQuery] Models.Requests.SearchRequest request)
 {
     if (String.IsNullOrEmpty(request.SearchQuery))
     {
         return(BadRequest(new { error = "search query must be non-empty string" }));
     }
     _searchUseCase.Handle(new SearchRequest(Regex.Replace(request.SearchQuery, @"\s+", " ").ToLower()), _searchPresenter);
     return(_searchPresenter.ContentResult);
 }