[英]Cannot query field “allDevArticles” on type “Query” graphql/template-strings for fetching dev.to articles
I am using the gatsby-source-dev gatsby plugin to get all my dev.to articles on my gatsby page.我正在使用 gatsby-source-dev gatsby 插件在我的 gatsby 页面上获取我的所有 dev.to 文章。 https://github.com/geocine/gatsby-source-dev
https://github.com/geocine/gatsby-source-dev
It was working fine but recently it started giving me this error.它工作正常,但最近它开始给我这个错误。
"cannot query field "allDevArticles" on type "Query" graphql/template-strings" “无法在类型“查询”graphql/模板字符串上查询字段“allDevArticles””
and not able to fetch my latest articles on the site.并且无法在网站上获取我的最新文章。
My gatsby-config.js looks like this我的 gatsby-config.js 看起来像这样
module.exports = {
plugins: [
`gatsby-plugin-react-helmet`,
{
resolve: `gatsby-source-filesystem`,
options: {
name: `profile`,
path: `./data`,
},
},
`gatsby-transformer-sharp`,
`gatsby-transformer-json`,
`gatsby-plugin-sharp`,
{
resolve: `gatsby-source-dev`,
options: {
username:'vish448'
}
},
],
}
My graphql query on the page looks like this我在页面上的 graphql 查询看起来像这样
export const query = graphql`
query ArticlePageQuery {
allDevArticles {
nodes {
article {
title
url
published_at(formatString: "DD MMM YYYY")
}
}
}
}`
I have updated my configuration in gatsby-config.js for gatsby-source-dev plugin and it works fine.我已经在 gatsby-config.js 中为 gatsby-source-dev 插件更新了配置,它工作正常。 So basically those string quotes are causing an issue.
所以基本上这些字符串引号引起了问题。 I have changed those quotes to string literals (``)
我已将这些引号更改为字符串文字 (``)
module.exports = {
plugins: [
`gatsby-plugin-react-helmet`,
{
resolve: `gatsby-source-filesystem`,
options: {
name: `profile`,
path: `./data`,
},
},
`gatsby-transformer-sharp`,
`gatsby-transformer-json`,
`gatsby-plugin-sharp`,
{
resolve: `gatsby-source-dev`,
options: {
**username:`vish448`**
}
},
],
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.