Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BLOCKING BUG: enum in case class fails with "Argument 'xyz' has invalid value: CNil" #528

Open
owetterau opened this issue Nov 4, 2020 · 4 comments

Comments

@owetterau
Copy link

owetterau commented Nov 4, 2020

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

@nickhudkins
Copy link
Contributor

Hi @owetterau please provide a full sample of the code that is failing and hopefully someone can help you out!

@ThibaultUrien
Copy link

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.

@owetterau
Copy link
Author

owetterau commented Jan 12, 2022

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 owetterau changed the title enum in case class fails with "Argument 'xyz' has invalid value: CNil" BLOCKING BUG: enum in case class fails with "Argument 'xyz' has invalid value: CNil" Jan 14, 2022
@yanns
Copy link
Contributor

yanns commented Sep 27, 2022

@owetterau if you want to help, you could prepare a PR, at least one with the test case reproducing the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants