/// <summary>
        /// Execute a GraphQL request (async)
        /// </summary>
        /// <param name="request">Fully built GraphQL request</param>
        /// <returns>GraphQL Response</returns>
        public async Task <IGraphQLResponse> ExecuteAsync(IGraphQLRequest graphQLrequest,
                                                          CancellationToken cancellationToken = default(CancellationToken))
        {
            try
            {
                var response =
                    await
                    _httpClient.ExecuteAsync <GraphQLResponse>(CreateHttpRequest(graphQLrequest), cancellationToken).ConfigureAwait(false);

                var responseData = response.ResponseData;
                if (responseData == null)
                {
                    throw new GraphQLClientException(response);
                }
                responseData.Headers = response.Headers;
                HandleErrors(responseData);
                if (Logger.IsTracingEnabled)
                {
                    Logger.Trace($"GraphQL Respose: {responseData.Data}");
                }
                return(responseData);
            }
            catch (GraphQLClientException)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new GraphQLClientException(e.Message, e);
            }
        }
 /// <summary>
 /// Execute a GraphQL request
 /// </summary>
 /// <param name="request">Fully built GraphQL request</param>
 /// <returns>GraphQL Response</returns>
 public IGraphQLResponse Execute(IGraphQLRequest graphQLrequest)
 {
     try
     {
         var response     = _httpClient.Execute <GraphQLResponse>(CreateHttpRequest(graphQLrequest));
         var responseData = response.ResponseData;
         if (responseData == null)
         {
             throw new GraphQLClientException(response);
         }
         responseData.Headers = response.Headers;
         HandleErrors(responseData);
         if (Logger.IsTracingEnabled)
         {
             Logger.Trace($"GraphQL Respose: {responseData.Data}");
         }
         return(responseData);
     }
     catch (GraphQLClientException)
     {
         throw;
     }
     catch (Exception e)
     {
         throw new GraphQLClientException(e.Message, e);
     }
 }
            private void ValidateRequest(IGraphQLRequest request)
            {
                Assert.AreEqual(request.Variables.Count, _expectedVariables.Count, "Variables are expected to be the same length.");

                foreach (var x in request.Variables)
                {
                    if (_expectedVariables.ContainsKey(x.Key))
                    {
                        if (x.Key == "contextData")
                        {
                            var a = request.Variables[x.Key] as List <ClaimValue>;
                            var b = _expectedVariables[x.Key] as List <ClaimValue>;
                            Assert.AreEqual(a.Count, b.Count, "ClaimValue count mismatch");
                            for (int i = 0; i < a.Count; i++)
                            {
                                Assert.AreEqual(a[i], b[i], "Claims dont match");
                            }
                        }
                        else
                        {
                            Assert.AreEqual(request.Variables[x.Key], _expectedVariables[x.Key],
                                            $"Variable value mismatch {x.Key}");
                        }
                    }
                    else
                    {
                        Assert.Fail("Excepted variable not found");
                    }
                }
            }
 public IGraphQLTypedResponse <T> Execute <T>(IGraphQLRequest request)
 {
     ValidateRequest(request);
     return(new GraphQLTypedResponse <T> {
         TypedResponseData = (T)((object)(new ContentQuery()))
     });
 }
 public IGraphQLResponse Execute(IGraphQLRequest request)
 {
     ValidateRequest(request);
     return(new GraphQLResponse {
         Data = new object()
     });
 }
 private IHttpClientRequest CreateHttpRequest(IGraphQLRequest graphQLrequest)
 =>
 new HttpClientRequest
 {
     ContentType = "application/json",
     Method      = "POST",
     Body        = graphQLrequest.Serialize(),
     Headers     = graphQLrequest.Headers,
     Binder      = graphQLrequest.Binder,
     Convertors  = graphQLrequest.Convertors
 };
        /// <summary>
        /// Execute a GraphQL request (async)
        /// </summary>
        /// <typeparam name="T">Target Type of response data</typeparam>
        /// <param name="request">GraphQL request</param>
        /// <returns>GraphQL Response</returns>
        public async Task <IGraphQLTypedResponse <T> > ExecuteAsync <T>(IGraphQLRequest graphQLrequest,
                                                                        CancellationToken cancellationToken = default(CancellationToken))
        {
            try
            {
                var response =
                    await
                    _httpClient.ExecuteAsync <GraphQLTypedResponse <T> >(CreateHttpRequest(graphQLrequest),
                                                                         cancellationToken).ConfigureAwait(false);

                var responseData = response.ResponseData;
                if (responseData == null)
                {
                    throw new GraphQLClientException(response);
                }
                responseData.Headers = response.Headers;
                HandleErrors(responseData);
                if (responseData.Data == null)
                {
                    throw new GraphQLClientException(response);
                }
                if (Logger.IsTracingEnabled)
                {
                    Logger.Trace($"GraphQL Respose: {responseData.Data}");
                }
                JsonSerializerSettings settings = new JsonSerializerSettings();
                if (graphQLrequest.Convertors == null || graphQLrequest.Convertors.Count <= 0)
                {
                    responseData.TypedResponseData = responseData.Data.ToObject <T>();
                }
                else
                {
                    foreach (var x in graphQLrequest.Convertors)
                    {
                        settings.Converters.Add(x);
                    }
                    responseData.TypedResponseData = JsonConvert.DeserializeObject <T>(responseData.Data.ToString(),
                                                                                       settings);
                }
                return(responseData);
            }
            catch (GraphQLClientException)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new GraphQLClientException(e.Message, e);
            }
        }
 public Task <IGraphQLTypedResponse <T> > ExecuteAsync <T>(IGraphQLRequest request,
                                                           CancellationToken cancellationToken)
 => _client.ExecuteAsync <T>(request, cancellationToken);
 public Task <IGraphQLResponse> ExecuteAsync(IGraphQLRequest request, CancellationToken cancellationToken)
 => _client.ExecuteAsync(request, cancellationToken);
 public IGraphQLTypedResponse <T> Execute <T>(IGraphQLRequest request)
 => _client.Execute <T>(request);
 public IGraphQLResponse Execute(IGraphQLRequest request)
 => _client.Execute(request);
 public Task <IGraphQLTypedResponse <T> > ExecuteAsync <T>(IGraphQLRequest request, CancellationToken cancellationToken)
 {
     throw new NotImplementedException();
 }
 public IGraphQLTypedResponse <T> Execute <T>(IGraphQLRequest request)
 {
     throw new NotImplementedException();
 }
 public IGraphQLResponse Execute(IGraphQLRequest request)
 {
     throw new NotImplementedException();
 }
 public Task <IGraphQLTypedResponse <T> > ExecuteAsync <T>(IGraphQLRequest request, CancellationToken cancellationToken)
 {
     ValidateRequest(request);
     return(null);
 }