这使我获得所有与showOnSite === true
相关的事件:
query MyQuery {
allSanityP2Event(filter: {showOnSite: {eq: true}}) {
edges {
node {
showOnSite
title
relatedEvents {
showOnSite
title
}
}
}
}
}
然后,我还要在这些结果中过滤relatedEvents
,也要过滤showOnSite === true
。 GraphQL当然可以做到吗?
使用elemMatch
不起作用,因为它仅向我提供relatedEvents
具有showOnSite === true
的事件,例如:
query MyQuery {
allSanityP2Event(filter: {showOnSite: {eq: true}, relatedEvents: {elemMatch: {showOnSite: {eq: true}}}}) {
edges {
node {
showOnSite
title
relatedEvents {
showOnSite
title
}
}
}
}
}
从逻辑上讲,我希望这能奏效,但是没有...
query MyQuery {
allSanityP2Event(filter: {showOnSite: {eq: true}}) {
edges {
node {
showOnSite
title
relatedEvents(filter: {showOnSite: {eq: true}}) {
showOnSite
title
}
}
}
}
}