如何使用graphql和护照设置身份验证,但仍使用Playground

问题描述

在向我们的后端Graphql服务器添加身份验证后,“ Schema”和“ Docs”在Graphql Playground中不再可见。将令牌添加到Playground中的“ HTTP头”时执行查询,在通过身份验证时可以正常运行,而在未通过用户身份验证时则不能正常运行。

我们从Apollo服务器禁用了内置的Playground,并使用中间件xlsx来使用其他URL并绕过身份验证。现在,我们可以浏览到Playground并使用它,但是我们无法在其中读取“ Schema”或“ Docs”。

尝试启用graphql-playground-middleware-express不能解决此问题。在introspection的{​​{1}}中调用passport.authenticate()会更好吗?还有一个名为passport-graphql的工具,但它与本地策略配合使用,可能无法解决问题。在致电Playground路线之前,我也tried setting the token in the header,但这没用。

对此我们有点迷茫。感谢您提供的任何见解。

enter image description here

相关代码:

Context
apollo-server

解决方法

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

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

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