I am having following enum in the application.
public enum State {
Started("newly started"),
Hold("hold on"),
Running("still running"),
Stop("just stopped");
private String value;
State(String value) {
this.value = value;
}
public String getValue() {
return value;
}
}
I have GraphQL schema as well for the same. I am using GraphQL-java library not GraphQL-spqr or GraphQL-java-tools. When I am returning this enum, it's name is being returned but I want to return it's assigned value i.e. "still running" for Running enum, "just stopped" for Stop enum etc. Is there any way in GraphQL-java?
Thanks in advance
it's name is being returned but I want to return it's assigned value
This is by design. From the spec:
Enums are not references for a numeric value, but are unique values in their own right. They may serialize as a string: the name of the represented value.
Enum values are serialized as their names. You may be able to provide an additional value that can be used internally during execution, but this value will not be used in the response.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With