GraphQL文档

 

https://graphql-dotnet.github.io/docs/getting-started/introduction

 

1、服务器请求GraphQL  api

https://github.com/graphql-dotnet/graphql-client

安装

GraphQL.Client

GraphQL.Client.Serializer.Newtonsoft

 

var graphQLClient = new GraphQLHttpClient("http://10.0.102.137:51980/api/graphql?token=d92291216c343dcdcd091a4fbd02e7518c72764674cc6701f0b5306dc2745017", new NewtonsoftJsonSerializer());
            var req = new GraphQLRequest()
            {
                Query= @"{
                            documents{
                              id,
                              title,
                              type
                            }
                        }"
            };
           
            var graphQLResponse = await graphQLClient.SendQueryAsync<WynRSData>(req);

 

public class WynRSData
{
    public List<WynDocumentInfo> documents { get; set; }
}
public class WynDocumentInfo
{
    public string id { get; set; }
    public string title { get; set; }
    public string type { get; set; }
}

 

data不用定义实体

{
    "data": {
        "documents": [
            {
                "title": "水球图",
                "id": "00fb936e-b1ee-49cf-bdc9-bdd79dda5946",
                "type": "visual"
            },
            {
                "title": "3-省电力公司电网资产监管中心",
                "id": "01130402-b444-4373-9098-a2a351422417",
                "type": "dbd"
            }
        ]
     }
}

 

posted @ 2020-10-21 20:17  wjl910  阅读(281)  评论(0)    收藏  举报