From 6567b0a6d798f21bb6222cd4f8bb4534be8c7be7 Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 10 Dec 2024 11:51:04 +1100 Subject: [PATCH] Add non generic version of GraphService.SendAsync() --- ShopifySharp/Services/Graph/GraphService.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ShopifySharp/Services/Graph/GraphService.cs b/ShopifySharp/Services/Graph/GraphService.cs index 2d485f0ce..3085841af 100644 --- a/ShopifySharp/Services/Graph/GraphService.cs +++ b/ShopifySharp/Services/Graph/GraphService.cs @@ -79,10 +79,20 @@ public virtual Task SendAsync(string graphqlQuery, int? graphq /// public virtual async Task SendAsync(GraphRequest request, int? graphqlQueryCost = null, CancellationToken cancellationToken = default) where TResult : class + { + return (TResult)await SendAsync(request, typeof(TResult), graphqlQueryCost, cancellationToken); + } + + public virtual Task SendAsync(string graphqlQuery, Type resultType, int? graphqlQueryCost = null, CancellationToken cancellationToken = default) + { + return SendAsync(new GraphRequest { query = graphqlQuery }, resultType, graphqlQueryCost, cancellationToken); + } + + public virtual async Task SendAsync(GraphRequest request, Type resultType, int? graphqlQueryCost = null, CancellationToken cancellationToken = default) { var elt = await this.SendAsync(request, graphqlQueryCost, cancellationToken); var ptyElt = elt.EnumerateObject().Single().Value; - return GraphQL.Serializer.Deserialize(ptyElt.GetRawText()); + return GraphQL.Serializer.Deserialize(ptyElt.GetRawText(), resultType); } #endif