如何在GraphQl(Nodejs)中切换内省?
我需要在Apollo-Graphql Nodejs服务器中切换内置。这意味着用户必须有能力在需要时打开和关闭内省。 我找到了两种方法:
还有其他吗?我不想在每次切换后重新启动服务器或使用肮脏的技巧作为中间件。
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:
- During graphql instance creation link
- 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不是阿波罗工具的专家。
但是可以建议迁移到 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