sangria
sangria copied to clipboard
BLOCKING BUG: enum in case class fails with "Argument 'xyz' has invalid value: CNil"
I have a case class which contains an enum for which I use EnumType()and deriveInputObjectType[] to create the schema.
Sangria shows an Argument 'testEnum' has invalid value: CNil when I send something like:
MethodCall(testCaseClass: {
name: "just a name",
testEnum: FIRST
}) {
result
}
If I use testEnum as a parameter of a mutation directly, everything works fine. It seems that this problem only appears when an enum is used as part of a case class.
I am using Sangria 2.0.1, Circe 0.13.0 and Sangria-Circe 1.3.1
Hi @owetterau please provide a full sample of the code that is failing and hopefully someone can help you out!
I have the exact same issue. Enum field in a case class input object cause this same error. Really anoying as I have no clue how to fix it except implementing a fromInput for all InputObject that use this enum.
Unfortunately, this issue is still not resolved. Here is a short example of how to recreate the problem:
sealed trait TestEnum
case object TestA extends TestEnum
case object TestB extends TestEnum
case object TestC extends TestEnum
final case class Test(id: String, test: TestEnum)
implicit val TestEnumType = deriveEnumType[TestEnum]()
implicit val TestObjectType: ObjectType[CallContext, Test] = deriveObjectType[CallContext, Test]()
implicit val TestInputType: InputObjectType[Test] = deriveInputObjectType[Test](
InputObjectTypeName("testInput")
)
val TestArg = Argument("test", TestInputType)
Field(
s"setTest", BooleanType,
arguments = TestArg :: Nil,
resolve = ctx => {
println(ctx arg TestArg)
true
}
)
I am now using Sangria 3.0.0-RC7, Sangria-Circe 1.3.2 and Circe 0.14.1
@owetterau if you want to help, you could prepare a PR, at least one with the test case reproducing the issue?