Search code examples
graphqlgraphcool

Meta data values of "Enum"


I created a field in a model named "Listing". The field in here is "category". This is set to enum of some values (screenshot below). Does graphql allow to query to fetch the enum list?


Solution

  • This is possible using a GraphQL introspection query.

    Enum types on Graphcool are named "MODEL_FIELD", so in your case you can run this query:

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

    You can find more information in this answer to a similar question.