gatsby-source-drupal не показывает запросы graphql - PullRequest
1 голос
/ 11 июня 2019

Я добавил gatsby-source-drupal в свой gatsby проект, но по какой-то причине drupal -запросы не отображаются в GraphiQL (http://localhost:8000/___graphql).

Я пытался в этом руководстве.

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)"
      ]
    }
  ]
}

Ответы [ 2 ]

1 голос
/ 16 июня 2019

Похоже, вы указываете на сервер разработки Gatsby по адресу localhost: 8000, а не экземпляр Drupal.Вы должны указать на drupal IP: порт / URL: порт, чтобы он работал.

1 голос
/ 11 июня 2019

Вы должны установить drupal/jsonapi_extras на установку drupal.

...