欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

【GraphQL Java 源码解析】Spring boot配置文件

程序员文章站 2022-03-03 12:01:18
...

GraphQLWebAutoConfiguration:GraphQL的Servlet配置类:

1. 通过GraphQLServletProperties配置 servlet。

Spring boot 配置前缀: graphql.servlet

配置属性包括:

 

private boolean enabled = true;   //是否可用
  private boolean corsEnabled = true;  //是否跨域
  private String mapping = "/graphql"; //GraphQL 前端访问网址,可以通过**配置宽域
  private boolean exceptionHandlersEnabled = false;
  private long subscriptionTimeout = 0;
  private ContextSetting contextSetting = ContextSetting.PER_QUERY_WITH_INSTRUMENTATION;
  private long asyncTimeout = 30000;
  private String tracingEnabled = "false";
  private boolean actuatorMetrics;
  private Integer maxQueryComplexity;
  private Integer maxQueryDepth;

GraphQLJavaToolsAutoConfiguration :GraphQL的Schema配置类:

 

2. 通过GraphQLToolsProperties配置

Spring boot 配置前缀: graphql.tools

配置属性包括:

 

 private String schemaLocationPattern = "**/*.graphqls";
  /**
   * Enable or disable the introspection query. Disabling it puts your server in contravention of
   * the GraphQL specification and expectations of most clients, so use this option with caution
   */
  private boolean introspectionEnabled = true;
  private boolean useDefaultObjectmapper = true;

 构建

  • schemaStringProvider: SchemaStringProvider  获取所有graphqls文件的内容
  • optionsBuilder:SchemaParserOptions Spring boot 配置前缀: graphql.tools.schema-parser-options 详细配置请参考: https://www.graphql-java-kickstart.com/tools/schema-parser-options/
  • schemaParser: SchemaParser schema解析的入口