如何在GraphQl(Nodejs)中切换内省?

发布于 2025-02-06 19:17:47 字数 655 浏览 0 评论 0原文

我需要在Apollo-Graphql Nodejs服务器中切换内置。这意味着用户必须有能力在需要时打开和关闭内省。 我找到了两种方法:

  1. 在GraphQl实例创建期间 link
  2. 或通过中间件过滤掉所有“ __schema”和“ __ types”请求 - 链接

还有其他吗?我不想在每次切换后重新启动服务器或使用肮脏的技巧作为中间件。

I need to toggle introspection in apollo-graphql nodejs server. It means that user has to have ability to turn on and turn off introspection when he wants it.
I found two ways to do it:

  1. During graphql instance creation link
  2. Or via middleware which filter out all "__schema" and "__types" requests - link

Is there anything else? I don't want to restart server after each toggle or use dirty tricks as middleware.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧城烟雨 2025-02-13 19:17:47

我不是阿波罗工具的专家。
但是可以建议迁移到 graphql-yoga 并添加 usedisableIntroptection 插件,它具有有条件的toggle flag

I'm not an expert in Apollo tools.
But can suggest to migrate to GraphQL-Yoga and add the useDisableIntrospection plugin, which has conditional toggle flag

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文