Skip to content

Commit 81ce627

Browse files
committed
Refactored configuration to ease use
1 parent 8a7d572 commit 81ce627

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

src/main/java/graphql/servlet/GraphQLConfiguration.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
public class GraphQLConfiguration {
1010

1111
private GraphQLInvocationInputFactory invocationInputFactory;
12-
private GraphQLQueryInvoker queryInvoker = GraphQLQueryInvoker.newBuilder().build();
13-
private GraphQLObjectMapper objectMapper = GraphQLObjectMapper.newBuilder().build();
12+
private GraphQLQueryInvoker queryInvoker;
13+
private GraphQLObjectMapper objectMapper;
1414
private List<GraphQLServletListener> listeners;
1515
private boolean asyncServletModeEnabled;
1616

@@ -22,7 +22,7 @@ public static GraphQLConfiguration.Builder with(GraphQLSchemaProvider schemaProv
2222
return new Builder(GraphQLInvocationInputFactory.newBuilder(schemaProvider));
2323
}
2424

25-
static GraphQLConfiguration.Builder with(GraphQLInvocationInputFactory invocationInputFactory) {
25+
public static GraphQLConfiguration.Builder with(GraphQLInvocationInputFactory invocationInputFactory) {
2626
return new Builder(invocationInputFactory);
2727
}
2828

src/main/java/graphql/servlet/GraphQLInvocationInputFactory.java

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* @author Andrew Potter
1515
*/
1616
public class GraphQLInvocationInputFactory {
17+
1718
private final Supplier<GraphQLSchemaProvider> schemaProviderSupplier;
1819
private final Supplier<GraphQLContextBuilder> contextBuilderSupplier;
1920
private final Supplier<GraphQLRootObjectBuilder> rootObjectBuilderSupplier;

src/main/java/graphql/servlet/GraphQLQueryInvoker.java

+12
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,18 @@ public Builder withInstrumentation(Supplier<Instrumentation> supplier) {
123123
return this;
124124
}
125125

126+
public Builder with(List<Instrumentation> instrumentations) {
127+
if (instrumentations.isEmpty()) {
128+
return this;
129+
}
130+
if (instrumentations.size() == 1) {
131+
withInstrumentation(instrumentations.get(0));
132+
} else {
133+
withInstrumentation(new ChainedInstrumentation(instrumentations));
134+
}
135+
return this;
136+
}
137+
126138
public Builder withPreparsedDocumentProvider(PreparsedDocumentProvider provider) {
127139
return withPreparsedDocumentProvider(() -> provider);
128140
}

src/main/java/graphql/servlet/SimpleGraphQLHttpServlet.java

+1-6
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,7 @@ public SimpleGraphQLHttpServlet() {
1717
}
1818

1919
/**
20-
* @param invocationInputFactory
21-
* @param queryInvoker
22-
* @param graphQLObjectMapper
23-
* @param listeners
24-
* @param asyncServletMode
25-
* @deprecated
20+
* @deprecated use {@link GraphQLHttpServlet} instead
2621
*/
2722
@Deprecated
2823
public SimpleGraphQLHttpServlet(GraphQLInvocationInputFactory invocationInputFactory, GraphQLQueryInvoker queryInvoker, GraphQLObjectMapper graphQLObjectMapper, List<GraphQLServletListener> listeners, boolean asyncServletMode) {

0 commit comments

Comments
 (0)