Skip to content
This repository was archived by the owner on Oct 25, 2021. It is now read-only.

Commit ad77a01

Browse files
committed
add webmvc support, refactoring
1 parent c70201e commit ad77a01

File tree

28 files changed

+402
-128
lines changed

28 files changed

+402
-128
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
language: java
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package graphql.spring.web.reactive;
2+
3+
import graphql.spring.web.reactive.controller.GraphQLController;
4+
import org.springframework.beans.factory.annotation.Autowired;
5+
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
6+
import org.springframework.context.ApplicationContext;
7+
import org.springframework.context.annotation.ComponentScan;
8+
import org.springframework.context.annotation.Configuration;
9+
10+
import javax.annotation.PostConstruct;
11+
12+
@Configuration
13+
@ConditionalOnWebApplication
14+
@ComponentScan(basePackageClasses = GraphQLController.class)
15+
public class GraphQLEndpointConfiguration {
16+
17+
@Autowired
18+
ApplicationContext applicationContext;
19+
20+
@PostConstruct
21+
public void init() {
22+
}
23+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
2-
graphql.spring.GraphQLEndpointConfiguration
2+
graphql.spring.web.reactive.GraphQLEndpointConfiguration
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
version = "1.0"
3+
4+
def springBootVersion = "2.1.0.RELEASE"
5+
6+
dependencies {
7+
compile "org.springframework.boot:spring-boot-autoconfigure:$springBootVersion"
8+
compile project(':graphql-java-spring-webmvc')
9+
}

graphql-java-spring-boot-starter-webflux/src/main/java/graphql/spring/GraphQLEndpointConfiguration.java renamed to graphql-java-spring-boot-starter-webmvc/src/main/java/graphql/spring/web/servlet/GraphQLEndpointConfiguration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
package graphql.spring;
1+
package graphql.spring.web.servlet;
22

3-
import graphql.spring.reactive.controller.GraphQLController;
3+
import graphql.spring.web.servlet.controller.GraphQLController;
44
import org.springframework.beans.factory.annotation.Autowired;
55
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
66
import org.springframework.context.ApplicationContext;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
2+
graphql.spring.web.servlet.GraphQLEndpointConfiguration

graphql-java-spring-webflux/build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
def springVersion = "5.1.2.RELEASE"
22
def jacksonVersion = "2.9.6"
3-
//def graphqlJavaVersion = "11.0"
4-
def graphqlJavaVersion = "2018-09-16T01-27-46-27a6e44"
3+
def graphqlJavaVersion = "11.0"
54

65
dependencies {
76
compile "org.springframework:spring-webflux:$springVersion"

graphql-java-spring-webflux/src/main/java/graphql/spring/reactive/DefaultExecutionResultHandler.java

Lines changed: 0 additions & 112 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package graphql.spring.web.reactive;
2+
3+
import com.fasterxml.jackson.databind.ObjectMapper;
4+
import graphql.ExecutionResult;
5+
import org.springframework.beans.factory.annotation.Autowired;
6+
import org.springframework.http.server.reactive.ServerHttpResponse;
7+
import org.springframework.stereotype.Component;
8+
import reactor.core.publisher.Mono;
9+
10+
@Component
11+
public class DefaultExecutionResultHandler implements ExecutionResultHandler {
12+
13+
@Autowired
14+
ObjectMapper objectMapper;
15+
16+
@Override
17+
public Object handleExecutionResult(Mono<ExecutionResult> executionResultMono, ServerHttpResponse serverHttpResponse) {
18+
return executionResultMono.map(executionResult -> handleImpl(executionResult, serverHttpResponse));
19+
}
20+
21+
private Object handleImpl(ExecutionResult executionResult, ServerHttpResponse serverHttpResponse) {
22+
return executionResult.toSpecification();
23+
}
24+
}

graphql-java-spring-webflux/src/main/java/graphql/spring/reactive/DefaultGraphQLInvocation.java renamed to graphql-java-spring-webflux/src/main/java/graphql/spring/web/reactive/DefaultGraphQLInvocation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package graphql.spring.reactive;
1+
package graphql.spring.web.reactive;
22

33
import graphql.ExecutionInput;
44
import graphql.ExecutionResult;

0 commit comments

Comments
 (0)