Class SchemaPrinter.Options

java.lang.Object
graphql.schema.idl.SchemaPrinter.Options
Enclosing class:
SchemaPrinter

public static class SchemaPrinter.Options extends Object
Options to use when printing a schema
  • Method Details

    • isIncludeIntrospectionTypes

      public boolean isIncludeIntrospectionTypes()
    • isIncludeScalars

      public boolean isIncludeScalars()
    • isIncludeSchemaDefinition

      public boolean isIncludeSchemaDefinition()
    • isIncludeDirectiveDefinitions

      public boolean isIncludeDirectiveDefinitions()
    • getIncludeDirectiveDefinition

      public Predicate<String> getIncludeDirectiveDefinition()
    • getIncludeDirective

      public Predicate<String> getIncludeDirective()
    • getIncludeSchemaElement

      public Predicate<GraphQLSchemaElement> getIncludeSchemaElement()
    • isDescriptionsAsHashComments

      public boolean isDescriptionsAsHashComments()
    • getComparatorRegistry

      public GraphqlTypeComparatorRegistry getComparatorRegistry()
    • isUseAstDefinitions

      public boolean isUseAstDefinitions()
    • isIncludeAstDefinitionComments

      public boolean isIncludeAstDefinitionComments()
    • defaultOptions

      public static SchemaPrinter.Options defaultOptions()
    • includeIntrospectionTypes

      public SchemaPrinter.Options includeIntrospectionTypes(boolean flag)
      This will allow you to include introspection types that are contained in a schema
      Parameters:
      flag - whether to include them
      Returns:
      options
    • includeScalarTypes

      public SchemaPrinter.Options includeScalarTypes(boolean flag)
      This will allow you to include scalar types that are contained in a schema
      Parameters:
      flag - whether to include them
      Returns:
      options
    • includeSchemaDefinition

      public SchemaPrinter.Options includeSchemaDefinition(boolean flag)
      This will force the printing of the graphql schema definition even if the query, mutation, and/or subscription types use the default names. Some graphql parsers require this information even if the schema uses the default type names. The schema definition will always be printed if any of the query, mutation, or subscription types do not use the default names.
      Parameters:
      flag - whether to force include the schema definition
      Returns:
      options
    • includeDirectiveDefinitions

      public SchemaPrinter.Options includeDirectiveDefinitions(boolean flag)
      This flag controls whether schema printer will include directive definitions at the top of the schema, but does not remove them from the field or type usage.

      In some schema definitions, like Apollo Federation, the schema should be printed without the directive definitions. This simplified schema is returned by a GraphQL query to other services, in a format that is different that the introspection query.

      On by default.

      Parameters:
      flag - whether to print directive definitions
      Returns:
      new instance of options
    • includeDirectiveDefinition

      public SchemaPrinter.Options includeDirectiveDefinition(Predicate<String> includeDirectiveDefinition)
      This is a Predicate that decides whether a directive definition is printed.
      Parameters:
      includeDirectiveDefinition - the predicate to decide of a directive definition is printed
      Returns:
      new instance of options
    • includeDirectives

      public SchemaPrinter.Options includeDirectives(boolean flag)
      Allow to print directives. In some situations, auto-generated schemas contain a lot of directives that make the printout noisy and having this flag would allow cleaner printout. On by default.
      Parameters:
      flag - whether to print directives
      Returns:
      new instance of options
    • includeDirectives

      public SchemaPrinter.Options includeDirectives(Predicate<String> includeDirective)
      This is a Predicate that decides whether a directive element is printed.
      Parameters:
      includeDirective - the predicate to decide of a directive is printed
      Returns:
      new instance of options
    • includeSchemaElement

      public SchemaPrinter.Options includeSchemaElement(Predicate<GraphQLSchemaElement> includeSchemaElement)
      This is a general purpose Predicate that decides whether a schema element is printed ever.
      Parameters:
      includeSchemaElement - the predicate to decide of a schema is printed
      Returns:
      new instance of options
    • useAstDefinitions

      public SchemaPrinter.Options useAstDefinitions(boolean flag)
      This flag controls whether schema printer will use the GraphQLType's original Ast TypeDefinitions when printing the type. This allows access to any `extend type` declarations that might have been originally made.
      Parameters:
      flag - whether to print via AST type definitions
      Returns:
      new instance of options
    • descriptionsAsHashComments

      public SchemaPrinter.Options descriptionsAsHashComments(boolean flag)
      Descriptions are defined as preceding string literals, however an older legacy versions of SDL supported preceding '#' comments as descriptions. Set this to true to enable this deprecated behavior. This option is provided to ease adoption and may be removed in future versions.
      Parameters:
      flag - whether to print description as # comments
      Returns:
      new instance of options
    • setComparators

      public SchemaPrinter.Options setComparators(GraphqlTypeComparatorRegistry comparatorRegistry)
      The comparator registry controls the printing order for registered GraphQLTypes.

      The default is to sort elements by name but you can put in your own code to decide on the field order

      Parameters:
      comparatorRegistry - The registry containing the Comparator and environment scoping rules.
      Returns:
      options
    • includeAstDefinitionComments

      public SchemaPrinter.Options includeAstDefinitionComments(boolean flag)
      Sometimes it is useful to allow printing schema comments. This can be achieved by providing comments in the AST definitions.

      The default is to ignore these for backward compatibility and due to this being relatively uncommon need.

      Parameters:
      flag - whether to include AST definition comments.
      Returns:
      new instance of Options