内容丰富的 graphql 嵌套结构
contentful graphql nested structure
我有一个内容丰富的页面,我使用 graphql 将内容检索到我的 React 应用程序。
在此页面中,link 一个名为 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",
"localized": false,
"required": true,
"validations": [],
"disabled": false,
"omitted": false,
"linkType": "Asset"
},
{
"id": "socialLinks",
"name": "social links",
"type": "Array",
"localized": false,
"required": false,
"validations": [],
"disabled": false,
"omitted": false,
"items": {
"type": "Link",
"validations": [
{
"linkContentType": [
"socialLink"
]
}
],
"linkType": "Entry"
}
}
ProfilePic 是另一种包含name 和picUrl 的内容模型。
SocialLinks 是 socialLink
内容模型的数组,其中包含名称和 link
我可以毫无问题地检索我的 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 提出了在哪里查找错误的建议。
我有一个内容丰富的页面,我使用 graphql 将内容检索到我的 React 应用程序。 在此页面中,link 一个名为 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",
"localized": false,
"required": true,
"validations": [],
"disabled": false,
"omitted": false,
"linkType": "Asset"
},
{
"id": "socialLinks",
"name": "social links",
"type": "Array",
"localized": false,
"required": false,
"validations": [],
"disabled": false,
"omitted": false,
"items": {
"type": "Link",
"validations": [
{
"linkContentType": [
"socialLink"
]
}
],
"linkType": "Entry"
}
}
ProfilePic 是另一种包含name 和picUrl 的内容模型。
SocialLinks 是 socialLink
内容模型的数组,其中包含名称和 link
我可以毫无问题地检索我的 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 提出了在哪里查找错误的建议。