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" } ] } }

浙公网安备 33010602011771号