Last active
October 13, 2016 02:40
-
-
Save nwillc/9f990efda61ee3952e2c0a42ddab0a7f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Map<String, Object> graphql(Request request, | |
Response response) { | |
Map<String, Object> payload; | |
payload = getMapper().readValue(request.body(), Map.class); | |
Map<String,Object> variables = | |
(Map<String, Object>) payload.get("variables"); | |
ExecutionResult executionResult = | |
graphql.execute(payload.get("query").toString(), null, null, variables); | |
Map<String, Object> result = new LinkedHashMap<>(); | |
if (executionResult.getErrors().size() > 0) { | |
result.put("errors", executionResult.getErrors()); | |
} | |
result.put("data", executionResult.getData()); | |
response.type("application/json"); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment