Skip to content

Commit e56a98f

Browse files
committed
Process variables as a string with a JSON value inside
1 parent 5509185 commit e56a98f

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ repositories {
1515
}
1616
1717
dependencies {
18-
compile 'graphql-java-servlet:graphql-java-servlet:0.6.0'
18+
compile 'graphql-java-servlet:graphql-java-servlet:0.6.1'
1919
}
2020
```
2121

src/main/java/graphql/servlet/GraphQLServlet.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
*/
1515
package graphql.servlet;
1616

17+
import com.fasterxml.jackson.annotation.JsonRawValue;
18+
import com.fasterxml.jackson.core.type.TypeReference;
1719
import com.fasterxml.jackson.databind.ObjectMapper;
1820
import com.google.common.io.CharStreams;
1921
import graphql.*;
@@ -159,8 +161,14 @@ public String executeQuery(String query) {
159161
public static class Request {
160162
@Getter @Setter
161163
private String query;
162-
@Getter @Setter
164+
@Getter
163165
private Map<String, Object> variables = new HashMap<>();
166+
167+
@SneakyThrows
168+
public void setVariables(String variables) {
169+
this.variables = new ObjectMapper().readValue(variables, new TypeReference<Map<String, Object>>() {});
170+
}
171+
164172
@Getter @Setter
165173
private String operationName;
166174
}

0 commit comments

Comments
 (0)