Skip to content

Commit

Permalink
Use newest feature in the test-project
Browse files Browse the repository at this point in the history
  • Loading branch information
muuki88 committed Jan 13, 2018
1 parent 8b1b1b0 commit fb71816
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -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._
Expand Down
65 changes: 45 additions & 20 deletions test-project/build.sbt
Original file line number Diff line number Diff line change
@@ -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")
8 changes: 8 additions & 0 deletions test-project/server/src/it/graphql/heroAndFriends.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
query HeroAndFriends {
hero {
name
friends {
name
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -69,4 +69,3 @@ class ProductRepo {

def products: List[Product] = Products
}

0 comments on commit fb71816

Please sign in to comment.