Updated graphql package and changed insert job query to upsert BOD-198.

This commit is contained in:
Patrick Fic
2020-08-20 14:35:31 -07:00
parent 32ec745c77
commit 8766026263
7 changed files with 66 additions and 31 deletions

View File

@@ -1,22 +1,24 @@
using GraphQL.Client;
using GraphQL.Common.Request;
using GraphQL.Common.Response;
using GraphQL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GraphQL.Client.Http;
using GraphQL.Client.Serializer.Newtonsoft;
namespace BodyshopPartner.Utils
{
public static class GraphQL
{
private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
public static GraphQLClient CreateGQLClient()
public static GraphQLHttpClient CreateGQLClient()
{
var graphQLClient = new GraphQLClient("https://bodyshop-dev-db.herokuapp.com/v1/graphql");
graphQLClient.DefaultRequestHeaders.Add("Authorization", "Bearer " + Utils.Auth.authlink.FirebaseToken);
var graphQLClient = new GraphQLHttpClient("https://bodyshop-dev-db.herokuapp.com/v1/graphql", new NewtonsoftJsonSerializer());
graphQLClient.HttpClient.DefaultRequestHeaders.Add("Authorization", "Bearer " + Utils.Auth.authlink.FirebaseToken);
return graphQLClient;
}
@@ -25,9 +27,10 @@ namespace BodyshopPartner.Utils
using (var g = Utils.GraphQL.CreateGQLClient())
{
logger.Trace("Firing GQL Query: {0} {1}", r.Query.ToString(), r.Variables);
var graphQLResponse = await g.PostAsync(r);
var graphQLResponse = await g.SendQueryAsync<dynamic>(r);
if (graphQLResponse.Errors == null)
{
//logger.Trace("GQL Response: {0}", graphQLResponse.Data);
return graphQLResponse.Data;
}