Encode function for enums is missing
ad-si opened this issue · comments
I have following GraphQL Enum:
enum Order {
ASC
DESC
}
It generates an src/Api/Enum/Order.elm
file with following type:
type Order
= Asc
| Desc
However, the generated src/Api/InputObject.elm
file references a function encodeOrder
which isn't defined anywhere.
I was able to fix it by adding it manually:
encodeOrder : Order -> Value
encodeOrder =
Encode.enum <|
\val ->
case val of
Asc ->
"ASC"
Desc ->
"DESC"
Is this a bug and it should be generated automatically, or am I missing something?
It looks like the generated code uses the enum's toString
functions within the InputObject
module. Here's an example of what is generated for the Star Wars API example:
So it appears that the basic case of encoding an enum within an InputObject is working as expected.
If you think there might be a bug, I would be interested to see a minimum reproduction of the relevant schema. There are some instructions for making a minimum reproduction here: https://github.com/dillonkearns/elm-graphql/blob/master/reproducing-issues/README.md