From c02702731dc585fecafadbad010f495a5cf6cb4b Mon Sep 17 00:00:00 2001 From: Horia Constantin Date: Tue, 2 Feb 2021 18:33:14 +0100 Subject: [PATCH 01/10] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index cc7c2b2..1ee9411 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ SDL Dynamic Experience Delivery GraphQL client for .NET === - Develop: ![Build Status](https://github.com/sdl/graphql-client-dotnet/workflows/Build/badge.svg?branch=develop) -- 2.2: ![Build Status](https://github.com/sdl/graphql-client-dotnet/workflows/Build/badge.svg?branch=release/2.2) About ----- From 1aa067603e6ac28d6c7a3706fbbd9fe0df56c2ba Mon Sep 17 00:00:00 2001 From: Horia Constantin Date: Tue, 2 Feb 2021 18:33:29 +0100 Subject: [PATCH 02/10] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1ee9411..49fe88a 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ Of course, it is also possible (and appreciated) to report an issue without asso License ------- -Copyright (c) 2014-2020 SDL Group. +Copyright (c) 2014-2021 SDL Group. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From 1b9cd700e331157fbb792b1f59de5778336bcf1a Mon Sep 17 00:00:00 2001 From: Horia Constantin Date: Tue, 2 Feb 2021 18:33:44 +0100 Subject: [PATCH 03/10] Delete _travis.yml --- _travis.yml | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 _travis.yml diff --git a/_travis.yml b/_travis.yml deleted file mode 100644 index 2c613e5..0000000 --- a/_travis.yml +++ /dev/null @@ -1,3 +0,0 @@ -language: csharp -solution: net/sln/Sdl.Tridion.Api.Client.sln - From 2070d0118ca4b1be5682f319e9588e9367142cea Mon Sep 17 00:00:00 2001 From: Paul Adams Date: Wed, 3 Feb 2021 12:46:38 +0000 Subject: [PATCH 04/10] Added pre-reqs to readme --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 49fe88a..ee33803 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,12 @@ SDL Dynamic Experience Delivery GraphQL client for .NET === - Develop: ![Build Status](https://github.com/sdl/graphql-client-dotnet/workflows/Build/badge.svg?branch=develop) +Prerequisites +------------- +For building .NET you must have the following installed: +- Visual Studio 2019 +- .NET Framework 4.6.2 + About ----- The GraphQL client provides a public content API for .NET in order to retrieve content from the new GraphQL endpoint exposed by the Content Service. From 37ce5bcc97d82754d2840bae7294055693be2871 Mon Sep 17 00:00:00 2001 From: Paul Adams Date: Tue, 3 Aug 2021 09:02:22 +0100 Subject: [PATCH 05/10] CRQ-25146 : Fixed graphql query signitures + added retry code --- net/src/Sdl.Tridion.Api.Client/ApiClient.cs | 6 ++ .../GraphQLClient/GraphQLClient.cs | 9 +++ .../GraphQLClient/IGraphQLClient.cs | 5 ++ .../HttpClient/HttpClient.cs | 76 ++++++++++++++----- .../HttpClient/IHttpClient.cs | 1 + .../Queries/BinaryComponentByCmUri.graphql | 2 +- .../Queries/BinaryComponentById.graphql | 2 +- .../Queries/BinaryComponentByUrl.graphql | 2 +- .../Queries/ComponentPresentation.graphql | 2 +- .../Queries/ComponentPresentations.graphql | 2 +- .../Queries/EntityModelById.graphql | 2 +- .../Queries/ItemQuery.graphql | 2 +- .../Queries/PageByCmUri.graphql | 2 +- .../Queries/PageById.graphql | 2 +- .../Queries/PageByUrl.graphql | 2 +- .../Queries/PageModelById.graphql | 2 +- .../Queries/PageModelByUrl.graphql | 2 +- .../Queries/PagesByUrl.graphql | 2 +- .../Queries/Publication.graphql | 2 +- .../Queries/Publications.graphql | 2 +- .../Queries/Sitemap.graphql | 2 +- .../Queries/SitemapSubtree.graphql | 2 +- .../Queries/SitemapSubtreeNoRecurse.graphql | 2 +- 23 files changed, 97 insertions(+), 36 deletions(-) diff --git a/net/src/Sdl.Tridion.Api.Client/ApiClient.cs b/net/src/Sdl.Tridion.Api.Client/ApiClient.cs index 8ff1f06..d0c07e8 100644 --- a/net/src/Sdl.Tridion.Api.Client/ApiClient.cs +++ b/net/src/Sdl.Tridion.Api.Client/ApiClient.cs @@ -55,6 +55,12 @@ public int Timeout set { _client.Timeout = value; } } + public int RetryCount + { + get { return _client.RetryCount; } + set { _client.RetryCount = value; } + } + public IHttpClient HttpClient => _client.HttpClient; diff --git a/net/src/Sdl.Tridion.Api.Client/GraphQLClient/GraphQLClient.cs b/net/src/Sdl.Tridion.Api.Client/GraphQLClient/GraphQLClient.cs index 4753244..0425096 100644 --- a/net/src/Sdl.Tridion.Api.Client/GraphQLClient/GraphQLClient.cs +++ b/net/src/Sdl.Tridion.Api.Client/GraphQLClient/GraphQLClient.cs @@ -70,6 +70,15 @@ public int Timeout set { _httpClient.Timeout = value; } } + /// + /// Get/Sets the retry count for any request. + /// + public int RetryCount + { + get { return _httpClient.RetryCount; } + set { _httpClient.RetryCount = value; } + } + /// /// HttpClient used for performing the actual request. /// diff --git a/net/src/Sdl.Tridion.Api.Client/GraphQLClient/IGraphQLClient.cs b/net/src/Sdl.Tridion.Api.Client/GraphQLClient/IGraphQLClient.cs index 3580201..9bba279 100644 --- a/net/src/Sdl.Tridion.Api.Client/GraphQLClient/IGraphQLClient.cs +++ b/net/src/Sdl.Tridion.Api.Client/GraphQLClient/IGraphQLClient.cs @@ -23,6 +23,11 @@ public interface IGraphQLClient /// int Timeout { get; set; } + /// + /// Get/Sets the retry count for the requests. + /// + int RetryCount { get; set; } + /// /// HttpClient used for performing the actual request. /// diff --git a/net/src/Sdl.Tridion.Api.Client/HttpClient/HttpClient.cs b/net/src/Sdl.Tridion.Api.Client/HttpClient/HttpClient.cs index bc4c3b4..12d6c66 100644 --- a/net/src/Sdl.Tridion.Api.Client/HttpClient/HttpClient.cs +++ b/net/src/Sdl.Tridion.Api.Client/HttpClient/HttpClient.cs @@ -22,6 +22,7 @@ public class HttpClient : IHttpClient { public Uri BaseUri { get; set; } public int Timeout { get; set; } = 30000; + public int RetryCount { get; set; } = 5; public string UserAgent { get; set; } = "SDL.PCA.NET"; public HttpHeaders Headers { get; set; } = new HttpHeaders(); public ILogger Logger { get; } = new NullLogger(); @@ -74,38 +75,36 @@ public HttpClient(Uri endpoint, ILogger logger, IAuthentication auth) : this(end public virtual IHttpClientResponse Execute(IHttpClientRequest clientRequest) { - HttpWebRequest request = CreateHttpWebRequest(clientRequest); try { - using (WebResponse response = request.GetResponse()) + return RetryBlock>(() => { - HttpWebResponse httpWebResponse = (HttpWebResponse)response; - - using (Stream responseStream = response.GetResponseStream()) + var request = CreateHttpWebRequest(clientRequest); + using (var response = request.GetResponse()) { - if (responseStream != null) + var httpWebResponse = (HttpWebResponse) response; + using (var responseStream = response.GetResponseStream()) { - byte[] data = ReadStream(responseStream); - + if (responseStream == null) return default(HttpClientResponse); + var data = ReadStream(responseStream); LogErrorResponse(data); - - T deserialized = Deserialize(data, httpWebResponse.ContentType, clientRequest.Binder, clientRequest.Convertors); - + var deserialized = Deserialize(data, httpWebResponse.ContentType, clientRequest.Binder, + clientRequest.Convertors); return new HttpClientResponse { - StatusCode = (int)httpWebResponse.StatusCode, + StatusCode = (int) httpWebResponse.StatusCode, ContentType = httpWebResponse.ContentType, Headers = new HttpHeaders(httpWebResponse.Headers), ResponseData = deserialized }; } } - } + }, RetryCount); } catch (WebException e) { if (e.Response == null) throw new HttpClientException(e.Message, e); - byte[] data = ReadStream(e.Response.GetResponseStream()); + var data = ReadStream(e.Response.GetResponseStream()); throw new HttpClientException( $"Failed to get http response from '{BaseUri}' with request: {clientRequest}", e, (int)e.Status, Encoding.UTF8.GetString(data)); @@ -114,16 +113,14 @@ public virtual IHttpClientResponse Execute(IHttpClientRequest clientReques { throw new HttpClientException($"Failed to get http response from '{BaseUri}' with request: {clientRequest}", e); } - - throw new HttpClientException($"Failed to get http response from '{BaseUri}' with request: {clientRequest}"); } public virtual async Task> ExecuteAsync(IHttpClientRequest clientRequest, CancellationToken cancellationToken = default(CancellationToken)) { - HttpWebRequest request = CreateHttpWebRequest(clientRequest); try { + HttpWebRequest request = CreateHttpWebRequest(clientRequest); using (WebResponse response = await request.GetResponseAsync().ConfigureAwait(false)) { HttpWebResponse httpWebResponse = (HttpWebResponse)response; @@ -213,7 +210,7 @@ private void LogErrorResponse(byte[] data) if (Logger.IsTracingEnabled && responseData.Contains("errors")) //not the best way to do it, but couldn't see any other way { - Logger.Trace($"Error Respose: {responseData}"); + Logger.Trace($"Error Response: {responseData}"); } } @@ -284,5 +281,48 @@ protected virtual T Deserialize(byte[] data, string contentType, Serializatio settings.Converters.Add(x); return JsonConvert.DeserializeObject(json, settings); } + + protected T RetryBlock(Func block, int retryCount) + { + if (retryCount < 0) + return default(T); + + int sleepTime = 1000; + while (retryCount > 0) + { + retryCount--; + try + { + return block(); + } + catch (Exception e) + { + WebException webException = e as WebException; + if (webException != null) + { + Logger.Debug($"Received web exception status code = {webException.Status}"); + } + if (retryCount <= 0) + { + Logger.Debug("Failed to receive a valid response after exhausting all retry attempts.."); + if (webException == null) throw; + if (webException.Response == null) throw; + var responseStream = webException.Response.GetResponseStream(); + if (responseStream == null) throw; + var resp = new StreamReader(responseStream).ReadToEnd(); + dynamic obj = JsonConvert.DeserializeObject(resp); + var serverResponseMsg = obj.error.message; + Logger.Debug($"Response message from server was {serverResponseMsg}"); + throw; + } + + Logger.Debug($"Sleeping for {sleepTime}ms"); + Thread.Sleep(sleepTime); + sleepTime += sleepTime; + } + } + + return default(T); + } } } diff --git a/net/src/Sdl.Tridion.Api.Client/HttpClient/IHttpClient.cs b/net/src/Sdl.Tridion.Api.Client/HttpClient/IHttpClient.cs index fcc777e..d676b5d 100644 --- a/net/src/Sdl.Tridion.Api.Client/HttpClient/IHttpClient.cs +++ b/net/src/Sdl.Tridion.Api.Client/HttpClient/IHttpClient.cs @@ -13,6 +13,7 @@ public interface IHttpClient { Uri BaseUri { get; set; } int Timeout { get; set; } + int RetryCount { get; set; } string UserAgent { get; set; } HttpHeaders Headers { get; set; } IHttpClientResponse Execute(IHttpClientRequest request); diff --git a/net/src/Sdl.Tridion.Api.Client/Queries/BinaryComponentByCmUri.graphql b/net/src/Sdl.Tridion.Api.Client/Queries/BinaryComponentByCmUri.graphql index e2cd3ed..fe5e952 100644 --- a/net/src/Sdl.Tridion.Api.Client/Queries/BinaryComponentByCmUri.graphql +++ b/net/src/Sdl.Tridion.Api.Client/Queries/BinaryComponentByCmUri.graphql @@ -1,4 +1,4 @@ -query binaryComponent($namespaceId: Int!, $publicationId: Int!, $cmUri: String, $contextData: [InputClaimValue!]) { +query binaryComponent($namespaceId: Int!, $publicationId: Int!, $cmUri: String, $contextData: [InputClaimValue]) { binaryComponent(namespaceId: $namespaceId, publicationId: $publicationId, cmUri: $cmUri, contextData: $contextData) { ...ItemFields ...BinaryComponentFields diff --git a/net/src/Sdl.Tridion.Api.Client/Queries/BinaryComponentById.graphql b/net/src/Sdl.Tridion.Api.Client/Queries/BinaryComponentById.graphql index 94bc0a6..fe61553 100644 --- a/net/src/Sdl.Tridion.Api.Client/Queries/BinaryComponentById.graphql +++ b/net/src/Sdl.Tridion.Api.Client/Queries/BinaryComponentById.graphql @@ -1,4 +1,4 @@ -query binaryComponent($namespaceId: Int!, $publicationId: Int!, $binaryId: Int!, $contextData: [InputClaimValue!]) { +query binaryComponent($namespaceId: Int!, $publicationId: Int!, $binaryId: Int!, $contextData: [InputClaimValue]) { binaryComponent(namespaceId: $namespaceId, publicationId: $publicationId, binaryId: $binaryId, contextData: $contextData) { ...ItemFields ...BinaryComponentFields diff --git a/net/src/Sdl.Tridion.Api.Client/Queries/BinaryComponentByUrl.graphql b/net/src/Sdl.Tridion.Api.Client/Queries/BinaryComponentByUrl.graphql index 54bacb0..bbf013e 100644 --- a/net/src/Sdl.Tridion.Api.Client/Queries/BinaryComponentByUrl.graphql +++ b/net/src/Sdl.Tridion.Api.Client/Queries/BinaryComponentByUrl.graphql @@ -1,4 +1,4 @@ -query binaryComponent($namespaceId: Int!, $publicationId: Int!, $url: String, $contextData: [InputClaimValue!]) { +query binaryComponent($namespaceId: Int!, $publicationId: Int!, $url: String, $contextData: [InputClaimValue]) { binaryComponent(namespaceId: $namespaceId, publicationId: $publicationId, url: $url, contextData: $contextData) { ...ItemFields ...BinaryComponentFields diff --git a/net/src/Sdl.Tridion.Api.Client/Queries/ComponentPresentation.graphql b/net/src/Sdl.Tridion.Api.Client/Queries/ComponentPresentation.graphql index 5bead29..ee73cb5 100644 --- a/net/src/Sdl.Tridion.Api.Client/Queries/ComponentPresentation.graphql +++ b/net/src/Sdl.Tridion.Api.Client/Queries/ComponentPresentation.graphql @@ -1,4 +1,4 @@ -query componentPresentation($namespaceId: Int!, $publicationId: Int!, $componentId: Int!, $templateId: Int!, $contextData: [InputClaimValue!]) { +query componentPresentation($namespaceId: Int!, $publicationId: Int!, $componentId: Int!, $templateId: Int!, $contextData: [InputClaimValue]) { componentPresentation(namespaceId: $namespaceId, publicationId: $publicationId, componentId: $componentId, templateId: $templateId, contextData: $contextData) { ...ComponentPresentationFields } diff --git a/net/src/Sdl.Tridion.Api.Client/Queries/ComponentPresentations.graphql b/net/src/Sdl.Tridion.Api.Client/Queries/ComponentPresentations.graphql index 8e551ec..94384d4 100644 --- a/net/src/Sdl.Tridion.Api.Client/Queries/ComponentPresentations.graphql +++ b/net/src/Sdl.Tridion.Api.Client/Queries/ComponentPresentations.graphql @@ -1,4 +1,4 @@ -query componentPresentations($namespaceId: Int!, $publicationId: Int!, $first: Int, $after: String, $filter: InputComponentPresentationFilter!, $inputSortParam: InputSortParam, $contextData: [InputClaimValue!]) { +query componentPresentations($namespaceId: Int!, $publicationId: Int!, $first: Int, $after: String, $filter: InputComponentPresentationFilter!, $inputSortParam: InputSortParam, $contextData: [InputClaimValue]) { componentPresentations(namespaceId: $namespaceId, publicationId: $publicationId, first: $first, after: $after, filter: $filter, sort: $inputSortParam, contextData: $contextData) { edges { cursor diff --git a/net/src/Sdl.Tridion.Api.Client/Queries/EntityModelById.graphql b/net/src/Sdl.Tridion.Api.Client/Queries/EntityModelById.graphql index 1df95af..424964f 100644 --- a/net/src/Sdl.Tridion.Api.Client/Queries/EntityModelById.graphql +++ b/net/src/Sdl.Tridion.Api.Client/Queries/EntityModelById.graphql @@ -1,4 +1,4 @@ -query componentPresentation($namespaceId: Int!, $publicationId: Int!, $componentId: Int!, $templateId: Int!, $contextData: [InputClaimValue!]) { +query componentPresentation($namespaceId: Int!, $publicationId: Int!, $componentId: Int!, $templateId: Int!, $contextData: [InputClaimValue]) { componentPresentation(namespaceId: $namespaceId, publicationId: $publicationId, componentId: $componentId, templateId: $templateId, contextData: $contextData) { itemId includeContent? { diff --git a/net/src/Sdl.Tridion.Api.Client/Queries/ItemQuery.graphql b/net/src/Sdl.Tridion.Api.Client/Queries/ItemQuery.graphql index faf58c7..6dc4ae4 100644 --- a/net/src/Sdl.Tridion.Api.Client/Queries/ItemQuery.graphql +++ b/net/src/Sdl.Tridion.Api.Client/Queries/ItemQuery.graphql @@ -1,4 +1,4 @@ -query items($first: Int, $after: String, $inputItemFilter: InputItemFilter!, $inputSortParam: InputSortParam, $contextData: [InputClaimValue!]) { +query items($first: Int, $after: String, $inputItemFilter: InputItemFilter!, $inputSortParam: InputSortParam, $contextData: [InputClaimValue]) { items(first: $first, after: $after, filter: $inputItemFilter, sort: $inputSortParam, contextData: $contextData) { edges { cursor diff --git a/net/src/Sdl.Tridion.Api.Client/Queries/PageByCmUri.graphql b/net/src/Sdl.Tridion.Api.Client/Queries/PageByCmUri.graphql index 080253e..c014a87 100644 --- a/net/src/Sdl.Tridion.Api.Client/Queries/PageByCmUri.graphql +++ b/net/src/Sdl.Tridion.Api.Client/Queries/PageByCmUri.graphql @@ -1,4 +1,4 @@ -query page($namespaceId: Int!, $publicationId: Int!, $cmUri: String, $contextData: [InputClaimValue!]) { +query page($namespaceId: Int!, $publicationId: Int!, $cmUri: String, $contextData: [InputClaimValue]) { page(namespaceId: $namespaceId, publicationId: $publicationId, cmUri: $cmUri, contextData: $contextData) { ...PageItemFields diff --git a/net/src/Sdl.Tridion.Api.Client/Queries/PageById.graphql b/net/src/Sdl.Tridion.Api.Client/Queries/PageById.graphql index d706787..ba3221c 100644 --- a/net/src/Sdl.Tridion.Api.Client/Queries/PageById.graphql +++ b/net/src/Sdl.Tridion.Api.Client/Queries/PageById.graphql @@ -1,4 +1,4 @@ -query page($namespaceId: Int!, $publicationId: Int!, $pageId: Int!, $contextData: [InputClaimValue!]) { +query page($namespaceId: Int!, $publicationId: Int!, $pageId: Int!, $contextData: [InputClaimValue]) { page(namespaceId: $namespaceId, publicationId: $publicationId, pageId: $pageId, contextData: $contextData) { ...PageItemFields diff --git a/net/src/Sdl.Tridion.Api.Client/Queries/PageByUrl.graphql b/net/src/Sdl.Tridion.Api.Client/Queries/PageByUrl.graphql index 22e8984..ba993fd 100644 --- a/net/src/Sdl.Tridion.Api.Client/Queries/PageByUrl.graphql +++ b/net/src/Sdl.Tridion.Api.Client/Queries/PageByUrl.graphql @@ -1,4 +1,4 @@ -query page($namespaceId: Int!, $publicationId: Int!, $url: String, $contextData: [InputClaimValue!]) { +query page($namespaceId: Int!, $publicationId: Int!, $url: String, $contextData: [InputClaimValue]) { page(namespaceId: $namespaceId, publicationId: $publicationId, url: $url, contextData: $contextData) { ...PageItemFields diff --git a/net/src/Sdl.Tridion.Api.Client/Queries/PageModelById.graphql b/net/src/Sdl.Tridion.Api.Client/Queries/PageModelById.graphql index 5daa169..7fe8185 100644 --- a/net/src/Sdl.Tridion.Api.Client/Queries/PageModelById.graphql +++ b/net/src/Sdl.Tridion.Api.Client/Queries/PageModelById.graphql @@ -1,4 +1,4 @@ -query page($pageId: Int!, $namespaceId: Int!, $publicationId: Int!, $contextData: [InputClaimValue!]) { +query page($pageId: Int!, $namespaceId: Int!, $publicationId: Int!, $contextData: [InputClaimValue]) { page(pageId: $pageId, namespaceId: $namespaceId, publicationId: $publicationId, contextData: $contextData) { itemId includeContent? { diff --git a/net/src/Sdl.Tridion.Api.Client/Queries/PageModelByUrl.graphql b/net/src/Sdl.Tridion.Api.Client/Queries/PageModelByUrl.graphql index 918bc6c..33301db 100644 --- a/net/src/Sdl.Tridion.Api.Client/Queries/PageModelByUrl.graphql +++ b/net/src/Sdl.Tridion.Api.Client/Queries/PageModelByUrl.graphql @@ -1,4 +1,4 @@ -query page($namespaceId: Int!, $publicationId: Int!, $url: String, $contextData: [InputClaimValue!]) { +query page($namespaceId: Int!, $publicationId: Int!, $url: String, $contextData: [InputClaimValue]) { page(namespaceId: $namespaceId, publicationId: $publicationId, url: $url, contextData: $contextData) { itemId includeContent? { diff --git a/net/src/Sdl.Tridion.Api.Client/Queries/PagesByUrl.graphql b/net/src/Sdl.Tridion.Api.Client/Queries/PagesByUrl.graphql index 40ff21b..c5a6549 100644 --- a/net/src/Sdl.Tridion.Api.Client/Queries/PagesByUrl.graphql +++ b/net/src/Sdl.Tridion.Api.Client/Queries/PagesByUrl.graphql @@ -1,4 +1,4 @@ -query pages($namespaceId: Int!, $first: Int, $after: String, $url: String!, $contextData: [InputClaimValue!]) { +query pages($namespaceId: Int!, $first: Int, $after: String, $url: String!, $contextData: [InputClaimValue]) { pages(namespaceId: $namespaceId, first: $first, after: $after, url: $url, contextData: $contextData) { edges { cursor diff --git a/net/src/Sdl.Tridion.Api.Client/Queries/Publication.graphql b/net/src/Sdl.Tridion.Api.Client/Queries/Publication.graphql index 33bb14a..6389d3b 100644 --- a/net/src/Sdl.Tridion.Api.Client/Queries/Publication.graphql +++ b/net/src/Sdl.Tridion.Api.Client/Queries/Publication.graphql @@ -1,4 +1,4 @@ -query publication($namespaceId: Int!, $publicationId: Int!, $contextData: [InputClaimValue!]) { +query publication($namespaceId: Int!, $publicationId: Int!, $contextData: [InputClaimValue]) { publication(namespaceId: $namespaceId, publicationId: $publicationId, contextData: $contextData) { ...ItemFields ...PublicationFields diff --git a/net/src/Sdl.Tridion.Api.Client/Queries/Publications.graphql b/net/src/Sdl.Tridion.Api.Client/Queries/Publications.graphql index 3c75515..47fa89d 100644 --- a/net/src/Sdl.Tridion.Api.Client/Queries/Publications.graphql +++ b/net/src/Sdl.Tridion.Api.Client/Queries/Publications.graphql @@ -1,4 +1,4 @@ -query publications($namespaceId: Int!, $first: Int, $after: String, $filter: InputPublicationFilter, $contextData: [InputClaimValue!]) { +query publications($namespaceId: Int!, $first: Int, $after: String, $filter: InputPublicationFilter, $contextData: [InputClaimValue]) { publications(namespaceId: $namespaceId, first: $first, after: $after, filter: $filter, contextData: $contextData) { edges { cursor diff --git a/net/src/Sdl.Tridion.Api.Client/Queries/Sitemap.graphql b/net/src/Sdl.Tridion.Api.Client/Queries/Sitemap.graphql index 42afdd3..0358191 100644 --- a/net/src/Sdl.Tridion.Api.Client/Queries/Sitemap.graphql +++ b/net/src/Sdl.Tridion.Api.Client/Queries/Sitemap.graphql @@ -1,4 +1,4 @@ -query sitemap($namespaceId: Int!, $publicationId: Int!, $contextData: [InputClaimValue!]) { +query sitemap($namespaceId: Int!, $publicationId: Int!, $contextData: [InputClaimValue]) { sitemap(namespaceId: $namespaceId, publicationId: $publicationId, contextData: $contextData) { ...TaxonomyItemFields ...RecurseItems diff --git a/net/src/Sdl.Tridion.Api.Client/Queries/SitemapSubtree.graphql b/net/src/Sdl.Tridion.Api.Client/Queries/SitemapSubtree.graphql index 2fca359..6ae40b7 100644 --- a/net/src/Sdl.Tridion.Api.Client/Queries/SitemapSubtree.graphql +++ b/net/src/Sdl.Tridion.Api.Client/Queries/SitemapSubtree.graphql @@ -1,4 +1,4 @@ -query sitemapSubtree($namespaceId: Int!, $publicationId: Int!, $taxonomyNodeId: String, $ancestor: Ancestor, $contextData: [InputClaimValue!]) { +query sitemapSubtree($namespaceId: Int!, $publicationId: Int!, $taxonomyNodeId: String, $ancestor: Ancestor, $contextData: [InputClaimValue]) { sitemapSubtree(namespaceId: $namespaceId, publicationId: $publicationId, taxonomyNodeId: $taxonomyNodeId, ancestor: $ancestor, contextData: $contextData) { ...TaxonomyItemFields ...RecurseItems diff --git a/net/src/Sdl.Tridion.Api.Client/Queries/SitemapSubtreeNoRecurse.graphql b/net/src/Sdl.Tridion.Api.Client/Queries/SitemapSubtreeNoRecurse.graphql index c153002..07b91b5 100644 --- a/net/src/Sdl.Tridion.Api.Client/Queries/SitemapSubtreeNoRecurse.graphql +++ b/net/src/Sdl.Tridion.Api.Client/Queries/SitemapSubtreeNoRecurse.graphql @@ -1,4 +1,4 @@ -query sitemapSubtree($namespaceId: Int!, $publicationId: Int!, $taxonomyNodeId: String, $ancestor: Ancestor, $contextData: [InputClaimValue!]) { +query sitemapSubtree($namespaceId: Int!, $publicationId: Int!, $taxonomyNodeId: String, $ancestor: Ancestor, $contextData: [InputClaimValue]) { sitemapSubtree(namespaceId: $namespaceId, publicationId: $publicationId, taxonomyNodeId: $taxonomyNodeId, ancestor: $ancestor, contextData: $contextData) { ...TaxonomyItemFields } From a0c0069ea967d2d2829a01baa8782308ef324f5c Mon Sep 17 00:00:00 2001 From: Neil Gibbons Date: Thu, 3 Nov 2022 08:00:43 +0000 Subject: [PATCH 06/10] Extended sort to include CUSTOM_META --- net/sln/Sdl.Tridion.Api.Client.Tests.sln | 25 +++++++++++++++++++ .../MockGraphQLClient.cs | 1 + .../TestPublicContentApi.cs | 25 +++++++++++++++++++ .../ContentModel/ContentModel.cs | 15 ++++++++++- 4 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 net/sln/Sdl.Tridion.Api.Client.Tests.sln diff --git a/net/sln/Sdl.Tridion.Api.Client.Tests.sln b/net/sln/Sdl.Tridion.Api.Client.Tests.sln new file mode 100644 index 0000000..87610c4 --- /dev/null +++ b/net/sln/Sdl.Tridion.Api.Client.Tests.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.32802.440 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sdl.Tridion.Api.Client.Tests", "..\src\Sdl.Tridion.Api.Client.Tests\Sdl.Tridion.Api.Client.Tests.csproj", "{28B0C39E-749E-4AED-87D6-84A78783D47F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {28B0C39E-749E-4AED-87D6-84A78783D47F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28B0C39E-749E-4AED-87D6-84A78783D47F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28B0C39E-749E-4AED-87D6-84A78783D47F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28B0C39E-749E-4AED-87D6-84A78783D47F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A8491C8F-ADA3-4779-B46F-044B6BAB646D} + EndGlobalSection +EndGlobal diff --git a/net/src/Sdl.Tridion.Api.Client.Tests/MockGraphQLClient.cs b/net/src/Sdl.Tridion.Api.Client.Tests/MockGraphQLClient.cs index a6323e6..583fde3 100644 --- a/net/src/Sdl.Tridion.Api.Client.Tests/MockGraphQLClient.cs +++ b/net/src/Sdl.Tridion.Api.Client.Tests/MockGraphQLClient.cs @@ -44,5 +44,6 @@ public Task SchemaAsync() } public List LastErrors { get; } + public int RetryCount { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } } } diff --git a/net/src/Sdl.Tridion.Api.Client.Tests/TestPublicContentApi.cs b/net/src/Sdl.Tridion.Api.Client.Tests/TestPublicContentApi.cs index 96857f9..c2d0d1f 100644 --- a/net/src/Sdl.Tridion.Api.Client.Tests/TestPublicContentApi.cs +++ b/net/src/Sdl.Tridion.Api.Client.Tests/TestPublicContentApi.cs @@ -57,6 +57,7 @@ public Task SchemaAsync() } public List LastErrors { get; } + public int RetryCount { get => throw new System.NotImplementedException(); set => throw new System.NotImplementedException(); } private void ValidateRequest(IGraphQLRequest request) { @@ -122,6 +123,30 @@ public void TestGlobalContextData() var client = CreateClient(new MockGraphQLClient(expected)); + InputItemFilter filters = new InputItemFilter + { + ItemTypes = new List {FilterItemType.COMPONENT}, + Schema = new InputSchemaCriteria { Id = 5309 }, + PublicationIds = new List {14} + }; + + List orList = new List(); + InputItemFilter inputItemFilterCustomMeta = new InputItemFilter(); + inputItemFilterCustomMeta.CustomMeta = new InputCustomMetaCriteria { Key = "solutionCategory", Scope = CriteriaScope.Item, Value = "Hello" }; + orList.Add(inputItemFilterCustomMeta); + filters.And = orList; + + InputSortParam sort = new InputSortParam + { + Order = SortOrderType.Descending, + SortBy = SortFieldType.CUSTOM_META, + KeyType = SortKeyType.DATE, + Key = "dateSort" + }; + + client.ExecuteItemQuery(filters, sort, new Pagination() {First = 5}, null, ContentIncludeMode.Exclude, false, null); + + client.GetBinaryComponent(ContentNamespace.Sites, 1, "/", null, claims); client.GlobalContextData = claims; diff --git a/net/src/Sdl.Tridion.Api.Client/ContentModel/ContentModel.cs b/net/src/Sdl.Tridion.Api.Client/ContentModel/ContentModel.cs index ffaa51c..9558109 100644 --- a/net/src/Sdl.Tridion.Api.Client/ContentModel/ContentModel.cs +++ b/net/src/Sdl.Tridion.Api.Client/ContentModel/ContentModel.cs @@ -1375,8 +1375,19 @@ public class InputSortParam /// The item field used for sorting /// public SortFieldType SortBy { get; set; } + + public SortKeyType KeyType { get; set; } + public string Key { get; set; } } + [JsonConverter(typeof(StringEnumConverter))] + public enum SortKeyType + { + DATE, + FLOAT, + STRING + } + /// /// Represents a type of natural sort: descending or ascending /// @@ -1442,7 +1453,9 @@ public enum SortFieldType /// TITLE, - UPDATED_DATE + UPDATED_DATE, + + CUSTOM_META } /// From 3d12fb1b0f4b69bb4f508ac9719fe83ef225a1ba Mon Sep 17 00:00:00 2001 From: Paul Adams Date: Tue, 21 Mar 2023 12:40:47 +0000 Subject: [PATCH 07/10] UDP-10777 : Exposed search API to content model and provided simple seach query --- net/BuildGraphQLModel.cmd | 2 +- net/src/Sdl.Tridion.Api.Client/ApiClient.cs | 22 + .../ContentModel/ContentModel.cs | 601 +++++++++++++++++- .../Sdl.Tridion.Api.Client/GraphQLRequests.cs | 13 + net/src/Sdl.Tridion.Api.Client/IApiClient.cs | 10 + .../Queries/SearchByRawCriteria.graphql | 38 ++ .../Sdl.Tridion.Api.Client.csproj | 1 + 7 files changed, 685 insertions(+), 2 deletions(-) create mode 100644 net/src/Sdl.Tridion.Api.Client/Queries/SearchByRawCriteria.graphql diff --git a/net/BuildGraphQLModel.cmd b/net/BuildGraphQLModel.cmd index 2d02e7e..58e76e9 100644 --- a/net/BuildGraphQLModel.cmd +++ b/net/BuildGraphQLModel.cmd @@ -1,3 +1,3 @@ @echo off msbuild sln\BuildGraphQLModel.sln -src\BuildGraphQLModel\bin\Debug\BuildGraphQLModel.exe -ns Sdl.Tridion.Api.Client.ContentModel -e http://localhost:8081/udp/content -o src\Sdl.Tridion.Api.Client\ContentModel\ContentModel.cs -f cs \ No newline at end of file +src\BuildGraphQLModel\bin\Debug\BuildGraphQLModel.exe -ns Sdl.Tridion.Api.Client.ContentModel -e http://localhost:8081/cd/api -o src\Sdl.Tridion.Api.Client\ContentModel\ContentModel.cs -f cs \ No newline at end of file diff --git a/net/src/Sdl.Tridion.Api.Client/ApiClient.cs b/net/src/Sdl.Tridion.Api.Client/ApiClient.cs index d0c07e8..6a01175 100644 --- a/net/src/Sdl.Tridion.Api.Client/ApiClient.cs +++ b/net/src/Sdl.Tridion.Api.Client/ApiClient.cs @@ -327,6 +327,28 @@ public List GetSitemapSubtree(ContentNamespace ns, int publ } } + /// + /// Search by raw criteria + /// + /// Raw criteria DSL generated by IqQuery API + /// Result filter + /// Pagination + /// Search results + public FacetedSearchResults SearchByRawCriteria(string rawCriteria, InputResultFilter resultFilter, IPagination pagination) + { + try + { + var response = + _client.Execute(GraphQLRequests.SearchByRawCriteria(rawCriteria, resultFilter, pagination)); + return response.TypedResponseData.Search; + } + catch (RuntimeBinderException e) + { + throw new ApiException( + $"Failed to get search results (rawCriteria:{rawCriteria})", e); + } + } + #endregion #region IPublicContentApiAsync diff --git a/net/src/Sdl.Tridion.Api.Client/ContentModel/ContentModel.cs b/net/src/Sdl.Tridion.Api.Client/ContentModel/ContentModel.cs index 9558109..2d45991 100644 --- a/net/src/Sdl.Tridion.Api.Client/ContentModel/ContentModel.cs +++ b/net/src/Sdl.Tridion.Api.Client/ContentModel/ContentModel.cs @@ -1,4 +1,4 @@ -// This file was generated by a tool on 25/10/2018 09:36:50 +// This file was generated by a tool on 20/03/2023 12:50:12 using System.Collections; using System.Collections.Generic; using Newtonsoft.Json; @@ -105,6 +105,11 @@ public class ContentQuery /// Get sitemap subtree /// public List SitemapSubtree { get; set; } + + /// + /// Faceted search using a criteria. + /// + public FacetedSearchResults Search { get; set; } } /// @@ -2353,4 +2358,598 @@ public class ClaimValue public string Value { get; set; } } + /// + /// Represents a facet node. + /// + public interface IFacet + { + /// + /// Identifies the unique ID of the facet. + /// + string Id { get; set; } + } + + /// + /// Faceted search results. + /// + public class FacetedSearchResults + { + /// + /// Facets. + /// + public List Facets { get; set; } + + /// + /// Search results. + /// + public SearchResultsConnection Results { get; set; } + } + + /// + /// A connection to a list of items. + /// + public class SearchResultsConnection + { + /// + /// The total number of the hits + /// + public int? Hits { get; set; } + + /// + /// a list of edges + /// + public List Edges { get; set; } + + /// + /// details about this specific page + /// + public PageInfo PageInfo { get; set; } + } + + /// + /// An edge in a connection + /// + public class SearchResultsEdge + { + /// + /// The item at the end of the edge + /// + public SearchResults Node { get; set; } + + /// + /// cursor marks a unique position or index into the connection + /// + public string Cursor { get; set; } + } + + /// + /// This is the search result response that contains results from search and broker database. + /// + public class SearchResults + { + /// + /// This is the results from broker database. + /// + public List Broker { get; set; } + + /// + /// This is the results from query service. + /// + public Search Search { get; set; } + } + + public class Search + { + /// + /// The author of the search result. + /// + public string Author { get; set; } + + /// + /// The author of the binary file. + /// + public string BinaryAuthor { get; set; } + + /// + /// The binary content length of the search result. + /// + public long BinaryContentLength { get; set; } + + /// + /// The binary content type of the search result. + /// + public string BinaryContentType { get; set; } + + /// + /// The creation date of the binary file. + /// + public string BinaryCreatedDate { get; set; } + + /// + /// The binary file name of the search result. + /// + public string BinaryFileName { get; set; } + + /// + /// The language of the search result. (binary file) + /// + public string BinaryLanguage { get; set; } + + /// + /// The title of binary file. + /// + public string BinaryTitle { get; set; } + + /// + /// Concept schemes attached to a search result. + /// + public List ConceptSchemes { get; set; } + + /// + /// The creation date of the search result. + /// + public string CreatedDate { get; set; } + + /// + /// A map of fields defined on the search result. + /// + public IDictionary Fields { get; set; } + + /// + /// A map of highlighted search results. + /// + public IDictionary Highlighted { get; set; } + + /// + /// The search result identifier. + /// + public string Id { get; set; } + + /// + /// The item type of the search result. + /// + public Sdl.Tridion.Api.Client.ItemType ItemType { get; set; } + + /// + /// The locale of the search result. + /// + public string Locale { get; set; } + + /// + /// The location of the search result. + /// + public string Location { get; set; } + + /// + /// The content of the search result (indexed by locale). + /// + public string MainContentField { get; set; } + + /// + /// The major version of the search result. + /// + public string MajorVersion { get; set; } + + /// + /// The minor version of the search result. + /// + public string MinorVersion { get; set; } + + /// + /// The updated date of the search result. + /// + public string ModifiedDate { get; set; } + + /// + /// The namespace of the search result. + /// + public string Namespace { get; set; } + + /// + /// The publication ID of the search result. + /// + public int? PublicationId { get; set; } + + /// + /// The publication title of the search result. + /// + public string PublicationTitle { get; set; } + + /// + /// The raw content of the search result. + /// + public string RawContent { get; set; } + + /// + /// The title of the search result (indexed by locale). + /// + public string RawLanguageTitle { get; set; } + + /// + /// The schema id of the search result. + /// + public string SchemaId { get; set; } + + /// + /// Matching score of the result. + /// + public float Score { get; set; } + + /// + /// The url of the search result. + /// + public string Url { get; set; } + } + + public class Concept + { + /// + /// Returns the alternative labels for concept. + /// + public List AlternativeLabels { get; set; } + + /// + /// Returns the concept Id. These are case sensitive, so do not mix case when defining IDs. + /// + public string Id { get; set; } + + /// + /// Returns the concept label. + /// + public string Label { get; set; } + + /// + /// Returns the narrower concepts. + /// + public TaxonomyNarrowerConceptsConnection NarrowerConcepts { get; set; } + + /// + /// Returns the parent concept Id graph. + /// + public List ParentConceptIdsGraph { get; set; } + + /// + /// Returns the parent concept Uri graph. + /// + public List ParentConceptsGraph { get; set; } + + /// + /// Returns the related concept Ids graph. + /// + public List RelatedConceptIds { get; set; } + + /// + /// Returns the related concept labels. + /// + public List RelatedConceptLabels { get; set; } + + /// + /// Returns the related concepts. + /// + public TaxonomyRelatedConceptsConnection RelatedConcepts { get; set; } + + /// + /// Returns the concept Uri. + /// + public string Uri { get; set; } + } + + public class ConceptAggregation + { + /// + /// Returns the concept hits. + /// + public int? Count { get; set; } + + /// + /// Returns the concept Id. These are case sensitive, so do not mix case when defining IDs. + /// + public string Id { get; set; } + + /// + /// Returns the concept label. + /// + public string Label { get; set; } + + /// + /// Returns the concept URI. + /// + public string Uri { get; set; } + } + + /// + /// Represents a concept facet. + /// + public class ConceptFacet : IFacet + { + /// + /// Identifies the unique ID of the facet. + /// + public string Id { get; set; } + + /// + /// Concepts. + /// + public List Concepts { get; set; } + + /// + /// Connector ID. + /// + public string ConnectorId { get; set; } + + /// + /// Concept scheme title. + /// + public string Title { get; set; } + + /// + /// Concept scheme URI. + /// + public string Uri { get; set; } + } + + /// + /// Concept Scheme. + /// + public class ConceptScheme + { + /// + /// Returns the default language for this concept scheme. + /// + public string DefaultLanguage { get; set; } + + /// + /// Returns the concept scheme language. + /// + public string Language { get; set; } + + /// + /// Returns the top-level concepts (no parents) for this concept scheme. + /// + public TaxonomyTopConceptsSearchResultsConnection TopConcepts { get; set; } + + /// + /// Returns the results of a concept search within this particular concept scheme. + /// + public List Concepts { get; set; } + + /// + /// Returns the connector Id for this concept scheme. + /// + public string ConnectorId { get; set; } + + /// + /// Returns the concept scheme title. + /// + public string Title { get; set; } + + /// + /// Returns the concept scheme uri. + /// + public string Uri { get; set; } + } + + public class ConceptSuggestion + { + /// + /// Returns the alternative labels for concept. + /// + public List AlternativeLabels { get; set; } + + /// + /// Returns the connector Id. + /// + public string ConnectorId { get; set; } + + /// + /// Returns number of documents marked with concept. + /// + public int? Count { get; set; } + + /// + /// Returns the concept highlighted label. + /// + public List Highlight { get; set; } + + /// + /// Returns the concept Id. These are case sensitive, so do not mix case when defining IDs. + /// + public string Id { get; set; } + + /// + /// Returns the concept label. + /// + public string Label { get; set; } + + /// + /// Returns the narrower concepts. + /// + public TaxonomyNarrowerConceptsConnection NarrowerConcepts { get; set; } + + /// + /// Returns the parent concept Id graph. + /// + public List ParentConceptIdsGraph { get; set; } + + /// + /// Returns the parent concept Uri graph. + /// + public List ParentConceptsGraph { get; set; } + + /// + /// Returns the related concept Ids graph. + /// + public List RelatedConceptIds { get; set; } + + /// + /// Returns the related concept labels. + /// + public List RelatedConceptLabels { get; set; } + + /// + /// Returns the related concepts. + /// + public TaxonomyRelatedConceptsConnection RelatedConcepts { get; set; } + + /// + /// Returns the concept Uri. + /// + public string Uri { get; set; } + } + + /// + /// A connection to a list of items. + /// + public class ConceptSuggestionConnection + { + /// + /// a list of edges + /// + public List Edges { get; set; } + } + + /// + /// An edge in a connection + /// + public class ConceptSuggestionEdge + { + /// + /// The item at the end of the edge + /// + public ConceptSuggestion Node { get; set; } + + /// + /// cursor marks a unique position or index into the connection + /// + public string Cursor { get; set; } + } + + /// + /// A connection to a list of items. + /// + public class TaxonomyRelatedConceptsConnection + { + /// + /// a list of edges + /// + public List Edges { get; set; } + } + + /// + /// An edge in a connection + /// + public class TaxonomyRelatedConceptsEdge + { + /// + /// The item at the end of the edge + /// + public Concept Node { get; set; } + + /// + /// cursor marks a unique position or index into the connection + /// + public string Cursor { get; set; } + } + + /// + /// A connection to a list of items. + /// + public class TaxonomyNarrowerConceptsConnection + { + /// + /// a list of edges + /// + public List Edges { get; set; } + } + + /// + /// An edge in a connection + /// + public class TaxonomyNarrowerConceptsEdge + { + /// + /// The item at the end of the edge + /// + public Concept Node { get; set; } + + /// + /// cursor marks a unique position or index into the connection + /// + public string Cursor { get; set; } + } + + /// + /// A connection to a list of items. + /// + public class TaxonomyTopConceptsSearchResultsConnection + { + /// + /// a list of edges + /// + public List Edges { get; set; } + } + + /// + /// An edge in a connection + /// + public class TaxonomyTopConceptsSearchResultsEdge + { + /// + /// The item at the end of the edge + /// + public Concept Node { get; set; } + + /// + /// cursor marks a unique position or index into the connection + /// + public string Cursor { get; set; } + } + + /// + /// Information about pagination in a connection. + /// + public class PageInfo + { + /// + /// When paginating forwards, are there more items? + /// + public bool HasNextPage { get; set; } + + /// + /// When paginating backwards, are there more items? + /// + public bool HasPreviousPage { get; set; } + + /// + /// When paginating backwards, the cursor to continue. + /// + public string StartCursor { get; set; } + + /// + /// When paginating forwards, the cursor to continue. + /// + public string EndCursor { get; set; } + } + + /// + /// Filtering and highlighting the search results + /// + public class InputResultFilter + { + /// + /// Fields that will be excluded from results. + /// + public List ExcludeFields { get; set; } + + /// + /// Parameter to enable highlight in all. + /// + public bool? HighlightInAllIsEnabled { get; set; } + + /// + /// Parameter to enable highlight. + /// + public bool? HighlightingIsEnabled { get; set; } + } + } diff --git a/net/src/Sdl.Tridion.Api.Client/GraphQLRequests.cs b/net/src/Sdl.Tridion.Api.Client/GraphQLRequests.cs index f400eca..a4cee48 100644 --- a/net/src/Sdl.Tridion.Api.Client/GraphQLRequests.cs +++ b/net/src/Sdl.Tridion.Api.Client/GraphQLRequests.cs @@ -304,6 +304,19 @@ public static IGraphQLRequest SitemapSubtree(ContentNamespace ns, int publicatio .Build(); } + public static IGraphQLRequest SearchByRawCriteria(string rawCritera, InputResultFilter resultFilter, IPagination pagination) + { + QueryBuilder builder = + new QueryBuilder().WithQueryResource("SearchByRawCriteria", false); + + return + builder + .WithVariable("rawCriteria", rawCritera) + .WithVariable("inputResultFilter", resultFilter) + .WithPagination(pagination) + .Build(); + } + #region Query Builder Helpers public static ClaimValue CreateClaim(ModelServiceLinkRendering linkRendering) => new ClaimValue diff --git a/net/src/Sdl.Tridion.Api.Client/IApiClient.cs b/net/src/Sdl.Tridion.Api.Client/IApiClient.cs index 9182a45..8bd7c07 100644 --- a/net/src/Sdl.Tridion.Api.Client/IApiClient.cs +++ b/net/src/Sdl.Tridion.Api.Client/IApiClient.cs @@ -350,5 +350,15 @@ TaxonomySitemapItem GetSitemap(ContentNamespace ns, int publicationId, int desce List GetSitemapSubtree(ContentNamespace ns, int publicationId, string taxonomyNodeId, int descendantLevels, Ancestor ancestor, IContextData contextData); + + + /// + /// Search by raw criteria + /// + /// Raw criteria DSL generated by IqQuery API + /// Result filter + /// Pagination + /// Search results + FacetedSearchResults SearchByRawCriteria(string rawCriteria, InputResultFilter resultFilter, IPagination pagination); } } \ No newline at end of file diff --git a/net/src/Sdl.Tridion.Api.Client/Queries/SearchByRawCriteria.graphql b/net/src/Sdl.Tridion.Api.Client/Queries/SearchByRawCriteria.graphql new file mode 100644 index 0000000..ad3b205 --- /dev/null +++ b/net/src/Sdl.Tridion.Api.Client/Queries/SearchByRawCriteria.graphql @@ -0,0 +1,38 @@ +query search($first: Int, $after: String, $rawCriteria: String, $inputResultFilter: InputResultFilter) { + search(rawCriteria: $rawCriteria, resultFilter: $inputResultFilter ) { + results(first: $first, after: $after) { + hits + edges { + node { + search { + id + author + binaryAuthor + binaryContentType + binaryCreatedDate + binaryFileName + binaryLanguage + binaryTitle + createdDate + fields + highlighted + itemType + locale + location + mainContentField + majorVersion + minorVersion + modifiedDate + namespace + publicationId + publicationTitle + rawLanguageTitle + schemaId + score + url + } + } + } + } + } +} \ No newline at end of file diff --git a/net/src/Sdl.Tridion.Api.Client/Sdl.Tridion.Api.Client.csproj b/net/src/Sdl.Tridion.Api.Client/Sdl.Tridion.Api.Client.csproj index 792f3ec..08fbc07 100644 --- a/net/src/Sdl.Tridion.Api.Client/Sdl.Tridion.Api.Client.csproj +++ b/net/src/Sdl.Tridion.Api.Client/Sdl.Tridion.Api.Client.csproj @@ -207,6 +207,7 @@ +