Using graphQL enums as a dropdown values array

I have a mutation that uses a graphQL enum as one of the inputs. I'm using a dropdown component to visually represent this input. I'd like to know if I could set the values array using the enum definition directly rather than using a string [] where I copy the enum values. As an example my current value array is

['EN', 'FR']

where I'd rather it be something like

[language.EN, language.FR]

1 Like

Hi maciej_tbx!

To confirm, you are currently manually hardcoding the values of the dropdown? Where is the enum definition currently stored within Retool?

Hi there, has there been any progress on this.
I also am trying to set the values of the dropdown based on the values of the enum in my API

Hi @enicol !

Could you share how you currently have this set up?

Hi there, we use typescript and a GQL backend. When I inspect the API I can see that there are certain enums defined that are basically an array of strings.

For instance, on the backend we have a enum labelled WorkOrderPriority

enum WorkOrderPriority {

HIGH

LOW

NORMAL

}

Instead of having to go to the additional effort of adding an API to query for these enums, I'm looking for the ability to read them directly from the schema

Ah I see what you are saying! Unfortunately, we still don't expose the entire GraphQL schema outside the query editor. So your best bet is to directly query the enums and then reference the result inside your application. Something like this would fetch the enum configuration:

{
  __type(name: "WorkOrderPriority"){
    name
    enumValues {
      name
    }
  }
}