Skip to content

Commit

Permalink
Exposing the set of members of emitted enumerations
Browse files Browse the repository at this point in the history
  • Loading branch information
blast-hardcheese committed Jun 23, 2021
1 parent 218a036 commit aed060f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tools/src/main/scala/caliban/tools/ClientWriter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,10 @@ object ClientWriter {
.map(v => s"""case ${typedef.name}.${safeEnumValue(v.enumValue)} => __EnumValue("${v.enumValue}")""")
.mkString("\n")}
}

val values: Vector[${enumName}] = Vector(${typedef.enumValuesDefinition
.map(v => safeEnumValue(v.enumValue))
.mkString(", ")})
}
"""
}
Expand Down
6 changes: 6 additions & 0 deletions tools/src/test/scala/caliban/tools/ClientWriterSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ object Client {
case Origin.MARS => __EnumValue("MARS")
case Origin.BELT => __EnumValue("BELT")
}
val values: Vector[Origin] = Vector(EARTH, MARS, BELT)
}
}
Expand Down Expand Up @@ -289,6 +291,8 @@ object Client {
case Origin.MARS => __EnumValue("MARS")
case Origin.BELT => __EnumValue("BELT")
}
val values: Vector[Origin] = Vector(EARTH, MARS, BELT)
}
case class Routes(origin: Origin, destinations: List[com.example.Destination] = Nil)
Expand Down Expand Up @@ -599,6 +603,8 @@ object Client {
case Episode.JEDI => __EnumValue("JEDI")
case Episode.jedi_1 => __EnumValue("jedi")
}
val values: Vector[Episode] = Vector(NEWHOPE, EMPIRE, JEDI, jedi_1)
}
}
Expand Down

0 comments on commit aed060f

Please sign in to comment.