【问题标题】:Graphql Playground in Gatsby does not startGatsby 中的 Graphql Playground 无法启动
【发布时间】:2022-11-14 23:12:14
【问题描述】:

我正在尝试在 Gatsby 中运行 Graphql Playground。

我的配置:

  "scripts": {
    "develop": "GATSBY_GRAPHQL_IDE=playground gatsby develop",
    "start": "gatsby develop",
    "build": "gatsby build",
    "serve": "gatsby serve",
    "clean": "gatsby clean"
  },
  "dependencies": {
    "babel-plugin-styled-components": "^2.0.7",
    "dotenv": "^16.0.3",
    "gatsby": "^5.0.0",
    "gatsby-plugin-styled-components": "^6.0.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "styled-components": "^5.3.6"
  }

我跑 npm run develop。但是进入游乐场模式是行不通的。

我尝试安装 dotenv。

添加

 require('dotenv').config({
    path: `.env.${process.env.NODE_ENV}`,
  });

gatsby-config.js

然后将GATSBY_GRAPHQL_IDE=playground赋值给env.development

npm run develop

仍然没有运气。

我还尝试运行简单的GATSBY_GRAPHQL_IDE=playground gatsby develop。也没有帮助。

在将 Gatsby 版本更改为 ^4.21.1 并运行 npm install 后,它实际上工作了。

可能是什么问题呢? Playground 是否仍然存在于 5.0.0 中?

【问题讨论】:

    标签: graphql gatsby graphql-playground


    【解决方案1】:

    Playground 已从版本 5 中删除。

    来自here

    移除 GraphQL Playground也许你不知道,但 Gatsby 支持 GraphQL Playground 作为 GraphiQL 的替代品已经有一段时间了。在 Gatsby 5 中,我们将 GraphiQL 更新到了 v2,它与 GraphQL Playground 具有相同的功能。因此,我们删除了 GATSBY_GRAPHQL_IDE 环境变量和 GraphQL Playground。访问 GraphiQL 指南以了解有关 GraphiQL v2 的更多信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-22
      • 1970-01-01
      • 2020-06-01
      • 2020-09-04
      • 2022-01-02
      • 2019-05-30
      • 2020-04-16
      • 2021-03-12
      相关资源
      最近更新 更多