分享 投稿 编辑 正文

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


GraphQLWebAutoConfiguration:GraphQL的Servlet配置类:
1. 通过GraphQLServletProperties配置 servlet。
Spring boot 配置前缀:  graphql.servlet
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
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解析的入口
  • schemaStringProvider:  SchemaStringProvider  获取所有 graphqls文件的内容
    SchemaStringProvider
    graphqls文件的内容
    optionsBuilder: SchemaParserOptions Spring boot 配置前缀:  graphql.tools.schema-parser-options 详细配置请参考: https://www.graphql-java-kickstart.com/tools/schema-parser-options/
    SchemaParserOptions 
    graphql.tools.schema-parser-options  详细配置请参考:  https://www.graphql-java-kickstart.com/tools/schema-parser-options/
     详细配置请参考: 
    https://www.graphql-java-kickstart.com/tools/schema-parser-options/
    schemaParser: SchemaParser schema解析的入口
    转载: https://www.iteye.com/blog/microsoul-2520220