graphql-client icon indicating copy to clipboard operation
graphql-client copied to clipboard

Problem with GraphQL.Client.Abstractions

Open gbicrobert opened this issue 3 years ago • 1 comments
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.

gbicrobert avatar Mar 14 '22 07:03 gbicrobert

You're missing two levels in your anonymous type.

This would work:

var answer_request = await graphQLClient.SendMutationAsync(request, () => new {
    pages = new Pages()
});

rose-a avatar Mar 16 '22 18:03 rose-a