Apollo Server 2 中没有 CDN 的 GraphQL Playground

标签 graphql apollo-server

我正在从 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. 破解
    你可以在你的封闭网络中设置你自己的“本地 cdn” 在它试图找到的特定域中提供所需的文件...

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

关于Apollo Server 2 中没有 CDN 的 GraphQL Playground,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51197031/

相关文章:

postgresql - 使用 prisma 和 postgres 的行级安全性

javascript - 在 GraphQL 中搜索具有特定字符串的特定结果

apollo-server - 是否可以为 Apollo Server 附带的 GraphQL Playground 定义 HTTP header ?

graphql - 如何知道 GraphQL 查询中请求了哪些字段?

graphql - Cypress 没有看到 graphql 请求

java - 通过查询模式通过子对象访问父对象的 protected 字段

javascript - ReactJS/Javascript/Graphql/React- Apollo : Cannot read property 'loading' of undefined

php - 如何在灯塔 graphql laravel 中获取自定义指令参数

amazon-web-services - 联合类型导致 graphql 订阅

graphql - 尝试 Prisma GraphQL 'Variable ' 时,得到 'UserCreateInput!' $data' 类型 'createUser' 的预期值 '