Package graphql.schema.idl
Class SchemaPrinter.Options
java.lang.Object
graphql.schema.idl.SchemaPrinter.Options
- Enclosing class:
SchemaPrinter
Options to use when printing a schema
-
Method Summary
Modifier and TypeMethodDescriptionstatic SchemaPrinter.Options
descriptionsAsHashComments
(boolean flag) Descriptions are defined as preceding string literals, however an older legacy versions of SDL supported preceding '#' comments as descriptions.includeAstDefinitionComments
(boolean flag) Sometimes it is useful to allow printing schema comments.includeDirectiveDefinition
(Predicate<String> includeDirectiveDefinition) This is a Predicate that decides whether a directive definition is printed.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.includeDirectives
(boolean flag) Allow to print directives.includeDirectives
(Predicate<String> includeDirective) This is a Predicate that decides whether a directive element is printed.includeIntrospectionTypes
(boolean flag) This will allow you to include introspection types that are contained in a schemaincludeScalarTypes
(boolean flag) This will allow you to include scalar types that are contained in a schemaincludeSchemaDefinition
(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.includeSchemaElement
(Predicate<GraphQLSchemaElement> includeSchemaElement) This is a general purpose Predicate that decides whether a schema element is printed ever.boolean
boolean
boolean
boolean
boolean
boolean
boolean
setComparators
(GraphqlTypeComparatorRegistry comparatorRegistry) The comparator registry controls the printing order for registeredGraphQLType
s.useAstDefinitions
(boolean flag) This flag controls whether schema printer will use theGraphQLType
's original AstTypeDefinition
s when printing the type.
-
Method Details
-
isIncludeIntrospectionTypes
public boolean isIncludeIntrospectionTypes() -
isIncludeScalars
public boolean isIncludeScalars() -
isIncludeSchemaDefinition
public boolean isIncludeSchemaDefinition() -
isIncludeDirectiveDefinitions
public boolean isIncludeDirectiveDefinitions() -
getIncludeDirectiveDefinition
-
getIncludeDirective
-
getIncludeSchemaElement
-
isDescriptionsAsHashComments
public boolean isDescriptionsAsHashComments() -
getComparatorRegistry
-
isUseAstDefinitions
public boolean isUseAstDefinitions() -
isIncludeAstDefinitionComments
public boolean isIncludeAstDefinitionComments() -
defaultOptions
-
includeIntrospectionTypes
This will allow you to include introspection types that are contained in a schema- Parameters:
flag
- whether to include them- Returns:
- options
-
includeScalarTypes
This will allow you to include scalar types that are contained in a schema- Parameters:
flag
- whether to include them- Returns:
- options
-
includeSchemaDefinition
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
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
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
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
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
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
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
-
includeAstDefinitionComments
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
-