0

The goal is to get a list of entry types for a section, so that a user can filter entires by entry type e.g.

query Entries {
  entries(section: "content", type: ["news", "article", "video"]) {
    id
    title
    .............
  }
}

I know this can be done template side using getEntryTypes() as per this question - How to list out entry types in a section

However I'm not sure how to do this with GraphQL, is it possible?

1 Answer 1

0

You can query for elements (entries, users, etc.) using Craft's GraphQL API, but not for collections of elements (sections, user groups, etc.).

My suggestion would be to either hard-code these, as I assume they won't change very often, or create a custom API endpoint using a custom module/plugin. See this article for a starting point: https://putyourlightson.com/articles/building-a-restful-api-in-craft-cms

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.