I am using GatsbyJS with the Prismic GraphQL interface to display multiple content documents of a single type on a single page. I would like to group the documents by the category field of that content type. The category field is a dropdown the writer selects. To do this, I have to hardcode the field which I want to group by like so:
query MyQuery {
prismic {
categoryOne: allMy_Content(where: {category_fulltext: "category1"}) {
edges {
node {
name
}
}
}
categoryTwo: allMy_Content(where: {category_fulltext: "category2"}) {
edges {
node {
name
}
}
}
categoryThree: allMy_Content(where: {category_fulltext: "category3"}) {
edges {
node {
name
}
}
}
}
I would like to do this without hardcoding the names of the categories so Prismic admins could add more categories in the future and it would not require updates to the Gatsby code base. Thanks!