Skip to content

Commit

Permalink
Adds deprecated fields
Browse files Browse the repository at this point in the history
  • Loading branch information
hwielenberg committed Jul 24, 2024
1 parent 9a18e0b commit 06b76b1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 18 deletions.
42 changes: 26 additions & 16 deletions tools/src/test/scala/caliban/tools/IntrospectionClientSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,27 @@ import caliban.schema.Annotations._
import caliban.schema.Schema.auto._
import caliban.schema.ArgBuilder.auto._
import zio.test._
import zio.{Clock, durationInt}
import zio.{ durationInt, Clock }

object IntrospectionClientSpec extends ZIOSpecDefault {

case class Args(@GQLDeprecated("Use nameV2") name:Option[String] = Some("defaultValue"), nameV2:String)
case class MyObject(
@GQLDeprecated("dep required") name: String,
@GQLDeprecated("dep optional") length: Option[Int]
)

case class Args(@GQLDeprecated("Use nameV2") name: Option[String] = Some("defaultValue"), nameV2: String)

case class Queries(
getObject: Args => String
)
getObject: Args => MyObject
)

object Resolvers {
def getObject(@GQLDeprecated("foobar") args: Args): String =
args.name.getOrElse("")
def getObject(@GQLDeprecated("foobar") args: Args): MyObject =
MyObject(
args.name.getOrElse(""),
Some(3)
)
}

val queries = Queries(
Expand All @@ -34,17 +42,19 @@ object IntrospectionClientSpec extends ZIOSpecDefault {
def spec = suite("IntrospectionClientSpec")(
test("is isomorphic") {
for {
_ <- api.runServer(
port = 8087,
apiPath = "/api/graphql",
).fork
_ <- Clock.ClockLive.sleep(2.seconds)
_ <- api
.runServer(
port = 8087,
apiPath = "/api/graphql"
)
.fork
_ <- Clock.ClockLive.sleep(2.seconds)
introspectedSchema = SchemaLoader.fromIntrospection("http://localhost:8087/api/graphql", None)
codeSchema = SchemaLoader.fromCaliban(api)
res <- SchemaComparison.compare(
introspectedSchema,
codeSchema
)
codeSchema = SchemaLoader.fromCaliban(api)
res <- SchemaComparison.compare(
introspectedSchema,
codeSchema
)
} yield assertTrue(res.isEmpty, false)
}
)
Expand Down
4 changes: 2 additions & 2 deletions tools/src/test/scala/caliban/tools/RemoteSchemaSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ object RemoteSchemaSpec extends ZIOSpecDefault {

case class Object(
field: Int,
optionalField: Option[Float],
@GQLDeprecated("dep optional") optionalField: Option[Float],
withDefault: Option[String] = Some("defaultValue"),
enumField: EnumType,
@GQLDeprecated("dep required") enumField: EnumType,
unionField: UnionType
)

Expand Down

0 comments on commit 06b76b1

Please sign in to comment.