From fb718161d925e9fa84b424bcf87edc3285a3f94f Mon Sep 17 00:00:00 2001 From: Nepomuk Seiler Date: Sat, 13 Jan 2018 16:33:15 +0100 Subject: [PATCH] Use newest feature in the test-project --- .../muki/graphql/GraphQLSchemaPlugin.scala | 1 + test-project/build.sbt | 65 +++++++++++++------ .../src/main/graphql/heroAndFriends.graphql | 0 .../src/it}/graphql/broken.graphql | 0 .../src/it/graphql/heroAndFriends.graphql | 8 +++ .../src/it}/graphql/product.graphql | 0 .../src/it}/graphql/specificProduct.graphql | 0 .../src/main/resources/schema.graphql | 0 .../main/scala/example/ProductSchema.scala | 5 +- .../main/scala/example/StarWarsSchema.scala | 0 10 files changed, 56 insertions(+), 23 deletions(-) rename test-project/{ => client}/src/main/graphql/heroAndFriends.graphql (100%) rename test-project/{src/main => server/src/it}/graphql/broken.graphql (100%) create mode 100644 test-project/server/src/it/graphql/heroAndFriends.graphql rename test-project/{src/main => server/src/it}/graphql/product.graphql (100%) rename test-project/{src/main => server/src/it}/graphql/specificProduct.graphql (100%) rename test-project/{ => server}/src/main/resources/schema.graphql (100%) rename test-project/{ => server}/src/main/scala/example/ProductSchema.scala (95%) rename test-project/{ => server}/src/main/scala/example/StarWarsSchema.scala (100%) diff --git a/src/main/scala/rocks/muki/graphql/GraphQLSchemaPlugin.scala b/src/main/scala/rocks/muki/graphql/GraphQLSchemaPlugin.scala index e60c010..9c0a649 100644 --- a/src/main/scala/rocks/muki/graphql/GraphQLSchemaPlugin.scala +++ b/src/main/scala/rocks/muki/graphql/GraphQLSchemaPlugin.scala @@ -1,5 +1,6 @@ package rocks.muki.graphql +import rocks.muki.graphql.releasenotes.MarkdownReleaseNotes import rocks.muki.graphql.schema.SchemaLoader import sangria.schema._ import sbt._ diff --git a/test-project/build.sbt b/test-project/build.sbt index 41d0a78..67ee38b 100644 --- a/test-project/build.sbt +++ b/test-project/build.sbt @@ -1,25 +1,50 @@ -name := "graphql-test-project" -version := "0.4" +lazy val root = project.in(file(".")) + .aggregate(server, client) -enablePlugins(GraphQLSchemaPlugin, GraphQLQueryPlugin) +lazy val server = project.in(file("server")) + .enablePlugins(GraphQLSchemaPlugin, GraphQLQueryPlugin) + .configs(IntegrationTest) + .settings(commonSettings, Defaults.itSettings) + .settings( + graphqlSchemaSnippet := "example.StarWarsSchema.schema", + // integration settings + graphqlQueryDirectory in IntegrationTest := (sourceDirectory in IntegrationTest).value / "graphql" + ) + .settings( + addCommandAlias("validateSangriaExample", "graphqlValidateSchema build sangria-example") + ) -libraryDependencies ++= Seq( - "org.sangria-graphql" %% "sangria" % "1.3.0", - "org.sangria-graphql" %% "sangria-circe" % "1.1.0" -) - -graphqlSchemaSnippet := "example.StarWarsSchema.schema" +lazy val client = project.in(file("client")) + .enablePlugins(GraphQLCodegenPlugin, GraphQLQueryPlugin) + .settings(commonSettings) + .settings( + graphqlCodegenSchema := graphqlRenderSchema.toTask("starwars").value, + resourceDirectories in graphqlCodegen := List( + (sourceDirectory in Compile).value / "graphql", + ), + graphqlCodegenPackage := "rocks.muki.graphql", + name in graphqlCodegen := "Api", + // includeFilter in graphqlCodegen := "product.graphql" + ) -graphqlSchemas += GraphQLSchema( - "sangria-example", - "staging schema at http://try.sangria-graphql.org/graphql", - Def.task( - GraphQLSchemaLoader - .fromIntrospection("http://try.sangria-graphql.org/graphql", streams.value.log) - .withHeaders("User-Agent" -> "sbt-graphql/${version.value}") - .loadSchema() - ).taskValue +lazy val commonSettings = Seq( + version := "0.4", + scalaVersion := "2.12.4", + organization := "rocks.muki", + libraryDependencies ++= Seq( + "org.sangria-graphql" %% "sangria" % "1.3.2", + "org.sangria-graphql" %% "sangria-circe" % "1.1.0" + ), + // define schemas available in all builds + graphqlSchemas += GraphQLSchema( + "starwars", + "starwars schema at http://try.sangria-graphql.org/graphql", + Def.task( + GraphQLSchemaLoader + .fromIntrospection("http://try.sangria-graphql.org/graphql", streams.value.log) + .withHeaders("User-Agent" -> s"sbt-graphql/${version.value}") + .loadSchema() + ).taskValue + ) ) - -addCommandAlias("validateSangriaExample", "graphqlValidateSchema build sangria-example") diff --git a/test-project/src/main/graphql/heroAndFriends.graphql b/test-project/client/src/main/graphql/heroAndFriends.graphql similarity index 100% rename from test-project/src/main/graphql/heroAndFriends.graphql rename to test-project/client/src/main/graphql/heroAndFriends.graphql diff --git a/test-project/src/main/graphql/broken.graphql b/test-project/server/src/it/graphql/broken.graphql similarity index 100% rename from test-project/src/main/graphql/broken.graphql rename to test-project/server/src/it/graphql/broken.graphql diff --git a/test-project/server/src/it/graphql/heroAndFriends.graphql b/test-project/server/src/it/graphql/heroAndFriends.graphql new file mode 100644 index 0000000..bee15c5 --- /dev/null +++ b/test-project/server/src/it/graphql/heroAndFriends.graphql @@ -0,0 +1,8 @@ +query HeroAndFriends { + hero { + name + friends { + name + } + } +} \ No newline at end of file diff --git a/test-project/src/main/graphql/product.graphql b/test-project/server/src/it/graphql/product.graphql similarity index 100% rename from test-project/src/main/graphql/product.graphql rename to test-project/server/src/it/graphql/product.graphql diff --git a/test-project/src/main/graphql/specificProduct.graphql b/test-project/server/src/it/graphql/specificProduct.graphql similarity index 100% rename from test-project/src/main/graphql/specificProduct.graphql rename to test-project/server/src/it/graphql/specificProduct.graphql diff --git a/test-project/src/main/resources/schema.graphql b/test-project/server/src/main/resources/schema.graphql similarity index 100% rename from test-project/src/main/resources/schema.graphql rename to test-project/server/src/main/resources/schema.graphql diff --git a/test-project/src/main/scala/example/ProductSchema.scala b/test-project/server/src/main/scala/example/ProductSchema.scala similarity index 95% rename from test-project/src/main/scala/example/ProductSchema.scala rename to test-project/server/src/main/scala/example/ProductSchema.scala index 6ed8c30..8bb9b94 100644 --- a/test-project/src/main/scala/example/ProductSchema.scala +++ b/test-project/server/src/main/scala/example/ProductSchema.scala @@ -27,8 +27,8 @@ object ProductSchema { Field("width", IntType, resolve = _.value.width), Field("height", IntType, resolve = _.value.height), Field("url", OptionType(StringType), - description = Some("Picture CDN URL"), - resolve = _.value.url))) + description = Some("Picture CDN URL"), + resolve = _.value.url))) val IdentifiableType = InterfaceType( "Identifiable", @@ -69,4 +69,3 @@ class ProductRepo { def products: List[Product] = Products } - diff --git a/test-project/src/main/scala/example/StarWarsSchema.scala b/test-project/server/src/main/scala/example/StarWarsSchema.scala similarity index 100% rename from test-project/src/main/scala/example/StarWarsSchema.scala rename to test-project/server/src/main/scala/example/StarWarsSchema.scala