【问题标题】:gatsby-source-drupal does not show graphql queriesgatsby-source-drupal 不显示 graphql 查询
【发布时间】: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)"
      ]
    }
  ]
}

【问题讨论】:

    标签: drupal graphql gatsby


    【解决方案1】:

    看起来您指向的是位于 localhost:8000 的 Gatsby 开发服务器,而不是 Drupal 实例。您必须指向 drupal IP:port / URL:port 才能工作。

    【讨论】:

      【解决方案2】:

      你必须在安装drupal时安装drupal/jsonapi_extras

      【讨论】:

        猜你喜欢
        • 2020-02-05
        • 1970-01-01
        • 2019-04-02
        • 2020-04-20
        • 2020-05-01
        • 2020-11-14
        • 2020-10-22
        • 2020-08-11
        • 2020-07-23
        相关资源
        最近更新 更多