I am writing a C# test using this client: https://github.com/graphql-dotnet/graphql-client. Here is my query:
query getFilters($input: FilterInputType!) {
getFilterData(input: $input) {
assetId
material
productFamily
equipmentModel
}
}
And here is the query variables:
{
"input": {
"startDate": "2019-09-01T00:00:00",
"endDate": "2019-09-30T23:59:59"
}
}
When I execute the query in RestClient it returns data, but the query in the code does not work. Here is my code
var startDate = "2019-09-01T00:00:00";
var endDate = "2019-09-30T00:00:00";
var dateRange = new { startDate, endDate };
var getFiltersRequest2 = new GraphQLRequest
{
Query = @"
{
query getFilters($input: FilterInputType!) {
getFilterData(input: $input) {
assetId
material
productFamily
equipmentModel
sourceSite
destinationSite
}
}
}",
OperationName = "getFilters",
Variables = new
{
input = dateRange
}
};
//Act
GraphQLClient graphQLClient = new GraphQLClient(endpointUrl);
graphQLClient.DefaultRequestHeaders.Add("Accept", "application/json");
graphQLClient.DefaultRequestHeaders.Add("Authorization", authToken);
var graphQLResponse = await graphQLClient.PostAsync(getFiltersRequest2);
What might be wrong with my syntax?
Aucun commentaire:
Enregistrer un commentaire