graphql - 无法在类型“Query”graphql/template-strings 上查询字段“allDevArticles”以获取 dev.to 文章
问题描述
我正在使用 gatsby-source-dev gatsby 插件在我的 gatsby 页面上获取我的所有 dev.to 文章。 https://github.com/geocine/gatsby-source-dev
它工作正常,但最近它开始给我这个错误。
“无法在类型“查询”graphql/模板字符串上查询字段“allDevArticles””
并且无法在网站上获取我的最新文章。
我的 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'
}
},
],
}
我在页面上的 graphql 查询如下所示
export const query = graphql`
query ArticlePageQuery {
allDevArticles {
nodes {
article {
title
url
published_at(formatString: "DD MMM YYYY")
}
}
}
}`
解决方案
我已经在 gatsby-config.js 中为 gatsby-source-dev 插件更新了配置,它工作正常。所以基本上这些字符串引号引起了问题。我已将这些引号更改为字符串文字 (``)
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`**
}
},
],
}
推荐阅读
- c# - C# Windows 窗体组合框如何将默认值设置为“选择”最初从数据表加载数据
- amazon-cloudformation - AWS CloudFormation - AWS::ElasticLoadBalancingV2::LoadBalancer - SecurityGroups
- android - Android:处理滚动视图中空白区域的点击
- php - ajax 没有向 php 页面发送数据
- apache-spark - Spark 能否自动检测非确定性结果并相应调整故障恢复?
- json - 如何迭代对象而不是数组
- java - Gson 属性相同但对象不同
- c++ - 变量神秘地设置为 204
- r - 构建 R 函数,它接收存储文件的目录和阈值。并返回相关性
- linux - linux shell重定向命令的顺序