如何在 graphql-spqr-spring-boot-starter 中禁用模式自省 [英] how to Disable Schema Introspection in graphql-spqr-spring-boot-starter

查看:87
本文介绍了如何在 graphql-spqr-spring-boot-starter 中禁用模式自省的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将 Spring Boot 应用程序与 graphql-spqr-spring-boot-starter 集成 https://github.com/leangen/graphql-spqr-spring-boot-starter ,我需要找到一种方法来禁用 graphql 模式自省,因为它是一种安全性生产问题.

I have integrated my spring boot application with graphql-spqr-spring-boot-starter https://github.com/leangen/graphql-spqr-spring-boot-starter , I need to find a way on how to disable graphql schema introspection since its a security issue for production.

推荐答案

schemaBuilder.fieldVisibility 已弃用.

schemaBuilder.fieldVisibility is Deprecated.

Graphql-spqr 0.10

    @Bean
    public GraphQLSchema graphQLSchema(GraphQLSchemaGenerator schemaGenerator) {
        schemaGenerator.withSchemaProcessors((schemaBuilder, buildContext) -> {
            schemaBuilder.codeRegistry(
                    buildContext
                            .codeRegistry
                            .fieldVisibility(NoIntrospectionGraphqlFieldVisibility.NO_INTROSPECTION_FIELD_VISIBILITY)
                            .build()
            );
            return schemaBuilder;
        });
        return schemaGenerator.generate();
    }

这篇关于如何在 graphql-spqr-spring-boot-starter 中禁用模式自省的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆