graphql - 如何使用 prismic graphql api 按链接文档/关系的 uid 过滤?
问题描述
我正在尝试按其类别、uid 列出一组文章,并且我假设我必须使用该where
查询,但我无法将其用于链接文档。
问题似乎是where
只接受字段上的字符串,但在链接文档的情况下,您需要深入挖掘 uid 字段。
我不确定我是否使用了错误的查询,但很难在文档中找到任何内容来帮助我。
我尝试深入研究类别对象:
{
allDirectoryServices(
where: { category: { _meta: { uid: "developers" } } }
) {
edges {
node {
name
city
region
country
category {
...on DirectoryTaxonomy {
_meta {
uid
}
name
}
}
}
}
}
}
但这会返回一个错误,它需要一个字符串:
"message": "Expected type String, found {_meta: {uid: \"developers\"}}.",
{
allDirectoryServices(
where: { category: "developers"}
) {
edges {
node {
name
city
region
country
category {
...on DirectoryTaxonomy {
_meta {
uid
}
name
}
}
}
}
}
}
显然,这不会返回任何结果。
解决方案
我也在 Prismic Slack 群上问过这个问题,得到了他们的回答:
为了通过这样的内容关系/链接字段进行查询,您需要使用文档 ID。
where: { category: "WBsLfioAABNUo9Kk" }
不幸的是,无法通过 UID(或任何其他字段)进行查询。
我想他们很快就会更新他们的文档,因为这不在其中。
感谢棱镜的家伙!
推荐阅读
- python - ValueError:检查输入时出错:预期 input_3 的形状为 (34,),但得到的数组的形状为 (36,)
- api - Fleet Api 与 Route API 不同 - POI 无效
- python - 装饰器在类方法中自动化“for arg in self.args”过程
- mysql - 在关系数据库和非关系数据库之间同步分页
- c - 在不使用指针的情况下模拟 C 中的多态性
- javascript - JavaScript画布将元素移动到目标坐标
- excel - 如何将公式(包含变量)的值分配给另一个变量
- c - C 中的 Web 服务器在几次刷新后给出分段错误(核心转储)
- python - 为什么 list.append() 在此代码中写入数据
- python - 更改 LSTM 网络自动编码器的超参数