|
6 | 6 | import graphql.parser.Parser; |
7 | 7 | import graphql.schema.GraphQLSchema; |
8 | 8 |
|
| 9 | +import java.util.Collections; |
| 10 | +import java.util.LinkedHashMap; |
| 11 | +import java.util.Map; |
| 12 | + |
9 | 13 | public class GraphQL { |
10 | 14 |
|
11 | 15 |
|
12 | | - private GraphQLSchema graphQLSchema; |
13 | | - private String requestString; |
| 16 | + private final GraphQLSchema graphQLSchema; |
| 17 | + private final String requestString; |
| 18 | + private final Map<String, Object> arguments = new LinkedHashMap<>(); |
14 | 19 |
|
15 | 20 | public GraphQL(GraphQLSchema graphQLSchema, String requestString) { |
| 21 | + this(graphQLSchema, requestString, Collections.<String, Object>emptyMap()); |
| 22 | + } |
| 23 | + |
| 24 | + public GraphQL(GraphQLSchema graphQLSchema, String requestString, Map<String, Object> arguments) { |
16 | 25 | this.graphQLSchema = graphQLSchema; |
17 | 26 | this.requestString = requestString; |
| 27 | + this.arguments.putAll(arguments); |
18 | 28 | } |
19 | 29 |
|
20 | 30 | public Object execute() { |
21 | 31 | Parser parser = new Parser(); |
22 | 32 | Document document = parser.parseDocument(requestString); |
23 | 33 | Execution execution = new Execution(); |
24 | | - return execution.execute(graphQLSchema, null, document, null, null).getResut(); |
| 34 | + return execution.execute(graphQLSchema, null, document, null, arguments).getResut(); |
25 | 35 | } |
26 | 36 |
|
27 | 37 |
|
|
0 commit comments