【问题标题】:Apollo-server-express introspection disabled but still possible over websocket connectionsApollo-server-express 内省已禁用,但仍然可以通过 websocket 连接
【发布时间】:2020-10-22 17:29:03
【问题描述】:

我们使用 apollo-server-express 来公开一个 graphql 服务器。

对于这个服务器,我们已将自省变量设置为 false 以向外部世界隐藏我们的模式,这对于通过 rest 调用的 Graphql 调用非常有效。

但是,当我们与同一台服务器建立 websocket 连接时,我们设法执行自省查询,即使在阿波罗服务器实例化期间,自省被显式设置为 false

启动 Apollo 服务器的配置如下所示:

{
   schema: <schema>,
   context: <context_function>,
   formatError: <format_error_function>,
   debug: false,
   tracing: false,
   subscriptions: {
       path: <graphQl_path>,
       keepAlive: <keep_alive_param>,
       onConnect: <connect_function>,
       onDisconnect: <disconnect_function>
   },
   introspection: false,
   playground: false
};

有人遇到过类似的问题吗?如果是,你能解决它吗?如何解决?

apollo-server-express 版本 = 2.1.0

npm 版本 = 6.4.1

节点版本 = 10.13.0

【问题讨论】:

    标签: graphql apollo-server introspection


    【解决方案1】:

    ApolloServer does internally 阻止您使用 __schema__type 解析器。我假设你可以做同样的事情:

    export const resolvers = {
      Query: {
        __type() {
          throw new Error('You cannot make introspection');
        },
        __schema() {
          throw new Error('You cannot make introspection');
        }
      }
    }
    

    【讨论】:

      猜你喜欢
      • 2021-02-02
      • 1970-01-01
      • 1970-01-01
      • 2021-12-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多