【发布时间】:2021-07-17 18:09:29
【问题描述】:
我有一个内容丰富的页面,我使用 graphql 将内容检索到我的反应应用程序。 在这个页面中,一个名为 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 是另一种包含名称和图片网址的内容模型。
SocialLinks 是一个包含名称和链接的socialLink 内容模型数组
我可以毫无问题地检索我的 profilePic 名称或 picUrl,但我无法获取 socialLinks。 我已阅读有关一对多的内容丰富的文档,但我不清楚如何申请我的案例: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这个概念吗?但具体如何?
【问题讨论】:
-
这一切对我来说看起来都不错。你检查过 GraphiQL 中可用的感觉吗?contentful.com/developers/docs/references/graphql/#/reference/…
-
谢谢!使用 graphql ID 它确实给了我一个更具体的错误。我正在研究它:)
标签: graphql contentful contentful-api