Skip to content

Commit

Permalink
Fix signature of optional interface and union generated code (#1237)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghostdogpr authored Jan 6, 2022
1 parent aad17d8 commit 44a3d7e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions tools/src/main/scala/caliban/tools/ClientWriter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ object ClientWriter {
(
s"[$typeLetter]",
s"(${unionTypes.map(t => s"""on${t.name}: Option[SelectionBuilder[${safeTypeName(t.name)}, $typeLetter]] = None""").mkString(", ")})",
s"Option[${writeType(field.ofType).replace(fieldType, typeLetter)}]",
s"${writeType(field.ofType).replace(fieldType, s"Option[$typeLetter]")}",
writeTypeBuilder(
field.ofType,
s"ChoiceOf(Map(${unionTypes.map(t => s""""${t.name}" -> on${t.name}.fold[FieldBuilder[Option[A]]](NullField)(a => OptionOf(Obj(a)))""").mkString(", ")}))"
Expand Down Expand Up @@ -214,7 +214,7 @@ object ClientWriter {
(
s"[$typeLetter]",
s"(${interfaceTypes.map(t => s"""on${t.name}: Option[SelectionBuilder[${safeTypeName(t.name)}, $typeLetter]] = None""").mkString(", ")})",
s"Option[${writeType(field.ofType).replace(fieldType, typeLetter)}]",
s"${writeType(field.ofType).replace(fieldType, s"Option[$typeLetter]")}",
writeTypeBuilder(
field.ofType,
s"ChoiceOf(Map(${interfaceTypes.map(t => s""""${t.name}" -> on${t.name}.fold[FieldBuilder[Option[A]]](NullField)(a => OptionOf(Obj(a)))""").mkString(", ")}))"
Expand Down
4 changes: 2 additions & 2 deletions tools/src/test/scala/caliban/tools/ClientWriterSpec.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package caliban.tools

import caliban.parsing.Parser
import zio.{ RIO, UIO }
import zio.RIO
import zio.blocking.Blocking
import zio.test.Assertion._
import zio.test._
Expand Down Expand Up @@ -948,7 +948,7 @@ object Client {
def ordersOption[A](
onAscending: Option[SelectionBuilder[Ascending, A]] = None,
onDescending: Option[SelectionBuilder[Descending, A]] = None
): SelectionBuilder[Sort, Option[Option[List[Option[A]]]]] = _root_.caliban.client.SelectionBuilder.Field(
): SelectionBuilder[Sort, Option[List[Option[Option[A]]]]] = _root_.caliban.client.SelectionBuilder.Field(
"orders",
OptionOf(
ListOf(
Expand Down

0 comments on commit 44a3d7e

Please sign in to comment.