Skip to content

Commit 357fddc

Browse files
committed
Cross-compile to scala 3
1 parent 28c1fb8 commit 357fddc

File tree

14 files changed

+47
-20
lines changed

14 files changed

+47
-20
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
strategy:
2424
matrix:
2525
os: [ubuntu-latest]
26-
scala: [2.12.20, 2.13.16]
26+
scala: [2.12.20, 2.13.16, 3.3.4]
2727
java: [zulu@8]
2828
runs-on: ${{ matrix.os }}
2929
steps:
@@ -68,7 +68,7 @@ jobs:
6868
strategy:
6969
matrix:
7070
os: [ubuntu-latest]
71-
scala: [2.13.16]
71+
scala: [3.3.4]
7272
java: [zulu@8]
7373
runs-on: ${{ matrix.os }}
7474
steps:
@@ -108,6 +108,16 @@ jobs:
108108
tar xf targets.tar
109109
rm targets.tar
110110
111+
- name: Download target directories (3.3.4)
112+
uses: actions/download-artifact@v4
113+
with:
114+
name: target-${{ matrix.os }}-3.3.4-${{ matrix.java }}
115+
116+
- name: Inflate target directories (3.3.4)
117+
run: |
118+
tar xf targets.tar
119+
rm targets.tar
120+
111121
- env:
112122
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
113123
PGP_SECRET: ${{ secrets.PGP_SECRET }}

.scalafmt.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ version = 3.9.4
22

33
runner.dialect = scala213
44

5+
fileOverride {
6+
"glob:**/src/main/scala-3/**" {
7+
runner.dialect = scala3
8+
}
9+
}
10+
511
maxColumn = 100
612

713
// Vertical alignment is pretty, but leads to bigger diffs

build.sbt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ inThisBuild(
1616
)
1717
)
1818

19+
val isScala3 = Def.setting(scalaBinaryVersion.value == "3")
20+
1921
// Build
20-
ThisBuild / crossScalaVersions := Seq("2.12.20", "2.13.16")
22+
ThisBuild / crossScalaVersions := Seq("2.12.20", "2.13.16", "3.3.4")
2123
ThisBuild / scalaVersion := crossScalaVersions.value.last
2224
ThisBuild / githubWorkflowBuildPreamble ++= List(
2325
WorkflowStep.Sbt(List("scalafmtCheckAll"), name = Some("Check formatting"))
@@ -124,7 +126,10 @@ def newProject(name: String) =
124126

125127
lazy val commonSettings = Seq(
126128
scalacOptions ++= Seq("-deprecation", "-feature"),
127-
scalacOptions += "-target:jvm-1.8",
129+
scalacOptions ++= {
130+
if (scalaVersion.value.startsWith("2.12")) Seq.empty
131+
else Seq("-release", "8")
132+
},
128133
javacOptions ++= Seq("-source", "8", "-target", "8")
129134
)
130135

core/src/main/scala/sangria/federation/v1/Federation.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package sangria.federation.v1
22

33
import sangria.ast
4-
import sangria.marshalling.InputUnmarshaller
4+
import sangria.marshalling.{FromInput, InputUnmarshaller}
55
import sangria.renderer.SchemaFilter
66
import sangria.schema._
7+
import sangria.util.tag.@@
78

89
object Federation {
910
import Query._
@@ -43,8 +44,8 @@ object Federation {
4344
"Query" -> Map(
4445
"_service" -> (_ => _Service(sdl)),
4546
"_entities" -> (ctx =>
46-
ctx.withArgs(representationsArg) { anys =>
47-
Action.sequence(anys.map { any =>
47+
ctx.withArgs(representationsArg) { (anys: Seq[_Any[Node]]) =>
48+
Action.sequence(anys.map { (any: _Any[Node]) =>
4849
val typeName = any.__typename
4950
val resolver = resolversMap.getOrElse(
5051
typeName,

core/src/main/scala/sangria/federation/v2/Federation.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package sangria.federation.v2
22

33
import sangria.ast
4+
import sangria.federation.v2._Any
45
import sangria.federation.v2.Directives.{ComposeDirective, Link}
56
import sangria.marshalling.InputUnmarshaller
67
import sangria.renderer.SchemaFilter
@@ -128,8 +129,8 @@ object Federation {
128129
"Query" -> Map(
129130
"_service" -> (_ => _Service(sdl)),
130131
"_entities" -> (ctx =>
131-
ctx.withArgs(representationsArg) { anys =>
132-
Action.sequence(anys.map { any =>
132+
ctx.withArgs(representationsArg) { (anys: Seq[_Any[Node]]) =>
133+
Action.sequence(anys.map { (any: _Any[Node]) =>
133134
val typeName = any.__typename
134135
val resolver = resolversMap.getOrElse(
135136
typeName,

core/src/test/scala/sangria/federation/package.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ package object federation {
1111
val spec: String = "https://specs.apollo.dev/federation/v2.3"
1212

1313
def beCompatibleWith(expectedSchema: Schema[_, _]): Matcher[Schema[_, _]] =
14-
Matcher { schema: Schema[_, _] =>
14+
Matcher { (schema: Schema[_, _]) =>
1515
val changes = schema.compare(expectedSchema)
1616

1717
MatchResult(
@@ -24,7 +24,7 @@ package object federation {
2424
private def pretty(v: Vector[_]): String = v.mkString("\n - ", "\n - ", "")
2525

2626
def importFederationDirective(name: String): Matcher[Schema[_, _]] =
27-
Matcher { schema: Schema[_, _] =>
27+
Matcher { (schema: Schema[_, _]) =>
2828
val links = schema.astDirectives.filter(d => d.name == "link")
2929
val link = links.find(d =>
3030
d.arguments.exists(arg => arg.name == "url" && arg.value == ast.StringValue(spec)))
@@ -61,7 +61,7 @@ package object federation {
6161
}
6262

6363
def renderLike(expected: String): Matcher[ast.Directive] =
64-
Matcher { directive: ast.Directive =>
64+
Matcher { (directive: ast.Directive) =>
6565
val rendered = QueryRenderer.renderPretty(directive)
6666
be(expected)(rendered)
6767
}

core/src/test/scala/sangria/federation/tracing/ApolloFederationTracingSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import org.scalatest.matchers.should.Matchers
88
import org.scalatest.wordspec.AsyncWordSpec
99
import reports.Trace
1010
import sangria.execution.Executor
11-
import sangria.macros.LiteralGraphQLStringContext
11+
import sangria.macros._
1212
import sangria.marshalling.ScalaInput
1313
import sangria.marshalling.circe._
1414

core/src/test/scala/sangria/federation/v1/FederationSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import sangria.ast.Document
1010
import sangria.execution.{Executor, VariableCoercionError}
1111
import sangria.federation._
1212
import sangria.federation.v1.Directives.Key
13-
import sangria.macros.LiteralGraphQLStringContext
13+
import sangria.macros._
1414
import sangria.parser.QueryParser
1515
import sangria.renderer.QueryRenderer
1616
import sangria.schema._

core/src/test/scala/sangria/federation/v2/ComposeDirectiveSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import sangria.ast
66
import sangria.federation.importFederationDirective
77
import sangria.federation.v2.ComposeDirectiveSpec.{helloDirective, initialSchema, myDirective}
88
import sangria.federation.v2.Directives.{ComposeDirective, Link}
9-
import sangria.macros.LiteralGraphQLStringContext
9+
import sangria.macros._
1010
import sangria.renderer.SchemaRenderer
1111
import sangria.schema._
1212
import sangria.util.tag.@@

core/src/test/scala/sangria/federation/v2/FederationSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import sangria.execution.deferred.{DeferredResolver, Fetcher, HasId}
99
import sangria.execution.{Executor, VariableCoercionError}
1010
import sangria.federation._
1111
import sangria.federation.v2.Directives.Key
12-
import sangria.macros.LiteralGraphQLStringContext
12+
import sangria.macros._
1313
import sangria.parser.QueryParser
1414
import sangria.renderer.{QueryRenderer, SchemaRenderer}
1515
import sangria.schema._

0 commit comments

Comments
 (0)