gatsby-source-drupal 不显示 graphql 查询
Posted
技术标签:
【中文标题】gatsby-source-drupal 不显示 graphql 查询【英文标题】:gatsby-source-drupal does not show graphql queries 【发布时间】:2019-10-26 04:04:51 【问题描述】:我将gatsby-source-drupal
添加到我的gatsby
项目中,但由于某种原因,drupal
-查询没有出现在 GraphiQL (http://localhost:8000/___graphql) 中。
我试过this教程。
gatsby-config.js
module.exports =
siteMetadata:
title: `Gatsby Default Starter`,
description: `Kick off your next, great Gatsby project with this default starter. This barebones starter ships with the main Gatsby configuration files you might need.`,
author: `@gatsbyjs`,
,
plugins: [
resolve: `gatsby-source-drupal`,
options:
baseUrl: `localhost:8000`,
apiBase: `jsonapi`, // optional, defaults to `jsonapi`
,
,
`gatsby-plugin-react-helmet`,
resolve: `gatsby-source-filesystem`,
options:
name: `images`,
path: `$__dirname/src/images`,
,
,
`gatsby-transformer-sharp`,
`gatsby-plugin-sharp`,
resolve: `gatsby-plugin-manifest`,
options:
name: `gatsby-starter-default`,
short_name: `starter`,
start_url: `/`,
background_color: `#663399`,
theme_color: `#663399`,
display: `minimal-ui`,
icon: `src/images/gatsby-icon.png`, // This path is relative to the root of the site.
,
// this (optional) plugin enables Progressive Web App + Offline functionality
// To learn more, visit: https://gatsby.dev/offline
// `gatsby-plugin-offline`,
],
例如运行
allNodeArticle
结束
"errors": [
"message": "Cannot query field \"allNodeArticle\" on type \"Query\".",
"locations": [
"line": 3,
"column": 2
],
"stack": [
"GraphQLError: Cannot query field \"allNodeArticle\" on type \"Query\".",
" at Object.Field (/app/node_modules/graphql/validation/rules/FieldsOnCorrectType.js:64:31)",
" at Object.enter (/app/node_modules/graphql/language/visitor.js:332:29)",
" at Object.enter (/app/node_modules/graphql/language/visitor.js:383:25)",
" at visit (/app/node_modules/graphql/language/visitor.js:250:26)",
" at validate (/app/node_modules/graphql/validation/validate.js:63:22)",
" at /app/node_modules/express-graphql/dist/index.js:154:52",
" at <anonymous>",
" at process._tickCallback (internal/process/next_tick.js:189:7)"
]
]
【问题讨论】:
【参考方案1】:看起来您指向的是位于 localhost:8000 的 Gatsby 开发服务器,而不是 Drupal 实例。您必须指向 drupal IP:port / URL:port 才能工作。
【讨论】:
【参考方案2】:你必须在安装drupal时安装drupal/jsonapi_extras
。
【讨论】:
以上是关于gatsby-source-drupal 不显示 graphql 查询的主要内容,如果未能解决你的问题,请参考以下文章