Hi there -
I’d like to query a content relationship that’s part of a slice and cannot figure out how to do it. I have two objects in my repo - Publications and Subjects. I am trying to get all publications that have a particular Subject, but can’t. Here is the query:
query MyQuery {
allSubjects(uid: “education”) {
edges {
node {
_meta {
uid
}
}
}
}
allPublications{
edges {
node {
title
body {
…on PublicationBodyPublication_subjects {
fields {
subject {
…on Subject {
_meta {
uid
}
}
}
}
}
}
}
}
}
}
I want to be able to pass the UID of the Subject down to the allPublications query and filter where the uid of the Subject in the slice is equal to the uid of the subject I have chose (here, I’ve hard-coded ‘education’ as an example, but I would use a variable in the future).
I have tried restructuring the data model to have a group in which folks choose a content relationship, instead of a slice, and I can’t get that to work either.
Our users want/need a controlled vocabulary for the Subject object, so we cannot use tags here. They need to be able to add/edit the subjects, but also assign Subjects to a Publication.
I am using Gatsby with the gatsby-source-prismic-graphql plugin to generate pages. I can generate a page for each Publication and a page for each Subject just fine, but I want to list all Publications of a particular subject on the Subject page and cannot figure out a way to do this.
Any help is greatly appreciated.
Danielle