Skip to content

Commit

Permalink
Merge d4fa9b9 into 65ffe26
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonAdameit committed Nov 8, 2019
2 parents 65ffe26 + d4fa9b9 commit b55f27f
Show file tree
Hide file tree
Showing 202 changed files with 9,730 additions and 7,801 deletions.
4 changes: 4 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
template: |
## What’s Changed
$CHANGES
9 changes: 5 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
language: scala
scala:
- 2.12.7
- 2.11.11
- 2.11.12
- 2.12.10
- 2.13.0
jdk:
- oraclejdk8
- openjdk8
- openjdk11

matrix:
exclude:
- scala: 2.11.11
- scala: 2.11.12
jdk: openjdk11

script: |
Expand Down
52 changes: 26 additions & 26 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,12 @@ If you are facing unexpected issues with migration to the new Sangria version, p
```scala
// Before
val exceptionHandler: Executor.ExceptionHandler = {
case (m, ...) ...
case (m, ...) => ...
})

// After
val exceptionHandler = ExceptionHandler {
case (m, ...) ...
case (m, ...) => ...
}
```

Expand Down Expand Up @@ -513,7 +513,7 @@ A minor maintenance release to keep up with the spec changes.

```scala
Executor.execute(schema, query).recover {
case error: ErrorWithResolver error.resolveError
case error: ErrorWithResolver => error.resolveError
}
```

Expand All @@ -525,8 +525,8 @@ A minor maintenance release to keep up with the spec changes.
executor.execute(query, ...)
.map(Ok(_))
.recover {
case error: QueryAnalysisError BadRequest(error.resolveError)
case error: ErrorWithResolver InternalServerError(error.resolveError)
case error: QueryAnalysisError => BadRequest(error.resolveError)
case error: ErrorWithResolver => InternalServerError(error.resolveError)
}
```

Expand All @@ -536,18 +536,18 @@ A minor maintenance release to keep up with the spec changes.

```scala
val authReducer = QueryReducer.collectTags[MyContext, String] {
case Permission(name) name
} { (permissionNames, ctx)
case Permission(name) => name
} { (permissionNames, ctx) =>
if (ctx.isUserAuthorized(permissionNames)) ctx
else throw AuthorizationException("User is not authorized!")
}

Executor.execute(schema, queryAst, userContext = new MyContext, queryReducers = authReducer :: Nil)
.map(Ok(_))
.recover {
case QueryReducingError(error: AuthorizationException) Unauthorized(error.getMessage)
case error: QueryAnalysisError BadRequest(error.resolveError)
case error: ErrorWithResolver InternalServerError(error.resolveError)
case QueryReducingError(error: AuthorizationException) => Unauthorized(error.getMessage)
case error: QueryAnalysisError => BadRequest(error.resolveError)
case error: ErrorWithResolver => InternalServerError(error.resolveError)
}
```

Expand Down Expand Up @@ -752,18 +752,18 @@ A minor maintenance release to keep up with the spec changes.
objects like:
```scala
// for JSON input: {"op1": "foo", "opt2": null}
Map("opt1" Some("foo"), "opt2" None)
Map("opt1" -> Some("foo"), "opt2" -> None)

// for JSON input: {"op1": "foo"}
Map("opt1" Some("foo"))
Map("opt1" -> Some("foo"))
```
instead of (old format):
```scala
// for JSON input: {"op1": "foo", "opt2": null}
Map("opt1" "foo")
Map("opt1" -> "foo")

// for JSON input: {"op1": "foo"}
Map("opt1" "foo")
Map("opt1" -> "foo")
```
As you can see, this allows you to distinguish between "undefined" json object fields and json object fields that are set to `null`.
* `null` value support (as defined in the spec change: https://github.com/facebook/graphql/pull/83) (#55) (spec change)
Expand Down Expand Up @@ -822,7 +822,7 @@ A minor maintenance release to keep up with the spec changes.
complexity analysis (introduced in previous release), but in much more generic form. That's because complexity analysis is now rewritten as
a `QueryReducer`. In order to migrate, you need to replace `measureComplexity` function with `QueryReducer.measureComplexity`. Here is an example:
```scala
val complReducer = QueryReducer.measureComplexity[MyCtx] { (c, ctx)
val complReducer = QueryReducer.measureComplexity[MyCtx] { (c, ctx) =>
complexity = c
ctx
}
Expand All @@ -833,7 +833,7 @@ A minor maintenance release to keep up with the spec changes.
```
Since rejection of complex queries is such a common use-case, there is now a helper function to create a reducer for it:
```scala
val rejectComplexQuery = QueryReducer.rejectComplexQueries[MyCtx](14, (c, ctx)
val rejectComplexQuery = QueryReducer.rejectComplexQueries[MyCtx](14, (c, ctx) =>
new IllegalArgumentException(s"Too complex query: max allowed complexity is 14.0, but got $c"))
```
* `Middleware` got a type parameter for `Ctx`. This is a minor breaking change. If you don't use the `userContext` inside of the `Middleware`,
Expand All @@ -848,18 +848,18 @@ A minor maintenance release to keep up with the spec changes.
```scala
Field("pets", OptionType(ListType(PetType)),
arguments = Argument("limit", IntType) :: Nil,
complexity = Some((args, childrenScore) 25.0D + args.arg[Int]("limit") * childrenScore),
resolve = ctx ...)
complexity = Some((args, childrenScore) => 25.0D + args.arg[Int]("limit") * childrenScore),
resolve = ctx => ...)
```
If you would like to use this feature, you need to provide `measureComplexity` argument to the `Executor`. For example:
```scala
val rejectComplexQueries = (c: Double)
val rejectComplexQueries = (c: Double) =>
if (c > 1000)
throw new IllegalArgumentException(s"Too complex query: max allowed complexity is 1000.0, but got $c")
else ()

val exceptionHandler: Executor.ExceptionHandler = {
case (m, e: IllegalArgumentException) HandledException(e.getMessage)
case (m, e: IllegalArgumentException) => HandledException(e.getMessage)
}

Executor.execute(schema, query,
Expand Down Expand Up @@ -927,20 +927,20 @@ I collected all of them in the change list below. They were necessary in order t
* #76 - You can now provide `maxQueryDepth` to `Executor`. It will then enforce this constraint for all queries (very useful if query has recursive types) [Docs](http://sangria-graphql.org/learn/#limiting-query-depth)
* #69 - `DeferredResolver` now got `userContext` as an argument. (breaking change: you need to provide a type parameter and one extra argument in `resolve` for your `DeferredResolver`s. you you are not interested in `userContext`, you can just use `Any` type)
* Renamed Json support objects in order to make more concise import syntax (breaking change: you need to rename imports as well):
* `sangria.integration.CirceSupport` `sangria.integration.circe`
* `sangria.integration.Json4sSupport` `sangria.integration.json4s`
* `sangria.integration.PlayJsonSupport` `sangria.integration.playJson`
* `sangria.integration.SprayJsonSupport` `sangria.integration.sprayJson`
* `sangria.integration.CirceSupport` -> `sangria.integration.circe`
* `sangria.integration.Json4sSupport` -> `sangria.integration.json4s`
* `sangria.integration.PlayJsonSupport` -> `sangria.integration.playJson`
* `sangria.integration.SprayJsonSupport` -> `sangria.integration.sprayJson`
* `ResultMarshaller` and `InputUnmarshaller` are moved in the `integration` package
* Renamed execution `arguments` to `variables` in order to be consistent with the spec (breaking change: you need to rename this argument as well, if you are using named arguments)
* Refactored variables and `InputUnmarshaller`. In order to avoid extra complexity it now does not have a dependent type. Instead it uses "type tagging" for scala map variables.
It's a minor breaking change. If you are providing execution variables as a scala map, then you need to use `mapVars` or `emptyMapVars` which are defined in `InputUnmarshaller` companion object (these functions do not wrap `Map` - they only needed to ensure type constraints):
```scala
Executor.execute(mySchema, query, variables = mapVars(Map("someId" "1000")))
Executor.execute(mySchema, query, variables = mapVars(Map("someId" -> "1000")))

// or

Executor.execute(mySchema, query, variables = mapVars("someId" "1000"))
Executor.execute(mySchema, query, variables = mapVars("someId" -> "1000"))
```
* #72 - `scala.util.Try` now can be returned from `resolve` in order to indicate a successful or failed result
* #65 - `DeprecationTracker` should be called even if deprecation is in the interface type
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[Sangria](http://sangria-graphql.org/) is a scala [GraphQL](http://facebook.github.io/graphql/) library.

[![Build Status](https://travis-ci.org/sangria-graphql/sangria.svg?branch=master)](https://travis-ci.org/sangria-graphql/sangria) [![Coverage Status](http://coveralls.io/repos/sangria-graphql/sangria/badge.svg?branch=master&service=github)](http://coveralls.io/github/sangria-graphql/sangria?branch=master) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.sangria-graphql/sangria_2.11/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.sangria-graphql/sangria_2.11) [![License](http://img.shields.io/:license-Apache%202-brightgreen.svg)](http://www.apache.org/licenses/LICENSE-2.0.txt) [![Scaladocs](https://www.javadoc.io/badge/org.sangria-graphql/sangria_2.12.svg?label=docs)](https://www.javadoc.io/doc/org.sangria-graphql/sangria_2.12) [![Join the chat at https://gitter.im/sangria-graphql/sangria](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/sangria-graphql/sangria?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build Status](https://travis-ci.org/sangria-graphql-org/sangria.svg?branch=master)](https://travis-ci.org/sangria-graphql-org/sangria) [![Coverage Status](http://coveralls.io/repos/sangria-graphql-org/sangria/badge.svg?branch=master&service=github)](http://coveralls.io/github/sangria-graphql-org/sangria?branch=master) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.sangria-graphql/sangria_2.11/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.sangria-graphql/sangria_2.11) [![License](http://img.shields.io/:license-Apache%202-brightgreen.svg)](http://www.apache.org/licenses/LICENSE-2.0.txt) [![Scaladocs](https://www.javadoc.io/badge/org.sangria-graphql/sangria_2.12.svg?label=docs)](https://www.javadoc.io/doc/org.sangria-graphql/sangria_2.12) [![Join the chat at https://gitter.im/sangria-graphql/sangria](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/sangria-graphql/sangria?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

SBT Configuration:

Expand Down Expand Up @@ -45,7 +45,7 @@ import sangria.marshalling.circe._
import scala.concurrent.ExecutionContext.Implicits.global

val QueryType = ObjectType("Query", fields[Unit, Unit](
Field("hello", StringType, resolve = _ "Hello world!")
Field("hello", StringType, resolve = _ => "Hello world!")
))

val schema = Schema(QueryType)
Expand All @@ -54,7 +54,7 @@ val query = graphql"{ hello }"

val result = Executor.execute(schema, query)

result.foreach(res println(res.spaces2))
result.foreach(res => println(res.spaces2))
```

this example will print following result JSON:
Expand Down
64 changes: 37 additions & 27 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,64 +1,74 @@
name := "sangria"
organization := "org.sangria-graphql"
version := "1.4.3-SNAPSHOT"
mimaPreviousArtifacts := Set("org.sangria-graphql" %% "sangria" % "1.4.2")

description := "Scala GraphQL implementation"
homepage := Some(url("http://sangria-graphql.org"))
licenses := Seq("Apache License, ASL Version 2.0" url("http://www.apache.org/licenses/LICENSE-2.0"))
licenses := Seq("Apache License, ASL Version 2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0"))

scalaVersion := "2.12.7"
crossScalaVersions := Seq("2.11.11", "2.12.7")
scalaVersion := "2.13.0"
crossScalaVersions := Seq("2.11.12", "2.12.10", scalaVersion.value)

scalacOptions ++= Seq(
"-deprecation",
"-feature",
"-Xlint:-missing-interpolator,-unused,_")
"-Xlint:-missing-interpolator,_")

scalacOptions ++= {
if (scalaVersion.value startsWith "2.12")
Seq.empty
else
if (scalaVersion.value startsWith "2.11")
Seq("-target:jvm-1.7")
else
Seq.empty
}

testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-oF")

libraryDependencies ++= Seq(
// AST Parser
"org.parboiled" %% "parboiled" % "2.1.4",
"org.parboiled" %% "parboiled" % "2.1.8",

// AST Visitor
"org.sangria-graphql" %% "macro-visit" % "0.1.1",
"org.sangria-graphql" %% "macro-visit" % "0.1.2",

// Marshalling
"org.sangria-graphql" %% "sangria-marshalling-api" % "1.0.3",
"org.sangria-graphql" %% "sangria-marshalling-api" % "1.0.4",

// Streaming
"org.sangria-graphql" %% "sangria-streaming-api" % "1.0.0",
"org.sangria-graphql" %% "sangria-streaming-api" % "1.0.1",

// Macros
"org.scala-lang" % "scala-reflect" % scalaVersion.value,

// Testing
"org.scalatest" %% "scalatest" % "3.0.5" % "test",
"org.sangria-graphql" %% "sangria-marshalling-testkit" % "1.0.1" % Test,
"org.sangria-graphql" %% "sangria-spray-json" % "1.0.1" % Test,
"org.sangria-graphql" %% "sangria-argonaut" % "1.0.0" % Test,
"org.sangria-graphql" %% "sangria-ion" % "1.0.0" % Test,
"org.sangria-graphql" %% "sangria-monix" % "1.0.0" % Test,
"org.sangria-graphql" %% "sangria-rxscala" % "1.0.0" % Test,
"eu.timepit" %% "refined" % "0.9.2" % Test,
"co.fs2" %% "fs2-core" % "2.1.0" % Test,
"org.scalatest" %% "scalatest" % "3.0.8" % Test,
"org.sangria-graphql" %% "sangria-marshalling-testkit" % "1.0.2" % Test,
"org.sangria-graphql" %% "sangria-spray-json" % "1.0.2" % Test,
"org.sangria-graphql" %% "sangria-argonaut" % "1.0.1" % Test,
"org.sangria-graphql" %% "sangria-ion" % "2.0.0" % Test,
"org.sangria-graphql" %% "sangria-monix" % "2.0.0" % Test,
"eu.timepit" %% "refined" % "0.9.10" % Test,

// CATs
"net.jcazevedo" %% "moultingyaml" % "0.4.0" % Test,
"io.github.classgraph" % "classgraph" % "4.0.6" % Test
"net.jcazevedo" %% "moultingyaml" % "0.4.1" % Test,
"io.github.classgraph" % "classgraph" % "4.8.53" % Test
)

// Publishing
// Benchmarking

enablePlugins(JmhPlugin)
sourceDirectory in Jmh := (sourceDirectory in Test).value
classDirectory in Jmh := (classDirectory in Test).value
dependencyClasspath in Jmh := (dependencyClasspath in Test).value
compile in Jmh := (compile in Jmh).dependsOn(compile in Test).value
run in Jmh := (run in Jmh).dependsOn(compile in Jmh).evaluated

// Publishing
releaseCrossBuild := true
releasePublishArtifactsAction := PgpKeys.publishSigned.value
publishMavenStyle := true
publishArtifact in Test := false
pomIncludeRepository := (_ false)
pomIncludeRepository := (_ => false)
publishTo := Some(
if (isSnapshot.value)
"snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
Expand All @@ -69,12 +79,12 @@ startYear := Some(2015)
organizationHomepage := Some(url("https://github.com/sangria-graphql"))
developers := Developer("OlegIlyenko", "Oleg Ilyenko", "", url("https://github.com/OlegIlyenko")) :: Nil
scmInfo := Some(ScmInfo(
browseUrl = url("https://github.com/sangria-graphql/sangria.git"),
connection = "scm:git:git@github.com:sangria-graphql/sangria.git"
browseUrl = url("https://github.com/sangria-graphql-org/sangria.git"),
connection = "scm:git:git@github.com:sangria-graphql-org/sangria.git"
))

// nice *magenta* prompt!

shellPrompt in ThisBuild := { state
shellPrompt in ThisBuild := { state =>
scala.Console.MAGENTA + Project.extract(state).currentRef.project + "> " + scala.Console.RESET
}
1 change: 1 addition & 0 deletions project/benchmarks.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.3.7")
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.2.3
sbt.version=1.3.3
2 changes: 0 additions & 2 deletions project/coverage.sbt

This file was deleted.

10 changes: 10 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
resolvers += Resolver.url(
"typesafe sbt-plugins",
url("https://dl.bintray.com/typesafe/sbt-plugins")
)(Resolver.ivyStylePatterns)

addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.12")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.0")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.6.1")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.0")
addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.2.7")
Loading

0 comments on commit b55f27f

Please sign in to comment.