graphql-client
graphql-client copied to clipboard
Problem with GraphQL.Client.Abstractions
trafficstars
Hi
I have problem with GraphQL.Client.Abstractions. I have portal with graphQL answer from portal to my request looks:
{
"data": {
"pages": {
"single": {
"title": "Tworzenie backup",
"id": 5,
"path": "database/backup"
}
}
}
}
When I use
var answer_request = await graphQLClient.SendMutationAsync<T>(request);
where T is class -> DataPageSearch
public class DataPageSearch
{
public Pages Pages { get; set; }
}
public class Pages
{
public Search Single{ get; set; }
}
public class Single
{
public List<Result> Results { get; set; }
}
public class Result
{
public string id { get; set; }
public string path { get; set; }
public string title { get; set; }
}
it's evrything ok. But when i try use GraphQL.Client.Abstractions and
var answer_request = await graphQLClient.SendMutationAsync(request, () => new {list = new Single()});
always i get null. Where is problem. Thanks.
You're missing two levels in your anonymous type.
This would work:
var answer_request = await graphQLClient.SendMutationAsync(request, () => new {
pages = new Pages()
});