Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.

Commit 8d84693

Browse files
committed
Refactored construction of servlet
1 parent fd01277 commit 8d84693

File tree

5 files changed

+13
-21
lines changed

5 files changed

+13
-21
lines changed

example-graphql-subscription/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ plugins {
55
sourceCompatibility = 1.8
66

77
repositories {
8+
jcenter()
89
mavenCentral()
910
}
1011

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ LIB_GRAPHQL_JAVA_VER = 11.0
4040
LIB_JUNIT_VER = 4.12
4141
LIB_SPRING_CORE_VER = 5.0.4.RELEASE
4242
LIB_SPRING_BOOT_VER = 2.1.0.RELEASE
43-
LIB_GRAPHQL_SERVLET_VER = 7.1.0
43+
LIB_GRAPHQL_SERVLET_VER = 7.1.1-SNAPSHOT
4444
LIB_GRAPHQL_JAVA_TOOLS_VER = 5.4.0
4545
LIB_COMMONS_IO_VER = 2.6
4646
kotlin.version=1.3.10

graphql-spring-boot-autoconfigure/src/main/java/com/oembedler/moon/graphql/boot/GraphQLJavaToolsAutoConfiguration.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
import com.fasterxml.jackson.databind.ObjectMapper;
55
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
66
import com.fasterxml.jackson.module.kotlin.KotlinModule;
7-
import com.oembedler.moon.graphql.boot.error.GraphQLErrorHandlerFactory;
87
import graphql.schema.GraphQLScalarType;
98
import graphql.schema.GraphQLSchema;
10-
import graphql.servlet.GraphQLErrorHandler;
119
import graphql.servlet.GraphQLSchemaProvider;
1210
import org.springframework.beans.factory.annotation.Autowired;
1311
import org.springframework.boot.autoconfigure.AutoConfigureAfter;

graphql-spring-boot-autoconfigure/src/main/java/com/oembedler/moon/graphql/boot/GraphQLWebAutoConfiguration.java

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import graphql.execution.AsyncExecutionStrategy;
2626
import graphql.execution.ExecutionStrategy;
2727
import graphql.execution.SubscriptionExecutionStrategy;
28-
import graphql.execution.instrumentation.ChainedInstrumentation;
2928
import graphql.execution.instrumentation.Instrumentation;
3029
import graphql.execution.preparsed.PreparsedDocumentProvider;
3130
import graphql.schema.GraphQLSchema;
@@ -182,13 +181,8 @@ public GraphQLQueryInvoker queryInvoker(ExecutionStrategyProvider executionStrat
182181
GraphQLQueryInvoker.Builder builder = GraphQLQueryInvoker.newBuilder()
183182
.withExecutionStrategyProvider(executionStrategyProvider);
184183

185-
if (instrumentations != null && !instrumentations.isEmpty()) {
186-
if (instrumentations.size() == 1) {
187-
builder.withInstrumentation(instrumentations.get(0));
188-
} else {
189-
Instrumentation instrumentation = new ChainedInstrumentation(instrumentations);
190-
builder.withInstrumentation(instrumentation);
191-
}
184+
if (instrumentations != null) {
185+
builder.with(instrumentations);
192186
}
193187

194188
if (preparsedDocumentProvider != null) {
@@ -207,7 +201,7 @@ public GraphQLObjectMapper graphQLObjectMapper(ObjectMapperProvider objectMapper
207201
builder.withGraphQLErrorHandler(errorHandler);
208202
}
209203

210-
if (objectMapperProvider != null){
204+
if (objectMapperProvider != null) {
211205
builder.withObjectMapperProvider(objectMapperProvider);
212206
} else if (objectMapperConfigurer != null) {
213207
builder.withObjectMapperConfigurer(objectMapperConfigurer);
@@ -218,7 +212,7 @@ public GraphQLObjectMapper graphQLObjectMapper(ObjectMapperProvider objectMapper
218212

219213
@Bean
220214
@ConditionalOnMissingBean
221-
@ConditionalOnProperty(value="graphql.servlet.use-default-objectmapper", havingValue = "true",
215+
@ConditionalOnProperty(value = "graphql.servlet.use-default-objectmapper", havingValue = "true",
222216
matchIfMissing = true)
223217
public ObjectMapperProvider objectMapperProvider(ObjectMapper objectMapper) {
224218
InjectableValues.Std injectableValues = new InjectableValues.Std();
@@ -228,16 +222,16 @@ public ObjectMapperProvider objectMapperProvider(ObjectMapper objectMapper) {
228222
}
229223

230224

231-
232225
@Bean
233226
@ConditionalOnMissingBean
234-
public SimpleGraphQLHttpServlet graphQLHttpServlet(GraphQLInvocationInputFactory invocationInputFactory, GraphQLQueryInvoker queryInvoker, GraphQLObjectMapper graphQLObjectMapper) {
235-
return SimpleGraphQLHttpServlet.newBuilder(invocationInputFactory)
236-
.withQueryInvoker(queryInvoker)
237-
.withObjectMapper(graphQLObjectMapper)
238-
.withListeners(listeners)
239-
.withAsyncServletMode(graphQLServletProperties.isAsyncModeEnabled())
227+
public GraphQLHttpServlet graphQLHttpServlet(GraphQLInvocationInputFactory invocationInputFactory, GraphQLQueryInvoker queryInvoker, GraphQLObjectMapper graphQLObjectMapper) {
228+
GraphQLConfiguration configuration = GraphQLConfiguration.with(invocationInputFactory)
229+
.with(queryInvoker)
230+
.with(graphQLObjectMapper)
231+
.with(listeners)
232+
.with(graphQLServletProperties.isAsyncModeEnabled())
240233
.build();
234+
return GraphQLHttpServlet.with(configuration);
241235
}
242236

243237
@Bean

graphql-spring-boot-autoconfigure/src/test/java/com/oembedler/moon/graphql/boot/GraphQLErrorHandlerTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ GraphQLSchema schema() {
9393
.resolvers(queryResolver())
9494
.build();
9595
return schemaParser.makeExecutableSchema();
96-
// return GraphQLSchema.newSchema().query(GraphQLObjectType.newObject().name("Query").build()).build();
9796
}
9897
}
9998

0 commit comments

Comments
 (0)