[Solved]-Query for enum value in GraphQL

11๐Ÿ‘

I found a solution, though I wonder if it is the best one. In addition to the query that has enum values, I included this query

query {
    # previous queries
    __type(name: "OrderState") {
       states: enumValues {
           name
           description
       }
    }
}

It pulls all possible key-value pairs for the OrderState enum. I then can use this as a dictionary to lookup enum values.

I feel that this approach is still too manual, but there are no examples that make a query for enum values. They just stopped at describing what an enum is, and how to declare one.

๐Ÿ‘คKhanetor

Leave a comment