forked from ghostdogpr/caliban
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds tests for checking deprecated args for derived schemas
- Loading branch information
1 parent
ce502f6
commit 9a18e0b
Showing
3 changed files
with
66 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
tools/src/test/scala/caliban/tools/IntrospectionClientSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package caliban.tools | ||
|
||
import caliban._ | ||
import caliban.quick._ | ||
import caliban.schema.Annotations._ | ||
import caliban.schema.Schema.auto._ | ||
import caliban.schema.ArgBuilder.auto._ | ||
import zio.test._ | ||
import zio.{Clock, durationInt} | ||
|
||
object IntrospectionClientSpec extends ZIOSpecDefault { | ||
|
||
case class Args(@GQLDeprecated("Use nameV2") name:Option[String] = Some("defaultValue"), nameV2:String) | ||
|
||
case class Queries( | ||
getObject: Args => String | ||
) | ||
|
||
object Resolvers { | ||
def getObject(@GQLDeprecated("foobar") args: Args): String = | ||
args.name.getOrElse("") | ||
} | ||
|
||
val queries = Queries( | ||
getObject = Resolvers.getObject | ||
) | ||
|
||
val api = graphQL( | ||
RootResolver( | ||
queries | ||
) | ||
) | ||
|
||
def spec = suite("IntrospectionClientSpec")( | ||
test("is isomorphic") { | ||
for { | ||
_ <- 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 | ||
) | ||
} yield assertTrue(res.isEmpty, false) | ||
} | ||
) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters