Skip to content

Commit

Permalink
Add missing types from nested input fields (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghostdogpr authored Nov 29, 2019
1 parent 73b0dc8 commit a347181
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion core/src/main/scala/caliban/schema/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ object Types {
case _ =>
val map1 = t.name.fold(existingTypes)(name => existingTypes.updated(name, t))
val embeddedTypes =
t.fields(__DeprecatedArgs(Some(true))).getOrElse(Nil).flatMap(f => f.`type` :: f.args.map(_.`type`))
t.fields(__DeprecatedArgs(Some(true))).getOrElse(Nil).flatMap(f => f.`type` :: f.args.map(_.`type`)) ++
t.inputFields.getOrElse(Nil).map(_.`type`)
val map2 = embeddedTypes.foldLeft(map1) {
case (types, f) =>
val t = innerType(f())
Expand Down
10 changes: 10 additions & 0 deletions core/src/test/scala/caliban/schema/SchemaSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ object SchemaSpec
introspect[InfallibleFieldSchema].fields(__DeprecatedArgs()).toList.flatten.headOption.map(_.`type`()),
isSome(hasField[__Type, __TypeKind]("kind", _.kind, equalTo(__TypeKind.NON_NULL)))
)
},
test("nested input fields") {
case class Queries(a: A => Unit)
case class A(b: B)
case class B(c: C)
case class C(d: Int)
assert(
Types.collectTypes(introspect[Queries]).keys,
contains("BInput") && contains("CInput")
)
}
)
)
Expand Down

0 comments on commit a347181

Please sign in to comment.