Package graphql.schema.idl
Class SchemaPrinter.Options
- java.lang.Object
-
- graphql.schema.idl.SchemaPrinter.Options
-
- Enclosing class:
- SchemaPrinter
public static class SchemaPrinter.Options extends java.lang.Object
Options to use when printing a schema
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SchemaPrinter.Options
defaultOptions()
SchemaPrinter.Options
descriptionsAsHashComments(boolean flag)
Descriptions are defined as preceding string literals, however an older legacy versions of SDL supported preceding '#' comments as descriptions.GraphqlTypeComparatorRegistry
getComparatorRegistry()
java.util.function.Predicate<java.lang.String>
getIncludeDirective()
java.util.function.Predicate<GraphQLSchemaElement>
getIncludeSchemaElement()
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.SchemaPrinter.Options
includeDirectives(boolean flag)
Allow to print directives.SchemaPrinter.Options
includeDirectives(java.util.function.Predicate<java.lang.String> includeDirective)
This is a Predicate that decides whether a directive element is printed.SchemaPrinter.Options
includeIntrospectionTypes(boolean flag)
This will allow you to include introspection types that are contained in a schemaSchemaPrinter.Options
includeScalarTypes(boolean flag)
This will allow you to include scalar types that are contained in a schemaSchemaPrinter.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.SchemaPrinter.Options
includeSchemaElement(java.util.function.Predicate<GraphQLSchemaElement> includeSchemaElement)
This is a general purpose Predicate that decides whether a schema element is printed ever.boolean
isDescriptionsAsHashComments()
boolean
isIncludeDirectiveDefinitions()
boolean
isIncludeIntrospectionTypes()
boolean
isIncludeScalars()
boolean
isIncludeSchemaDefinition()
boolean
isUseAstDefinitions()
SchemaPrinter.Options
setComparators(GraphqlTypeComparatorRegistry comparatorRegistry)
The comparator registry controls the printing order for registeredGraphQLType
s.SchemaPrinter.Options
useAstDefinitions(boolean flag)
This flag controls whether schema printer will use theGraphQLType
's original AstTypeDefinition
s when printing the type.
-
-
-
Method Detail
-
isIncludeIntrospectionTypes
public boolean isIncludeIntrospectionTypes()
-
isIncludeScalars
public boolean isIncludeScalars()
-
isIncludeSchemaDefinition
public boolean isIncludeSchemaDefinition()
-
isIncludeDirectiveDefinitions
public boolean isIncludeDirectiveDefinitions()
-
getIncludeDirective
public java.util.function.Predicate<java.lang.String> getIncludeDirective()
-
getIncludeSchemaElement
public java.util.function.Predicate<GraphQLSchemaElement> getIncludeSchemaElement()
-
isDescriptionsAsHashComments
public boolean isDescriptionsAsHashComments()
-
getComparatorRegistry
public GraphqlTypeComparatorRegistry getComparatorRegistry()
-
isUseAstDefinitions
public boolean isUseAstDefinitions()
-
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
-
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(java.util.function.Predicate<java.lang.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(java.util.function.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 theGraphQLType
's original AstTypeDefinition
s 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 registeredGraphQLType
s.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 theComparator
and environment scoping rules.- Returns:
- options
-
-