我在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)"
]
}
]
}
答案 0 :(得分:1)
您必须在drupal安装中安装drupal/jsonapi_extras
。
答案 1 :(得分:1)
您似乎要指向位于localhost:8000的Gatsby开发服务器,而不是Drupal实例。您必须指向drupal IP:port / URL:port才能使其正常工作。