forked from carlflor/unity_graphql_client
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathGraphQLResponse.cs
More file actions
28 lines (23 loc) · 804 Bytes
/
Copy pathGraphQLResponse.cs
File metadata and controls
28 lines (23 loc) · 804 Bytes
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
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
namespace GraphQL {
public class GraphQLResponse {
public string Raw { get; private set; }
private readonly JObject data;
public string Exception { get; private set; }
public GraphQLResponse (string text, string ex = null) {
Exception = ex;
Raw = text;
data = text != null ? JObject.Parse(text) : null;
}
public T Get<T> (string key) {
return GetData()[key].ToObject<T>();
}
public List<T> GetList<T> (string key) {
return Get<JArray>(key).ToObject<List<T>>();
}
private JObject GetData () {
return data == null ? null : JObject.Parse(data["data"].ToString());
}
}
}