Search code examples
graphqlcontentful

Querying validation entries in Contentful / GraphQL


So I have a very basic content model in Contentful. On the category field, I have validation rules that only let the user choose from the predefine options.

I'm trying to query what these options are in graphQL. IE, a query that returns 'Day Ticket' and 'Season Ticket' + any additional ones that are added in the future of course. No luck so far, any thoughts?

content model

validation inputs


Solution

  • Contentful DevRel here. 👋

    I don't think that's possible via the GraphQL API. The GQL api works on with publish and preview data. The available functionality is more or less mapping to the data available in the Content Delivery API and Content Preview API.

    To retrieve this information you'd have to communicate with the Content Management API (CMA). You'll find the information when you fetch a content model.

    ❗Heads up, don't put a CMA token in the client (the browser). The CMA is a read/write API. If you leak the token to authorise people could alter your Contentful space and the data it includes.