diff --git a/README.md b/README.md index b348ee91..c7b776a0 100644 --- a/README.md +++ b/README.md @@ -11,12 +11,12 @@ This project is tested against Spring Boot 2.4+, but should work on 2.3 as well. You can start by creating a project on https://start.spring.io and select the `spring-boot-starter-web` or `spring-boot-starter-webflux` starter, depending on the type of web application you'd like to build. Once the project is generated, you can manually add the -`org.springframework.experimental:spring-graphql-web` dependency. +`org.springframework.experimental:graphql-spring-boot-starter` dependency. `build.gradle` snippet: ```groovy dependencies { - implementation 'org.springframework.experimental:spring-graphql-web:0.1.0-SNAPSHOT' + implementation 'org.springframework.experimental:graphql-spring-boot-starter:0.1.0-SNAPSHOT' // Spring Web MVC starter implementation 'org.springframework.boot:spring-boot-starter-web' @@ -38,7 +38,7 @@ repositories { org.springframework.experimental - spring-graphql-web + graphql-spring-boot-starter 0.1.0-SNAPSHOT @@ -142,14 +142,15 @@ management.endpoints.web.exposure.include=health,metrics,info You can then check those metrics at `http://localhost:8080/actuator/metrics/graphql.query`. -## Sample application +## Sample applications -This repository contains a sample application that the team is using to test new features and ideas. +This repository contains sample applications that the team is using to test new features and ideas. -You can run it by cloning this repository and typing on the command line: +You can run them by cloning this repository and typing on the command line: ```shell script -$ ./gradlew :graphql-sample:bootRun +$ ./gradlew :samples:webmvc-http:bootRun +$ ./gradlew :samples:webflux-websocket:bootRun ``` diff --git a/graphql-spring-boot-starter/build.gradle b/graphql-spring-boot-starter/build.gradle new file mode 100644 index 00000000..147a8152 --- /dev/null +++ b/graphql-spring-boot-starter/build.gradle @@ -0,0 +1,66 @@ +import org.springframework.boot.gradle.plugin.SpringBootPlugin + +plugins { + id 'org.springframework.boot' version '2.4.1' apply false + id 'io.spring.dependency-management' version '1.0.10.RELEASE' + id 'java-library' + id 'maven' +} + +description = "GraphQL Spring Boot Starter" +sourceCompatibility = 1.8 +targetCompatibility = 1.8 + +configurations { + apt +} + +dependencyManagement { + imports { + mavenBom SpringBootPlugin.BOM_COORDINATES + } + generatedPomCustomization { + enabled = false + } +} + +dependencies { + api project(':spring-graphql-web') + api 'com.graphql-java:graphql-java:15.0' + // Reactor is required as it's part of the interception model + api 'io.projectreactor:reactor-core' + api 'org.springframework:spring-context' + api 'org.springframework.boot:spring-boot-starter' + + compileOnly 'org.springframework:spring-webflux' + compileOnly 'javax.servlet:javax.servlet-api' + compileOnly 'org.springframework:spring-webmvc' + + compileOnly 'io.micrometer:micrometer-core' + compileOnly 'org.springframework.boot:spring-boot-actuator-autoconfigure' + + apt 'javax.annotation:javax.annotation-api:1.3.2' + annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor' + annotationProcessor 'org.springframework.boot:spring-boot-autoconfigure-processor' + + testImplementation 'com.fasterxml.jackson.core:jackson-databind' + testImplementation 'org.springframework:spring-webflux' + testImplementation 'org.springframework:spring-webmvc' + testImplementation 'io.projectreactor:reactor-test' + testImplementation 'javax.servlet:javax.servlet-api' + testImplementation 'org.springframework.boot:spring-boot-actuator-autoconfigure' + testImplementation 'org.springframework.boot:spring-boot-starter-test' +} + +compileJava { + options.annotationProcessorPath = configurations.apt +} + +test { + useJUnitPlatform() + testLogging { + events "passed", "skipped", "failed" + } +} + +apply from: "${rootDir}/gradle/publishing.gradle" \ No newline at end of file diff --git a/spring-graphql-web/src/main/java/org/springframework/boot/graphql/GraphQLAutoConfiguration.java b/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/GraphQLAutoConfiguration.java similarity index 98% rename from spring-graphql-web/src/main/java/org/springframework/boot/graphql/GraphQLAutoConfiguration.java rename to graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/GraphQLAutoConfiguration.java index a6977ba7..ede15a17 100644 --- a/spring-graphql-web/src/main/java/org/springframework/boot/graphql/GraphQLAutoConfiguration.java +++ b/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/GraphQLAutoConfiguration.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.boot.graphql; +package org.springframework.graphql.boot; import java.io.IOException; import java.util.List; diff --git a/spring-graphql-web/src/main/java/org/springframework/boot/graphql/GraphQLProperties.java b/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/GraphQLProperties.java similarity index 98% rename from spring-graphql-web/src/main/java/org/springframework/boot/graphql/GraphQLProperties.java rename to graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/GraphQLProperties.java index 4c8de061..b473f854 100644 --- a/spring-graphql-web/src/main/java/org/springframework/boot/graphql/GraphQLProperties.java +++ b/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/GraphQLProperties.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.boot.graphql; +package org.springframework.graphql.boot; import java.time.Duration; diff --git a/spring-graphql-web/src/main/java/org/springframework/boot/graphql/MissingGraphQLSchemaException.java b/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/MissingGraphQLSchemaException.java similarity index 96% rename from spring-graphql-web/src/main/java/org/springframework/boot/graphql/MissingGraphQLSchemaException.java rename to graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/MissingGraphQLSchemaException.java index b44862ec..31e1ba64 100644 --- a/spring-graphql-web/src/main/java/org/springframework/boot/graphql/MissingGraphQLSchemaException.java +++ b/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/MissingGraphQLSchemaException.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.graphql; +package org.springframework.graphql.boot; import org.springframework.core.io.Resource; diff --git a/spring-graphql-web/src/main/java/org/springframework/boot/graphql/RuntimeWiringCustomizer.java b/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/RuntimeWiringCustomizer.java similarity index 94% rename from spring-graphql-web/src/main/java/org/springframework/boot/graphql/RuntimeWiringCustomizer.java rename to graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/RuntimeWiringCustomizer.java index 8a51b375..67fc0e49 100644 --- a/spring-graphql-web/src/main/java/org/springframework/boot/graphql/RuntimeWiringCustomizer.java +++ b/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/RuntimeWiringCustomizer.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.boot.graphql; +package org.springframework.graphql.boot; import graphql.schema.idl.RuntimeWiring; diff --git a/spring-graphql-web/src/main/java/org/springframework/boot/graphql/WebFluxGraphQLAutoConfiguration.java b/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/WebFluxGraphQLAutoConfiguration.java similarity index 98% rename from spring-graphql-web/src/main/java/org/springframework/boot/graphql/WebFluxGraphQLAutoConfiguration.java rename to graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/WebFluxGraphQLAutoConfiguration.java index 0162fada..2e37c055 100644 --- a/spring-graphql-web/src/main/java/org/springframework/boot/graphql/WebFluxGraphQLAutoConfiguration.java +++ b/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/WebFluxGraphQLAutoConfiguration.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.boot.graphql; +package org.springframework.graphql.boot; import java.util.Collections; diff --git a/spring-graphql-web/src/main/java/org/springframework/boot/graphql/WebMvcGraphQLAutoConfiguration.java b/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/WebMvcGraphQLAutoConfiguration.java similarity index 98% rename from spring-graphql-web/src/main/java/org/springframework/boot/graphql/WebMvcGraphQLAutoConfiguration.java rename to graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/WebMvcGraphQLAutoConfiguration.java index 73a77c7b..79eb604a 100644 --- a/spring-graphql-web/src/main/java/org/springframework/boot/graphql/WebMvcGraphQLAutoConfiguration.java +++ b/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/WebMvcGraphQLAutoConfiguration.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.boot.graphql; +package org.springframework.graphql.boot; import java.util.Collections; diff --git a/spring-graphql-web/src/main/java/org/springframework/boot/actuate/metrics/graphql/DefaultGraphQLTagsProvider.java b/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/actuate/metrics/DefaultGraphQLTagsProvider.java similarity index 96% rename from spring-graphql-web/src/main/java/org/springframework/boot/actuate/metrics/graphql/DefaultGraphQLTagsProvider.java rename to graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/actuate/metrics/DefaultGraphQLTagsProvider.java index 19e0d7a3..a488c1e9 100644 --- a/spring-graphql-web/src/main/java/org/springframework/boot/actuate/metrics/graphql/DefaultGraphQLTagsProvider.java +++ b/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/actuate/metrics/DefaultGraphQLTagsProvider.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.actuate.metrics.graphql; +package org.springframework.graphql.boot.actuate.metrics; import graphql.ErrorClassification; import graphql.ErrorType; diff --git a/spring-graphql-web/src/main/java/org/springframework/boot/actuate/metrics/graphql/GraphQLMetricsAutoConfiguration.java b/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/actuate/metrics/GraphQLMetricsAutoConfiguration.java similarity index 97% rename from spring-graphql-web/src/main/java/org/springframework/boot/actuate/metrics/graphql/GraphQLMetricsAutoConfiguration.java rename to graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/actuate/metrics/GraphQLMetricsAutoConfiguration.java index c2a4fbab..580b0929 100644 --- a/spring-graphql-web/src/main/java/org/springframework/boot/actuate/metrics/graphql/GraphQLMetricsAutoConfiguration.java +++ b/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/actuate/metrics/GraphQLMetricsAutoConfiguration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.actuate.metrics.graphql; +package org.springframework.graphql.boot.actuate.metrics; import io.micrometer.core.instrument.MeterRegistry; diff --git a/spring-graphql-web/src/main/java/org/springframework/boot/actuate/metrics/graphql/GraphQLMetricsInstrumentation.java b/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/actuate/metrics/GraphQLMetricsInstrumentation.java similarity index 97% rename from spring-graphql-web/src/main/java/org/springframework/boot/actuate/metrics/graphql/GraphQLMetricsInstrumentation.java rename to graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/actuate/metrics/GraphQLMetricsInstrumentation.java index caa3a227..91729cef 100644 --- a/spring-graphql-web/src/main/java/org/springframework/boot/actuate/metrics/graphql/GraphQLMetricsInstrumentation.java +++ b/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/actuate/metrics/GraphQLMetricsInstrumentation.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.actuate.metrics.graphql; +package org.springframework.graphql.boot.actuate.metrics; import graphql.ExecutionResult; import graphql.execution.instrumentation.InstrumentationContext; diff --git a/spring-graphql-web/src/main/java/org/springframework/boot/actuate/metrics/graphql/GraphQLMetricsProperties.java b/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/actuate/metrics/GraphQLMetricsProperties.java similarity index 95% rename from spring-graphql-web/src/main/java/org/springframework/boot/actuate/metrics/graphql/GraphQLMetricsProperties.java rename to graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/actuate/metrics/GraphQLMetricsProperties.java index 297448a3..207d5402 100644 --- a/spring-graphql-web/src/main/java/org/springframework/boot/actuate/metrics/graphql/GraphQLMetricsProperties.java +++ b/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/actuate/metrics/GraphQLMetricsProperties.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.actuate.metrics.graphql; +package org.springframework.graphql.boot.actuate.metrics; import org.springframework.boot.actuate.autoconfigure.metrics.AutoTimeProperties; import org.springframework.boot.context.properties.ConfigurationProperties; diff --git a/spring-graphql-web/src/main/java/org/springframework/boot/actuate/metrics/graphql/GraphQLTagsProvider.java b/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/actuate/metrics/GraphQLTagsProvider.java similarity index 94% rename from spring-graphql-web/src/main/java/org/springframework/boot/actuate/metrics/graphql/GraphQLTagsProvider.java rename to graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/actuate/metrics/GraphQLTagsProvider.java index 9efc6998..0e410a80 100644 --- a/spring-graphql-web/src/main/java/org/springframework/boot/actuate/metrics/graphql/GraphQLTagsProvider.java +++ b/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/actuate/metrics/GraphQLTagsProvider.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.actuate.metrics.graphql; +package org.springframework.graphql.boot.actuate.metrics; import graphql.ExecutionResult; import graphql.execution.instrumentation.parameters.InstrumentationExecutionParameters; diff --git a/spring-graphql-web/src/main/java/org/springframework/boot/graphql/package-info.java b/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/package-info.java similarity index 94% rename from spring-graphql-web/src/main/java/org/springframework/boot/graphql/package-info.java rename to graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/package-info.java index 53e7d2a9..6aaf504e 100644 --- a/spring-graphql-web/src/main/java/org/springframework/boot/graphql/package-info.java +++ b/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/package-info.java @@ -15,7 +15,7 @@ */ @NonNullApi @NonNullFields -package org.springframework.boot.graphql; +package org.springframework.graphql.boot; import org.springframework.lang.NonNullApi; import org.springframework.lang.NonNullFields; diff --git a/graphql-spring-boot-starter/src/main/resources/META-INF/spring-devtools.properties b/graphql-spring-boot-starter/src/main/resources/META-INF/spring-devtools.properties new file mode 100644 index 00000000..3431e723 --- /dev/null +++ b/graphql-spring-boot-starter/src/main/resources/META-INF/spring-devtools.properties @@ -0,0 +1 @@ +restart.include.graphqljava=graphql-java[\\w-]+\.jar \ No newline at end of file diff --git a/graphql-spring-boot-starter/src/main/resources/META-INF/spring.factories b/graphql-spring-boot-starter/src/main/resources/META-INF/spring.factories new file mode 100644 index 00000000..15942d6c --- /dev/null +++ b/graphql-spring-boot-starter/src/main/resources/META-INF/spring.factories @@ -0,0 +1,5 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ +org.springframework.graphql.boot.actuate.metrics.GraphQLMetricsAutoConfiguration,\ +org.springframework.graphql.boot.GraphQLAutoConfiguration,\ +org.springframework.graphql.boot.WebFluxGraphQLAutoConfiguration,\ +org.springframework.graphql.boot.WebMvcGraphQLAutoConfiguration diff --git a/spring-graphql-web/src/main/resources/graphiql/index.html b/graphql-spring-boot-starter/src/main/resources/graphiql/index.html similarity index 100% rename from spring-graphql-web/src/main/resources/graphiql/index.html rename to graphql-spring-boot-starter/src/main/resources/graphiql/index.html diff --git a/graphql-spring-boot-starter/src/test/java/org/springframework/graphql/boot/Book.java b/graphql-spring-boot-starter/src/test/java/org/springframework/graphql/boot/Book.java new file mode 100644 index 00000000..871fba7a --- /dev/null +++ b/graphql-spring-boot-starter/src/test/java/org/springframework/graphql/boot/Book.java @@ -0,0 +1,54 @@ +package org.springframework.graphql.boot; + +public class Book { + + String id; + + String name; + + int pageCount; + + String author; + + public Book() { + } + + public Book(String id, String name, int pageCount, String author) { + this.id = id; + this.name = name; + this.pageCount = pageCount; + this.author = author; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getPageCount() { + return pageCount; + } + + public void setPageCount(int pageCount) { + this.pageCount = pageCount; + } + + public String getAuthor() { + return author; + } + + public void setAuthor(String author) { + this.author = author; + } +} diff --git a/spring-graphql-web/src/test/java/org/springframework/boot/graphql/GraphQLAutoConfigurationTests.java b/graphql-spring-boot-starter/src/test/java/org/springframework/graphql/boot/GraphQLAutoConfigurationTests.java similarity index 98% rename from spring-graphql-web/src/test/java/org/springframework/boot/graphql/GraphQLAutoConfigurationTests.java rename to graphql-spring-boot-starter/src/test/java/org/springframework/graphql/boot/GraphQLAutoConfigurationTests.java index 26887207..4f6aa867 100644 --- a/spring-graphql-web/src/test/java/org/springframework/boot/graphql/GraphQLAutoConfigurationTests.java +++ b/graphql-spring-boot-starter/src/test/java/org/springframework/graphql/boot/GraphQLAutoConfigurationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.graphql; +package org.springframework.graphql.boot; import graphql.GraphQL; import graphql.schema.GraphQLObjectType; diff --git a/graphql-spring-boot-starter/src/test/java/org/springframework/graphql/boot/GraphQLDataFetchers.java b/graphql-spring-boot-starter/src/test/java/org/springframework/graphql/boot/GraphQLDataFetchers.java new file mode 100644 index 00000000..9adf6447 --- /dev/null +++ b/graphql-spring-boot-starter/src/test/java/org/springframework/graphql/boot/GraphQLDataFetchers.java @@ -0,0 +1,30 @@ +package org.springframework.graphql.boot; + +import java.util.Arrays; +import java.util.List; + +import graphql.schema.DataFetcher; +import reactor.core.publisher.Flux; + +public class GraphQLDataFetchers { + + private static List books = Arrays.asList( + new Book("book-1", "GraphQL for beginners", 100, "John GraphQL"), + new Book("book-2", "Harry Potter and the Philosopher's Stone", 223, "Joanne Rowling"), + new Book("book-3", "Moby Dick", 635, "Moby Dick"), + new Book("book-3", "Moby Dick", 635, "Moby Dick")); + + + public static DataFetcher getBookByIdDataFetcher() { + return environment -> books.stream() + .filter(book -> book.getId().equals(environment.getArgument("id"))) + .findFirst() + .orElse(null); + } + + public static DataFetcher getBooksOnSale() { + return environment -> Flux.fromIterable(books) + .filter(book -> book.getPageCount() >= (int) environment.getArgument("minPages")); + } + +} diff --git a/spring-graphql-web/src/test/java/org/springframework/boot/graphql/WebFluxApplicationContextTests.java b/graphql-spring-boot-starter/src/test/java/org/springframework/graphql/boot/WebFluxApplicationContextTests.java similarity index 97% rename from spring-graphql-web/src/test/java/org/springframework/boot/graphql/WebFluxApplicationContextTests.java rename to graphql-spring-boot-starter/src/test/java/org/springframework/graphql/boot/WebFluxApplicationContextTests.java index 5c38da82..d5f243be 100644 --- a/spring-graphql-web/src/test/java/org/springframework/boot/graphql/WebFluxApplicationContextTests.java +++ b/graphql-spring-boot-starter/src/test/java/org/springframework/graphql/boot/WebFluxApplicationContextTests.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.boot.graphql; +package org.springframework.graphql.boot; import java.util.Collections; import java.util.function.Consumer; @@ -30,7 +30,6 @@ import org.springframework.boot.test.context.runner.ReactiveWebApplicationContex import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.graphql.GraphQLDataFetchers; import org.springframework.http.MediaType; import org.springframework.test.web.reactive.server.WebTestClient; diff --git a/spring-graphql-web/src/test/java/org/springframework/boot/graphql/WebMvcApplicationContextTests.java b/graphql-spring-boot-starter/src/test/java/org/springframework/graphql/boot/WebMvcApplicationContextTests.java similarity index 94% rename from spring-graphql-web/src/test/java/org/springframework/boot/graphql/WebMvcApplicationContextTests.java rename to graphql-spring-boot-starter/src/test/java/org/springframework/graphql/boot/WebMvcApplicationContextTests.java index 75693659..2e806873 100644 --- a/spring-graphql-web/src/test/java/org/springframework/boot/graphql/WebMvcApplicationContextTests.java +++ b/graphql-spring-boot-starter/src/test/java/org/springframework/graphql/boot/WebMvcApplicationContextTests.java @@ -1,4 +1,4 @@ -package org.springframework.boot.graphql; +package org.springframework.graphql.boot; import org.junit.jupiter.api.Test; @@ -11,13 +11,10 @@ import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguratio import org.springframework.boot.test.context.runner.WebApplicationContextRunner; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.graphql.GraphQLDataFetchers; import org.springframework.http.MediaType; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MvcResult; -import org.springframework.test.web.servlet.ResultActions; import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder; -import org.springframework.test.web.servlet.result.MockMvcResultMatchers; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import static graphql.schema.idl.TypeRuntimeWiring.newTypeWiring; diff --git a/graphql-spring-boot-starter/src/test/resources/books/schema.graphqls b/graphql-spring-boot-starter/src/test/resources/books/schema.graphqls new file mode 100644 index 00000000..7ec591e5 --- /dev/null +++ b/graphql-spring-boot-starter/src/test/resources/books/schema.graphqls @@ -0,0 +1,14 @@ +type Query { + bookById(id: ID): Book +} + +type Book { + id: ID + name: String + pageCount: Int + author: String +} + +type Subscription { + bookSearch(minPages:Int) : Book! +} diff --git a/samples/webflux-websocket/build.gradle b/samples/webflux-websocket/build.gradle index f722c6e3..5994e94d 100644 --- a/samples/webflux-websocket/build.gradle +++ b/samples/webflux-websocket/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'org.springframework.boot' version '2.4.0-SNAPSHOT' + id 'org.springframework.boot' version '2.4.1' id 'io.spring.dependency-management' version '1.0.10.RELEASE' id 'java' } @@ -9,7 +9,7 @@ description = "GraphQL over WebSocket sample" sourceCompatibility = '1.8' dependencies { - implementation project(':spring-graphql-web') + implementation project(':graphql-spring-boot-starter') implementation 'org.springframework.boot:spring-boot-starter-webflux' implementation 'org.springframework.boot:spring-boot-starter-actuator' developmentOnly 'org.springframework.boot:spring-boot-devtools' diff --git a/samples/webflux-websocket/src/main/java/io/spring/sample/graphql/SampleWiring.java b/samples/webflux-websocket/src/main/java/io/spring/sample/graphql/SampleWiring.java index 14be4617..9a635be6 100644 --- a/samples/webflux-websocket/src/main/java/io/spring/sample/graphql/SampleWiring.java +++ b/samples/webflux-websocket/src/main/java/io/spring/sample/graphql/SampleWiring.java @@ -5,7 +5,7 @@ import java.time.Duration; import graphql.schema.idl.RuntimeWiring; import reactor.core.publisher.Flux; -import org.springframework.boot.graphql.RuntimeWiringCustomizer; +import org.springframework.graphql.boot.RuntimeWiringCustomizer; import org.springframework.stereotype.Component; @Component diff --git a/samples/webmvc-http/build.gradle b/samples/webmvc-http/build.gradle index acd1592c..35fa059a 100644 --- a/samples/webmvc-http/build.gradle +++ b/samples/webmvc-http/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'org.springframework.boot' version '2.4.0-SNAPSHOT' + id 'org.springframework.boot' version '2.4.1' id 'io.spring.dependency-management' version '1.0.10.RELEASE' id 'java' } @@ -9,7 +9,7 @@ description = "GraphQL sample application" sourceCompatibility = '1.8' dependencies { - implementation project(':spring-graphql-web') + implementation project(':graphql-spring-boot-starter') implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.boot:spring-boot-starter-hateoas' implementation 'org.springframework.boot:spring-boot-starter-data-jpa' diff --git a/samples/webmvc-http/src/main/java/io/spring/sample/graphql/project/ProjectDataWiring.java b/samples/webmvc-http/src/main/java/io/spring/sample/graphql/project/ProjectDataWiring.java index bfc73ddd..653a10c4 100644 --- a/samples/webmvc-http/src/main/java/io/spring/sample/graphql/project/ProjectDataWiring.java +++ b/samples/webmvc-http/src/main/java/io/spring/sample/graphql/project/ProjectDataWiring.java @@ -2,7 +2,7 @@ package io.spring.sample.graphql.project; import graphql.schema.idl.RuntimeWiring; -import org.springframework.boot.graphql.RuntimeWiringCustomizer; +import org.springframework.graphql.boot.RuntimeWiringCustomizer; import org.springframework.stereotype.Component; @Component diff --git a/samples/webmvc-http/src/main/java/io/spring/sample/graphql/repository/ArtifactRepositoryDataWiring.java b/samples/webmvc-http/src/main/java/io/spring/sample/graphql/repository/ArtifactRepositoryDataWiring.java index 830c20d4..9cf287fe 100644 --- a/samples/webmvc-http/src/main/java/io/spring/sample/graphql/repository/ArtifactRepositoryDataWiring.java +++ b/samples/webmvc-http/src/main/java/io/spring/sample/graphql/repository/ArtifactRepositoryDataWiring.java @@ -2,7 +2,7 @@ package io.spring.sample.graphql.repository; import graphql.schema.idl.RuntimeWiring; -import org.springframework.boot.graphql.RuntimeWiringCustomizer; +import org.springframework.graphql.boot.RuntimeWiringCustomizer; import org.springframework.stereotype.Component; @Component diff --git a/settings.gradle b/settings.gradle index 4e418e7a..d4eaa0f0 100644 --- a/settings.gradle +++ b/settings.gradle @@ -14,6 +14,4 @@ pluginManagement { } rootProject.name = 'spring-graphql' -include 'spring-graphql-web' -include 'samples:webmvc-http' -include 'samples:webflux-websocket' +include 'spring-graphql-web', 'graphql-spring-boot-starter', 'samples:webmvc-http', 'samples:webflux-websocket' diff --git a/spring-graphql-web/build.gradle b/spring-graphql-web/build.gradle index 20c74263..0e838951 100644 --- a/spring-graphql-web/build.gradle +++ b/spring-graphql-web/build.gradle @@ -1,7 +1,5 @@ -import org.springframework.boot.gradle.plugin.SpringBootPlugin plugins { - id 'org.springframework.boot' version '2.4.1' apply false id 'io.spring.dependency-management' version '1.0.10.RELEASE' id 'java-library' id 'maven' @@ -13,7 +11,9 @@ targetCompatibility = 1.8 dependencyManagement { imports { - mavenBom SpringBootPlugin.BOM_COORDINATES + mavenBom "com.fasterxml.jackson:jackson-bom:2.12.0" + mavenBom "io.projectreactor:reactor-bom:2020.0.2" + mavenBom "org.springframework:spring-framework-bom:5.3.2" } generatedPomCustomization { enabled = false @@ -24,28 +24,24 @@ dependencies { api 'com.graphql-java:graphql-java:15.0' // Reactor is required as it's part of the interception model api 'io.projectreactor:reactor-core' - // auto-configurations should be moved to the spring-boot project - api 'org.springframework.boot:spring-boot-autoconfigure' + api 'org.springframework:spring-context' - compileOnly 'org.springframework:spring-context' + compileOnly "javax.annotation:javax.annotation-api:1.3.2" compileOnly 'org.springframework:spring-webflux' - compileOnly 'org.springframework:spring-webmvc' - compileOnly 'javax.servlet:javax.servlet-api' - - compileOnly 'io.micrometer:micrometer-core' - compileOnly 'org.springframework.boot:spring-boot-actuator-autoconfigure' - - annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor' - annotationProcessor 'org.springframework.boot:spring-boot-autoconfigure-processor' + compileOnly 'javax.servlet:javax.servlet-api:4.0.1' testImplementation 'com.fasterxml.jackson.core:jackson-databind' testImplementation 'org.springframework:spring-webflux' testImplementation 'org.springframework:spring-webmvc' testImplementation 'io.projectreactor:reactor-test' - testImplementation 'javax.servlet:javax.servlet-api' - testImplementation 'org.springframework.boot:spring-boot-actuator-autoconfigure' - testImplementation 'org.springframework.boot:spring-boot-starter-test' + testImplementation 'javax.servlet:javax.servlet-api:4.0.1' + + testImplementation 'com.jayway.jsonpath:json-path:2.4.0' + testImplementation 'org.assertj:assertj-core:3.18.1' + testImplementation 'org.junit.jupiter:junit-jupiter:5.7.0' + testImplementation 'org.skyscreamer:jsonassert:1.5.0' + testImplementation 'org.springframework:spring-test' } test { diff --git a/spring-graphql-web/src/main/resources/META-INF/spring-devtools.properties b/spring-graphql-web/src/main/resources/META-INF/spring-devtools.properties deleted file mode 100644 index cf65371f..00000000 --- a/spring-graphql-web/src/main/resources/META-INF/spring-devtools.properties +++ /dev/null @@ -1 +0,0 @@ -restart.include.graphql-java=graphql-java.*\.jar \ No newline at end of file diff --git a/spring-graphql-web/src/main/resources/META-INF/spring.factories b/spring-graphql-web/src/main/resources/META-INF/spring.factories deleted file mode 100644 index f190d798..00000000 --- a/spring-graphql-web/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,5 +0,0 @@ -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.springframework.boot.actuate.metrics.graphql.GraphQLMetricsAutoConfiguration,\ -org.springframework.boot.graphql.GraphQLAutoConfiguration,\ -org.springframework.boot.graphql.WebFluxGraphQLAutoConfiguration,\ -org.springframework.boot.graphql.WebMvcGraphQLAutoConfiguration