I want to perform an integration test on my GraphQL mutation. I can run the query in my GraphiQL fine but don't really know how to translate this into the query string with the input for my xunit integration test.
Above is my GraphiQL that return me data fine. I have followed StarWars git hub project for the integration tests. Querying GraphQL working fine by passing the graphql query string but because of the lack of knowledge and documentation, I am unable to convert above GraphiQL mutation into the query string.
Following is my integration test code so far where the query variables part is missing and don't know how to bring them in
//Arrange
const string query = @"{
""query"": "" mutation CreateMutation($input: InputType!) {
addNewItem(myInput: $input) {
col1
col2
col3
col4
col5
}
} ""
}";
var content = new StringContent(query, Encoding.UTF8, "application/json");
// Act
var response = await client.PostAsync("/graphql", content);
//Assert
response.EnsureSuccessStatusCode();