[英]Wordpress schema not appearing at Gatsby /___graphql endpoint
我正在嘗試設置 Gatsby 以創建無頭 Wordpress 站點。 我有一個本地 Wordpress 環境設置並使用以下已安裝並處於活動狀態的插件:
Wordpress 端的一切似乎都按預期工作。 I've now been trying to set up my local Gatsby site to work and pull from Wordpress using the Gatsby Source GraphQL plugin, however the wordpress scheme just isn't appearing in my GraphiQL interface at http://localhost:8000/___graphql/
.
這是我的gatsby-config.js
:
module.exports = {
siteMetadata: {
title: "Portfolio Site",
},
plugins: [
{
resolve: "gatsby-source-graphql",
options: {
typeName: "WPGraphQL",
fieldName: "wpgraphql",
url: "http://local.test/graphql",
refetchInterval: 60,
},
},
],
};
這是我的package.json
的內容:
{
"name": "portfolio-site",
"version": "1.0.0",
"private": true,
"description": "Portfolio Site",
"author": "jsaget",
"keywords": [
"gatsby"
],
"scripts": {
"develop": "gatsby develop",
"start": "gatsby develop",
"build": "gatsby build",
"serve": "gatsby serve",
"clean": "gatsby clean"
},
"dependencies": {
"@fontsource/syne-mono": "^4.2.2",
"gatsby": "^2.32.3",
"gatsby-source-graphql": "^2.14.0",
"gatsby-source-wordpress": "^4.0.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"typewriter-effect": "^2.17.0"
}
}
當我在終端中運行npm run develop
以啟動我的本地 Gatsby 時,我在控制台中收到以下錯誤和警告:
ERROR #11321 PLUGIN
"gatsby-source-graphql" threw an error while running the sourceNodes lifecycle:
warn The gatsby-source-graphql plugin has generated no Gatsby nodes. Do you need it?
一位同事以與我完全相同的方式設置了這個 Gatsby 環境(所有依賴項的相同版本等),它在他的機器上運行良好,但在我的機器上卻不行。 一些全球 npm 模塊或其他東西會干擾嗎? 或者它可能是 Wordpress 端的東西?
同樣在這里,但我發現了一些東西!
Go 到 WordPress 儀表板 > GraphQL > 設置:勾選框“啟用 Z524DE3D2ADE454FBDF2F60F60F70”
Go 回到你的終端:gastby clean,然后 npm 運行開發
wpgraphql 現在應該出現在 http://localhost:8000/___graphql
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.