问题描述
我有一个内容丰富的页面,我使用 graphql 将内容检索到我的 React 应用程序。 在此页面中,链接了一个名为 Person 的内容模型,如下所示:
{
"name": "Person","description": "","displayField": "name","fields": [
{
"id": "name","name": "Name","type": "Symbol","localized": false,"required": true,"validations": [],"disabled": false,"omitted": false
},{
"id": "profilePic","name": "profile pic","type": "Link","omitted": false,"linkType": "Asset"
},{
"id": "socialLinks","name": "social links","type": "Array","required": false,"items": {
"type": "Link","validations": [
{
"linkContentType": [
"socialLink"
]
}
],"linkType": "Entry"
}
}
ProfilePic 是另一种包含名称和 picUrl 的内容模型。
SocialLinks 是一个包含名称和链接的 socialLink
内容模型数组
我可以毫无问题地检索我的 profilePic 名称或 picUrl,但我无法获得社交链接。 我已阅读有关一对多的内容丰富的文档,但不清楚如何适用于我的案例:https://www.contentful.com/developers/docs/references/graphql/#/reference/schema-generation/one-to-many-multi-type-relationships
我的查询:
...rest of the query..
founder{
name,profilePic{
url,title
},socialLinksCollection {
items {
name,link
}
}
},... rest of the query...
somoene 能帮我理解为什么它不能作为普通集合吗?
我应该使用 linkedFrom
的这个概念吗?但究竟如何?
解决方法
我不得不将(限制:1)添加到我的 socialLinksCollections 中,否则调用太多并且无法取回数据。 感谢 @stefan judis 建议在哪里查找错误。