Since defineEnum converts all members of an enum into String objects in order to mark them as a GraphQL enum, it makes doing stuff like this confusing:
import { SomeEnum } from '~/models/depot';
switch (someModel.someEnum) {
case SomeEnum.VALUE_A:
// invoke logic
break;
case SomeEnum.VALUE_B:
// invoke logic
break;
}
This won't work because you're comparing objects. You have to explicitly use toString():
switch (someModel.someEnum.toString()) {
case SomeEnum.VALUE_A.toString():
// invoke logic
break;
case SomeEnum.VALUE_B.toString():
// invoke logic
break;
}
We need to find another way to deal with enums when building GraphQL query documents...
Since
defineEnum
converts all members of an enum into String objects in order to mark them as a GraphQL enum, it makes doing stuff like this confusing:This won't work because you're comparing objects. You have to explicitly use
toString()
:We need to find another way to deal with enums when building GraphQL query documents...