Skip to content

Commit 6ecb041

Browse files
authored
Merge pull request #163 from lburja/master
Ensure 'variables' is never null, since graphql-java 12.0 expects it
2 parents 40ea03c + fbf11e2 commit 6ecb041

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/main/java/graphql/servlet/internal/GraphQLRequest.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,17 @@
1313
public class GraphQLRequest {
1414
private String query;
1515
@JsonDeserialize(using = VariablesDeserializer.class)
16-
private Map<String, Object> variables = new HashMap<>();
16+
private Map<String, Object> variables;
1717
private String operationName;
1818

1919
public GraphQLRequest() {
2020
}
2121

2222
public GraphQLRequest(String query, Map<String, Object> variables, String operationName) {
2323
this.query = query;
24-
this.variables = variables;
2524
this.operationName = operationName;
25+
26+
setVariables(variables);
2627
}
2728

2829
public String getQuery() {
@@ -38,7 +39,11 @@ public Map<String, Object> getVariables() {
3839
}
3940

4041
public void setVariables(Map<String, Object> variables) {
41-
this.variables = variables;
42+
if (variables == null) {
43+
this.variables = new HashMap<>();
44+
} else {
45+
this.variables = variables;
46+
}
4247
}
4348

4449
public String getOperationName() {

0 commit comments

Comments
 (0)