-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContent.cs
57 lines (45 loc) · 1.52 KB
/
Content.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System.Net.Http.Headers;
using Google.Apis.Json;
using GraphQL;
using GraphQL.Client;
using GraphQL.Client.Http;
using Newtonsoft.Json;
using GraphQL.Client.Serializer.Newtonsoft;
using System.Net.Http;
namespace Dcp
{
public class ContentData
{
public List<Article> Article { get; set; }
}
public class Article
{
public string Title { get; set; }
}
public class Content
{
private static string host = "http://dmdemo2.dev.digimaker.no/api";
private static string apiKey = "ddddxxxx7383423424sjfshfgfysifsik";
public static ContentData List()
{
var heroRequest = new GraphQLRequest
{
Query = @"query{
article(filter:{cid: 473})
{
cid,
title,
summary
}
}"
};
var graphQLClient = new GraphQLHttpClient(host+"/graphql", new GraphQL.Client.Serializer.Newtonsoft.NewtonsoftJsonSerializer());
var httpClient = graphQLClient.HttpClient;
httpClient.DefaultRequestHeaders.Add("apiKey", apiKey);
var result = new ContentData();
var resp = Task.Run(() => graphQLClient.SendQueryAsync<ContentData>(heroRequest)).Result;
result = resp.Data;
return result;
}
}
}