我正在尝试使用 Gatsby API createPages 和来自 Firebase 的数据以编程方式创建 Gatsby 页面。我已经成功设置了所有内容,直到可以通过 GraphQL 访问 Firebase 数据,现在我想查询使用 id(字符串格式)创建的每个新页面的特定数据。但是,当我创建模板组件并尝试查询数据时,出现此错误:
Variable "$clientId" of type "String!" used in position expecting type "StringQueryOperatorInput".
Run Code Online (Sandbox Code Playgroud)
我到处寻找这个StringQueryOperatorInput的参考,但找不到任何关于它的信息。谷歌和 graphql 文档似乎没有提到这个词,这是我第一次看到它。经过一个小时的故障排除后,我得到了一个不同的错误:
If you're e.g. filtering for specific nodes make sure that you choose the correct field (that has the same type "String!") or adjust the context variable to the type "StringQueryOperatorInput".
File: src/templates/Homeowner/Homeowner.js:24:9
Run Code Online (Sandbox Code Playgroud)
但是,我仍然不知道 StringQueryOperatorInput 是什么或如何解决这个问题。下面是我的这个组件的代码和我的 gatsby-node.js 和我的 gatsby-config.js,我使用插件来获取 Firebase 数据。我真的可以在这方面使用一些帮助,我似乎找不到这个 StringQueryOperatorInput 的任何参考。其他一切正常,我只是无法在 Homeowner.js 模板上运行此查询。
gatsby-node.js
exports.createPages = async ({ graphql, …Run Code Online (Sandbox Code Playgroud) 使用此 Starter 开发 Gatsby 应用程序 https://github.com/the-road-to-react-with-firebase/react-gatsby-firebase-authentication
当我在运行 Gatsby Develop 后尝试访问我的页面时,我在更新我的节点包后不断收到此 HPM 错误。该项目编译成功,但随后我在浏览器中收到此错误,但没有任何显示。
尝试代理时出错:localhost:8000/
这在终端中:
错误 [HPM] 尝试代理请求时发生错误 / 从 localhost:8000 到http://localhost:4000 (ECONNREFUSED
一旦我从gatsby-config.js它工作的文件和浏览器中生成的页面中删除
它:
module.exports = {
developMiddleware: app => {
app.use(
proxy({
target: "http://localhost:4000",
})
)
},
}
Run Code Online (Sandbox Code Playgroud)
但是,然后我在终端中收到此错误:
在“/404.html”中加载页面查询结果时出错。查询未运行且未找到缓存结果。页面未找到/404.html
我想知道为什么 Proxy 不工作以及上面的模块导出到底在做什么。我觉得我正在做的这种解决方法不好。任何帮助或建议都会很棒!!
Github 仓库: