如何修复Gatsby查询以获取内容丰富的引用类型

问题描述 投票:0回答:1

我正在从Contentful获取内容。结构很简单:

[Page

- sections (ref)
-- Section1
--- modules (ref)
---- Module1
---- Module2
-- Section2
--- modules (ref)
---- Module1
---- Module2

我似乎无法到达嵌套引用类型。

我的内容模型的页面包含一个参考模块模块,这些模块包括标题和其他模块列表。似乎插件无法访问内容。你知道为什么吗?以及如何解决?

    allContentfulProductLandingPage{
        edges {
            node {
                name
                    sections { #this is a reference type
                        title
                        modules { #this is a reference type
                            __typename
                            #title #I need title and subfields here
                        }
                    }
                }
            }
        }
    }
}```



How can I get more then the __typename from this query? Likethe title I commented out?


graphql gatsby contentful
1个回答
0
投票

您可能已经知道了,我遇到了同样的问题。我可以使它起作用的唯一方法是,如果所有引用都来自相同的内容类型。我无法混合搭配它们。

© www.soinside.com 2019 - 2024. All rights reserved.