Skip to content

Commit

Permalink
Upgrade Scala 3 to 3.1.0 (ghostdogpr#1107)
Browse files Browse the repository at this point in the history
* Upgrade Scala 3 to 3.1.0

* Give federation a little help

* Simplify

* Remove weird trick

* Update CI

* Fix name

* Simplify

* Simplify

* fmt

* Simplify

* Cleanup

* Cleanup
  • Loading branch information
ghostdogpr authored Nov 18, 2021
1 parent 8d1d186 commit c9cf645
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
- restore_cache:
key: sbtcache
- run: sbt ++2.13.6! check
- run: sbt ++3.0.2! check
- run: sbt ++3.1.0! check
- save_cache:
key: sbtcache
paths:
Expand Down Expand Up @@ -78,7 +78,7 @@ jobs:
- checkout
- restore_cache:
key: sbtcache
- run: sbt ++3.0.2! core/test catsInterop/compile monixInterop/compile clientJVM/test clientJS/compile zioHttp/compile tapirInterop/test http4s/test federation/test
- run: sbt ++3.1.0! core/test catsInterop/compile monixInterop/compile clientJVM/test clientJS/compile zioHttp/compile tapirInterop/test http4s/test federation/test
- save_cache:
key: sbtcache
paths:
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import sbtcrossproject.CrossPlugin.autoImport.{ crossProject, CrossType }

val scala212 = "2.12.14"
val scala213 = "2.13.7"
val scala3 = "3.0.2"
val scala3 = "3.1.0"
val allScala = Seq(scala212, scala213, scala3)

val akkaVersion = "2.6.15"
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala-3/caliban/Macros.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ object Macros {

private def gqldocImpl(document: Expr[String])(using Quotes): Expr[String] = {
import quotes.reflect.report
document.value.fold(report.throwError("This macro can only be used with string literals."))(
Parser.check(_).fold(document)(e => report.throwError(s"GraphQL document is invalid: $e"))
document.value.fold(report.errorAndAbort("This macro can only be used with string literals."))(
Parser.check(_).fold(document)(e => report.errorAndAbort(s"GraphQL document is invalid: $e"))
)
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package caliban.introspection

import caliban.InputValue
import caliban.Value.StringValue
import caliban.introspection.adt._
import caliban.parsing.adt.Directive
import caliban.schema.Schema

trait IntrospectionDerivation {
implicit lazy val directiveSchema: Schema[Any, Directive] =
Schema.scalarSchema("Directive", None, d => StringValue(d.name))
implicit lazy val inputValueSchema: Schema[Any, __InputValue] = Schema.gen
implicit lazy val enumValueSchema: Schema[Any, __EnumValue] = Schema.gen
implicit lazy val fieldSchema: Schema[Any, __Field] = Schema.gen
import Schema._

implicit lazy val inputValueSchema: Schema[Any, InputValue] = Schema.gen
implicit lazy val typeSchema: Schema[Any, __Type] = Schema.gen
implicit lazy val __directiveSchema: Schema[Any, __Directive] = Schema.gen
val introspectionSchema: Schema[Any, __Introspection] = Schema.gen
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/scala/caliban/schema/Schema.scala
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,8 @@ trait GenericSchema[R] extends SchemaDerivation[R] with TemporalSchema {
arg1: ArgBuilder[A],
ev1: Schema[RA, A],
ev2: Schema[RB, B]
): Schema[RA with RB, A => B] =
new Schema[RA with RB, A => B] {
): Schema[RB, A => B] =
new Schema[RB, A => B] {
private lazy val inputType = ev1.toType_(true)
private val unwrappedArgumentName = "value"
override def arguments: List[__InputValue] =
Expand All @@ -381,7 +381,7 @@ trait GenericSchema[R] extends SchemaDerivation[R] with TemporalSchema {
override def optional: Boolean = ev2.optional
override def toType(isInput: Boolean, isSubscription: Boolean): __Type = ev2.toType_(isInput, isSubscription)

override def resolve(f: A => B): Step[RA with RB] =
override def resolve(f: A => B): Step[RB] =
FunctionStep { args =>
val builder = arg1.build(InputValue.ObjectValue(args))
handleInput(builder)(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ trait Federation {
val resolvers = resolver +: otherResolvers.toList

val genericSchema = new GenericSchema[R] {}
import genericSchema.{ gen, _ }
import genericSchema._

implicit val entitySchema: Schema[R, _Entity] = new Schema[R, _Entity] {
override def toType(isInput: Boolean, isSubscription: Boolean): __Type =
Expand Down Expand Up @@ -110,6 +110,8 @@ trait Federation {

val withSDL = original.withAdditionalTypes(resolvers.map(_.toType).flatMap(Types.collectTypes(_)))

implicit val querySchema: Schema[R, Query] = genericSchema.gen[Query]

GraphQL.graphQL(
RootResolver(
Query(
Expand Down

0 comments on commit c9cf645

Please sign in to comment.