Skip to content

Commit

Permalink
Merge branch 'main' into update/sbt-github-actions-0.24.0
Browse files Browse the repository at this point in the history
  • Loading branch information
yanns authored Jul 9, 2024
2 parents 3133611 + 6eae51b commit 90a147b
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 35 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.12.18, 2.13.12, 3.3.1]
scala: [2.12.18, 2.13.14, 3.3.1]
java: [zulu@8]
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -71,7 +71,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.12]
scala: [2.13.14]
java: [zulu@8]
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -101,12 +101,12 @@ jobs:
tar xf targets.tar
rm targets.tar
- name: Download target directories (2.13.12)
- name: Download target directories (2.13.14)
uses: actions/download-artifact@v4
with:
name: target-${{ matrix.os }}-2.13.12-${{ matrix.java }}
name: target-${{ matrix.os }}-2.13.14-${{ matrix.java }}

- name: Inflate target directories (2.13.12)
- name: Inflate target directories (2.13.14)
run: |
tar xf targets.tar
rm targets.tar
Expand Down
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 3.8.1
version = 3.8.2

runner.dialect = scala213

Expand Down
8 changes: 4 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.typesafe.tools.mima.core._
val isScala3 = Def.setting(scalaBinaryVersion.value == "3")

// sbt-github-actions needs configuration in `ThisBuild`
ThisBuild / crossScalaVersions := Seq("2.12.18", "2.13.12", "3.3.1")
ThisBuild / crossScalaVersions := Seq("2.12.18", "2.13.14", "3.3.1")
ThisBuild / scalaVersion := crossScalaVersions.value.tail.head
ThisBuild / githubWorkflowBuildPreamble ++= List(
WorkflowStep.Sbt(List("mimaReportBinaryIssues"), name = Some("Check binary compatibility")),
Expand Down Expand Up @@ -76,7 +76,7 @@ lazy val parser = project
libraryDependencies ++= Seq(
// AST Parser
"org.parboiled" %% "parboiled" % "2.5.1",
"org.scalatest" %% "scalatest" % "3.2.18" % Test
"org.scalatest" %% "scalatest" % "3.2.19" % Test
),
apiURL := {
val ver = CrossVersion.binaryScalaVersion(scalaVersion.value)
Expand Down Expand Up @@ -206,15 +206,15 @@ lazy val core = project
// Streaming
"org.sangria-graphql" %% "sangria-streaming-api" % "1.0.3",
// Testing
"org.scalatest" %% "scalatest" % "3.2.18" % Test,
"org.scalatest" %% "scalatest" % "3.2.19" % Test,
"org.sangria-graphql" %% "sangria-marshalling-testkit" % "1.0.4" % Test,
"org.sangria-graphql" %% "sangria-spray-json" % "1.0.3" % Test,
"org.sangria-graphql" %% "sangria-argonaut" % "1.0.2" % Test,
"org.sangria-graphql" %% "sangria-ion" % "2.0.1" % Test,
"eu.timepit" %% "refined" % "0.11.2" % Test,
// CATs
("net.jcazevedo" %% "moultingyaml" % "0.4.2" % Test).cross(CrossVersion.for3Use2_13),
"io.github.classgraph" % "classgraph" % "4.8.173" % Test
"io.github.classgraph" % "classgraph" % "4.8.174" % Test
) ++ (if (isScala3.value) Seq.empty
else Seq("org.scala-lang" % "scala-reflect" % scalaVersion.value)), // Macros

Expand Down
62 changes: 38 additions & 24 deletions modules/core/src/main/scala/sangria/execution/FutureResolver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1891,6 +1891,15 @@ private[execution] class FutureResolver[Ctx](
field: Field[Ctx, _],
astFields: Vector[ast.Field],
maxLevel: Int): Vector[ProjectedName] = {

def collectProjectionsInternal(
path: ExecutionPath,
tpe: OutputType[_],
astFields: Vector[ast.Field],
currLevel: Int): Vector[ProjectedName] =
loop(path, tpe, astFields, currLevel)

@tailrec
def loop(
path: ExecutionPath,
tpe: OutputType[_],
Expand All @@ -1904,44 +1913,49 @@ private[execution] class FutureResolver[Ctx](
case objTpe: ObjectType[Ctx, _] =>
fieldCollector.collectFields(path, objTpe, astFields) match {
case Success(ff) =>
ff.fields.collect {
case CollectedField(_, _, Success(fields))
if objTpe.getField(schema, fields.head.name).nonEmpty && !objTpe
.getField(schema, fields.head.name)
.head
.tags
.contains(ProjectionExclude) =>
val astField = fields.head
val field = objTpe.getField(schema, astField.name).head
val projectionNames = field.tags.iterator.collect { case ProjectionName(name) =>
name
}.toVector

val projectedName =
if (projectionNames.nonEmpty) projectionNames
else Vector(field.name)

projectedName.map(name =>
ProjectedName(
name,
loop(path.add(astField, objTpe), field.fieldType, fields, currLevel + 1),
Args(field, astField, variables)))
ff.fields.collect { case CollectedField(_, _, Success(astFields)) =>
val astField = astFields.head
val fields = objTpe.getField(schema, astField.name)
if (fields.isEmpty) Vector.empty
else {
val field = fields.head
if (field.tags.contains(ProjectionExclude)) Vector.empty
else {
val projectionNames = field.tags.iterator.collect {
case ProjectionName(name) => name
}

val projectedName =
if (projectionNames.nonEmpty) projectionNames
else Iterator.single(field.name)

projectedName.map { name =>
val children =
collectProjectionsInternal(
path.add(astField, objTpe),
field.fieldType,
astFields,
currLevel + 1)
ProjectedName(name, children, Args(field, astField, variables))
}
}
}
}.flatten
case Failure(_) => Vector.empty
}
case abst: AbstractType =>
schema.possibleTypes
.get(abst.name)
.map(
_.flatMap(loop(path, _, astFields, currLevel + 1))
_.flatMap(collectProjectionsInternal(path, _, astFields, currLevel + 1))
.groupBy(_.name)
.map(_._2.head)
.toVector)
.getOrElse(Vector.empty)
case _ => Vector.empty
}

loop(path, field.fieldType, astFields, 1)
collectProjectionsInternal(path, field.fieldType, astFields, 1)
}

private def isOptional(tpe: ObjectType[_, _], fieldName: String): Boolean =
Expand Down
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.3")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.12")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.1.0")
addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.3.11")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.7")
addSbtPlugin("com.github.sbt" % "sbt-github-actions" % "0.24.0")
Expand Down

0 comments on commit 90a147b

Please sign in to comment.