如何根据条件检查动态显示/隐藏GraphiqlUI界面

问题描述

如何根据用户启用/禁用Graphiql(UI界面)

我有 node express/graphQL API 并使用 Graphiql UI 界面在 SIT 和生产环境中浏览/测试 API/查询。我无法通过设置 [graphiql:false]
来完全停止或隐藏此界面 因为我们需要将 API ui 限制为 PROD 中的某些用户

我的代码如下

app.use("/api",passport.authenticate("WindowsAuthentication"),graphql({ graphiql : true}));

是否可以根据条件或承诺设置“graphiql:true/false”,例如

app.use("/api",graphql({ graphiql : userAuth() ? true : false }));

基本上动态设置GraphIQL UI界面选项graphql({ graphiql : userAuth() ? true : false }));

任何线索都会有所帮助。

谢谢 兰加

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)