In this article we are going to see how we can do a Mutation in GraphQL in your .NET app, you will be able to find more documentation about mutations here: http://graphql.org/learn/queries/
We will be using the same endpoints and example as in the previous article:
Using GraphQL in your Windows Application part I [UWP,NET,GraphQL]
Just like the previous article related to querying GraphQL, you will need a text file that will hold a JSON mutation query as follow:
Next we will need to create a Class what will hold the variables that we will pass in our query:
Here are the string const that we will be using:
Doing a mutation on GraphQL is very much like doing a classic GET HTTP GraphQL query but you also need to pass variable in the query. You will need to intenciante the QueryAddToFavBooksMutationModel class with the correct value so that you can add the correct book to your favorites. Next you will convert the class to JSON and pass this it to your query as follows:
And there you have it you can now do mutations on GraphQL. This could be greatly improved, however for our example this gets the job done.