1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package eu.ehri.project.graphql;
21
22 import com.fasterxml.jackson.annotation.JsonCreator;
23 import com.fasterxml.jackson.annotation.JsonProperty;
24 import com.google.common.collect.Maps;
25
26 import java.util.Collections;
27 import java.util.Map;
28
29 public class GraphQLQuery {
30
31 private final String query;
32 private final Map<String, Object> variables;
33 private final String operationName;
34
35 @JsonCreator
36 public GraphQLQuery(@JsonProperty("query") String query,
37 @JsonProperty("variables") Map<String, Object> variables,
38 @JsonProperty("operationName") String operationName) {
39 this.query = query;
40 this.variables = variables;
41 this.operationName = operationName;
42 }
43
44 public GraphQLQuery(String query) {
45 this(query, Collections.emptyMap(), null);
46 }
47
48 public String getQuery() {
49 return query;
50 }
51
52 public Map<String, Object> getVariables() {
53 return variables != null ? variables : Collections.emptyMap();
54 }
55
56 public String getOperationName() {
57 return operationName;
58 }
59
60 @Override
61 public String toString() {
62 Map<String, Object> m = Maps.newHashMap();
63 m.put("query", query);
64 m.put("variables", variables);
65 return m.toString();
66 }
67 }