Skip to content

Commit

Permalink
Escape function name properly in interface client generation (ghostdo…
Browse files Browse the repository at this point in the history
  • Loading branch information
ghostdogpr authored and Fluxx committed Jan 27, 2022
1 parent 7895d28 commit 99433f8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 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 @@ -206,9 +206,9 @@ object ClientWriter {
if (commonInterface) {
(
s"[$typeLetter]",
s"(${field.name}: SelectionBuilder[${safeTypeName(getTypeName(field.ofType))}, $typeLetter])",
s"(${safeName(field.name)}: SelectionBuilder[${safeTypeName(getTypeName(field.ofType))}, $typeLetter])",
writeType(field.ofType).replace(fieldType, typeLetter),
writeTypeBuilder(field.ofType, s"Obj(${field.name})")
writeTypeBuilder(field.ofType, s"Obj(${safeName(field.name)})")
)
} else if (optionalInterface) {
(
Expand Down
14 changes: 7 additions & 7 deletions tools/src/test/scala/caliban/tools/ClientWriterSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ object Client {
name: String!
}
type Sort {
order: Order
object: Order
}
""".stripMargin

Expand All @@ -877,18 +877,18 @@ object Client {
type Sort
object Sort {
def order[A](onAscending: SelectionBuilder[Ascending, A]): SelectionBuilder[Sort, Option[A]] =
_root_.caliban.client.SelectionBuilder.Field("order", OptionOf(ChoiceOf(Map("Ascending" -> Obj(onAscending)))))
def orderOption[A](
def `object`[A](onAscending: SelectionBuilder[Ascending, A]): SelectionBuilder[Sort, Option[A]] =
_root_.caliban.client.SelectionBuilder.Field("object", OptionOf(ChoiceOf(Map("Ascending" -> Obj(onAscending)))))
def objectOption[A](
onAscending: Option[SelectionBuilder[Ascending, A]] = None
): SelectionBuilder[Sort, Option[Option[A]]] = _root_.caliban.client.SelectionBuilder.Field(
"order",
"object",
OptionOf(
ChoiceOf(Map("Ascending" -> onAscending.fold[FieldBuilder[Option[A]]](NullField)(a => OptionOf(Obj(a)))))
)
)
def orderInterface[A](order: SelectionBuilder[Order, A]): SelectionBuilder[Sort, Option[A]] =
_root_.caliban.client.SelectionBuilder.Field("order", OptionOf(Obj(order)))
def objectInterface[A](`object`: SelectionBuilder[Order, A]): SelectionBuilder[Sort, Option[A]] =
_root_.caliban.client.SelectionBuilder.Field("object", OptionOf(Obj(`object`)))
}
}
Expand Down

0 comments on commit 99433f8

Please sign in to comment.