无法查询类型 "Query" 上的字段 "allMdx"
cannot query field "allMdx" on type "Query"
我是 GraphiQl 的新手,我正在学习来自 here
的教程
而且我也是 Gatsby 的新手,当我想继续这个 link: http://localhost:8000/___graphql
然后告诉我一个错误allMdx
如果我将鼠标悬停在上面。
像这样:
但是官方文档一切正常,我不知道我的问题在哪里
任何更新问题!
我用过gatsby v3
我的初始查询也与 this
不匹配
有什么建议吗
基本上,GraphQL 游乐场 (localhost:8000/___graphql
) 告诉您您没有创建 allMdx
节点。所有可用节点的列表位于左列(allFile
、allDirectory
等)。
您需要设置文件系统以允许 Gatsby 通过以下方式推断节点:
npm install gatsby-source-filesystem
然后,在您的 gatsby-config.js
:
module.exports = {
siteMetadata: {
title: "My First Gatsby Site",
},
plugins: [
"gatsby-plugin-gatsby-cloud",
"gatsby-plugin-image",
"gatsby-plugin-sharp",
{
resolve: "gatsby-source-filesystem",
options: {
name: `blog`,
path: `${__dirname}/blog`, // <-- the folder where you have the .mdx files
}
},
],
};
如果您在 /blog
文件夹中有一些 MDX 文件,Gatsby 将生成适当的节点 (allMdx
),允许您查询它们。
gatsby clean && gatsby develop
重启并清理你的服务器。
接下来的步骤是通过添加一些配置来查询数据,例如:
{
resolve: `gatsby-plugin-mdx`,
options: {
defaultLayouts: {
posts: require.resolve("./src/components/blog-layout.js"),
default: require.resolve("./src/components/layout.js"),
},
},
},
注意:您需要先安装 gatsby-plugin-mdx
插件
您可以查看以下教程:https://www.digitalocean.com/community/tutorials/gatsbyjs-mdx-in-gatsby
我是 GraphiQl 的新手,我正在学习来自 here
的教程而且我也是 Gatsby 的新手,当我想继续这个 link: http://localhost:8000/___graphql
然后告诉我一个错误allMdx
如果我将鼠标悬停在上面。
像这样:
但是官方文档一切正常,我不知道我的问题在哪里
任何更新问题!
我用过gatsby v3
我的初始查询也与 this
不匹配有什么建议吗
基本上,GraphQL 游乐场 (localhost:8000/___graphql
) 告诉您您没有创建 allMdx
节点。所有可用节点的列表位于左列(allFile
、allDirectory
等)。
您需要设置文件系统以允许 Gatsby 通过以下方式推断节点:
npm install gatsby-source-filesystem
然后,在您的 gatsby-config.js
:
module.exports = {
siteMetadata: {
title: "My First Gatsby Site",
},
plugins: [
"gatsby-plugin-gatsby-cloud",
"gatsby-plugin-image",
"gatsby-plugin-sharp",
{
resolve: "gatsby-source-filesystem",
options: {
name: `blog`,
path: `${__dirname}/blog`, // <-- the folder where you have the .mdx files
}
},
],
};
如果您在 /blog
文件夹中有一些 MDX 文件,Gatsby 将生成适当的节点 (allMdx
),允许您查询它们。
gatsby clean && gatsby develop
重启并清理你的服务器。
接下来的步骤是通过添加一些配置来查询数据,例如:
{
resolve: `gatsby-plugin-mdx`,
options: {
defaultLayouts: {
posts: require.resolve("./src/components/blog-layout.js"),
default: require.resolve("./src/components/layout.js"),
},
},
},
注意:您需要先安装 gatsby-plugin-mdx
插件
您可以查看以下教程:https://www.digitalocean.com/community/tutorials/gatsbyjs-mdx-in-gatsby