Apollo Server 2 中没有 CDN 的 GraphQL Playground

GraphQL Playground without CDN in Apollo Server 2

我正在从 Apollo Server Hapi v1 迁移到 Apollo Server Hapi v2。我们的生产环境无法访问 Internet,因此我们无法托管内置的 Graphiql 客户端,而是不得不创建我们自己的 Graphiql UI。我可以重用为 v1 开发的 Graphiql 代码,但更愿意使用 Apollo Server 内置的 Graphql Playground。

我们如何在不需要使用 CDN 文件 index.css 和 middleware.js 的情况下使用新的 Graphql Playground?

Apollo 服务器 2 在后台使用 graphql-playground-middleware-express 您实际上可以将一些选项传递给它,但不幸的是没有与 cdn 可用性相关的选项可用 但您还可以执行其他一些解决方案:

  1. 快速简单
    我发现在使用 graphql-playground 的电子释放时 它不上网,一切都在本地 运行.

  2. 破解
    您可以在自己的封闭网络中设置自己的 "local cdn" 在它试图找到的特定域中提供所需的文件...

  3. 最好但最难
    获取并 fork graphql-playground 并弄清楚如何不依赖 在 cdn 上。然后创建一个允许中间件的拉取请求 cdn独立