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

Derive Enum Type should include values in FIFO order instead of LIFO. #456

Open
apoorvajhanwer opened this issue Aug 18, 2019 · 1 comment

Comments

@apoorvajhanwer
Copy link

apoorvajhanwer commented Aug 18, 2019

I made a scala Enum

object Counts extends Enumeration {
  type CountsType = Value
  val Zero = Value(0)
  val One = Value(1)
  val Two = Value(2)
  val Three = Value(3)
}

Then created the same type for graph Ql schema

  val CountType = deriveEnumType[Counts.Value](
    IncludeValues("Zero", "One", "Two", "Three")
  )

or

  val CountType = deriveEnumType[Counts.Value](
    IncludeValues("Three", "Two","One","Zero")
  )

But found out that enum created was in LIFO so zero was assigned value 3 beacuse of this line

case (acc, MacroIncludeValues(vals, _)) acc ++ vals

When i run the introspection query i get three on the top of my enum values.

image

@apoorvajhanwer
Copy link
Author

The best way to avoid this issue is to not use DeriveEnumType and create it like this
val Count = EnumType(
"Count",
values = List(
EnumValue("Zero", value = Counts.Zero),
EnumValue("One", value = Counts.One),
EnumValue("Two", value = Counts.Two),
EnumValue("Three", value = Counts.Three)
)
)

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

No branches or pull requests

1 participant