-
-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Client / Schema codegen for
oneOf
inputs (#2294)
* Add client / schema codegen for oneOf inputs * Add test for codegen * Another test
- Loading branch information
1 parent
7d0a698
commit 95c9f2d
Showing
11 changed files
with
160 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
tools/src/test/resources/snapshots/ClientWriterSpec/input object oneOf.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import caliban.client._ | ||
import caliban.client.__Value._ | ||
|
||
object Client { | ||
|
||
sealed trait CharacterInput { | ||
protected def encode: __Value | ||
} | ||
object CharacterInput { | ||
final case class Name(name: String) extends CharacterInput { | ||
protected def encode: __Value = __ObjectValue(List("name" -> implicitly[ArgEncoder[String]].encode(name))) | ||
} | ||
final case class Nicknames(nicknames: List[String] = Nil) extends CharacterInput { | ||
protected def encode: __Value = __ObjectValue( | ||
List("nicknames" -> __ListValue(nicknames.map(value => implicitly[ArgEncoder[String]].encode(value)))) | ||
) | ||
} | ||
|
||
implicit val encoder: ArgEncoder[CharacterInput] = new ArgEncoder[CharacterInput] { | ||
override def encode(value: CharacterInput): __Value = value.encode | ||
} | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
tools/src/test/resources/snapshots/SchemaWriterSpec/input type oneOf.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import caliban.schema.Annotations._ | ||
|
||
object Types { | ||
|
||
final case class Character(name: String) | ||
|
||
@GQLOneOfInput | ||
sealed trait CharacterArgs extends scala.Product with scala.Serializable | ||
object CharacterArgs { | ||
final case class Foo(foo: String) extends CharacterArgs | ||
final case class Bar(bar: Int) extends CharacterArgs | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters