I am trying to fetch data from Contentful with a filter whose eq
operator is also fetched from Contentful. In my current scenario, as shown in the code below, I am trying to filter the content fetched from allContentfulPost
with the value fetched from label
in contentfulCategory
.
Any ideas how I can do so? I tried using $label
in the allContentfulPost
filter eq
operator, but that didn't work.
export const pageQuery = graphql`
query CategoryBySlug($slug: String!) {
contentfulCategory (slug: { eq: $slug }) {
slug
label
}
allContentfulPost (filter: { categories: { elemMatch: { label: { eq: ????? } } } }) {
edges {
node {
title
slug
featured
image {
fluid {
src
}
}
}
}
}
}
`
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…