Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing types from nested input fields #101

Merged
merged 1 commit into from
Nov 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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