How to deserialize Graphql Response

How to deserialize Graphql Response


0

Hi I have a graphql Response after Mutating

{{
 "carCreate": {
   "car": {
     "id": "TestId"
   }
 }
}}

I want to Desealize it I am using The following Code

var graphQlClient = new GraphQLHttpClient(AppConfig.GraphQlUrl, new NewtonsoftJsonSerializer());

I have tried to resolve with the following code

var response = await graphQlClient.SendMutationAsync<CarCreate>(request);

My Created Model is :

 public class Car
    {
        public string Id { get; set; }
    }
public class CarCreate
    {
        public Car Car { get; set; }
    }

Share
Improve this question

1 Answer
1

Reset to default


1

Your class should be something like this,

// Root myDeserializedClass = JsonConvert.DeserializeObject<Root>(myJsonResponse);
    public class Car
    {
        public string id { get; set; }
    }

    public class CarCreate
    {
        public Car car { get; set; }
    }

    public class Root
    {
        public CarCreate carCreate { get; set; }
    }

Share
Improve this answer



Leave a Reply

Your email address will not be published. Required fields are marked *