From 06b76b117bb6843ede3dd2c837dd15090b88c01d Mon Sep 17 00:00:00 2001 From: Henning Wielenberg Date: Wed, 24 Jul 2024 15:39:39 +0100 Subject: [PATCH] Adds deprecated fields --- .../tools/IntrospectionClientSpec.scala | 42 ++++++++++++------- .../caliban/tools/RemoteSchemaSpec.scala | 4 +- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/tools/src/test/scala/caliban/tools/IntrospectionClientSpec.scala b/tools/src/test/scala/caliban/tools/IntrospectionClientSpec.scala index b152e6eb1b..8f5f582065 100644 --- a/tools/src/test/scala/caliban/tools/IntrospectionClientSpec.scala +++ b/tools/src/test/scala/caliban/tools/IntrospectionClientSpec.scala @@ -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( @@ -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) } ) diff --git a/tools/src/test/scala/caliban/tools/RemoteSchemaSpec.scala b/tools/src/test/scala/caliban/tools/RemoteSchemaSpec.scala index 49b8f89232..143ad91a77 100644 --- a/tools/src/test/scala/caliban/tools/RemoteSchemaSpec.scala +++ b/tools/src/test/scala/caliban/tools/RemoteSchemaSpec.scala @@ -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 )