Package graphql.schema.idl
Class SchemaPrinter
java.lang.Object
graphql.schema.idl.SchemaPrinter
This can print an in memory GraphQL schema back to a logical schema definition
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Options to use when printing a schemaprivate static interface
-
Field Summary
FieldsModifier and TypeFieldDescriptionThis predicate excludes all directives which are specified by the GraphQL Specification.private final SchemaPrinter.Options
private final Map
<Class<?>, SchemaPrinter.SchemaElementPrinter<?>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate List
<GraphQLAppliedDirective> addDeprecatedDirectiveIfNeeded
(GraphQLDirectiveContainer directiveContainer) (package private) String
argsString
(Class<? extends GraphQLSchemaElement> parent, List<GraphQLArgument> arguments) (package private) String
argsString
(List<GraphQLArgument> arguments) private String
(package private) String
description
(String runtimeDescription, Description descriptionAst) private String
directiveDefinition
(GraphQLDirective directive) (package private) String
directivesString
(Class<? extends GraphQLSchemaElement> parentType, boolean isDeprecated, GraphQLDirectiveContainer directiveContainer) directivesString
(Class<? extends GraphQLSchemaElement> parentType, GraphQLDirectiveContainer directiveContainer) private String
directivesString
(Class<? extends GraphQLSchemaElement> parentType, List<GraphQLAppliedDirective> directives) private String
directiveString
(GraphQLAppliedDirective directive) private String
getAstDefinitionComments
(Object commentHolder) private Comparator
<? super GraphQLSchemaElement> getComparator
(Class<? extends GraphQLSchemaElement> parentType, Class<? extends GraphQLSchemaElement> elementType) private String
getDeprecationReason
(GraphQLDirectiveContainer directiveContainer) private String
getDescription
(Object descriptionHolder) private List
<GraphQLDirective> getSchemaDirectives
(GraphQLSchema schema) private boolean
hasAstDefinitionComments
(Object commentHolder) private boolean
hasDeprecatedDirective
(List<GraphQLAppliedDirective> directives) private boolean
hasDescription
(Object descriptionHolder) private boolean
isDeprecatedDirective
(GraphQLAppliedDirective directive) private boolean
private static boolean
This can print an in memory GraphQL IDL document back to a logical schema definition.print
(GraphQLDirective graphQLDirective) print
(GraphQLSchema schema) This can print an in memory GraphQL schema back to a logical schema definitionprint
(GraphQLType type) print
(List<GraphQLSchemaElement> elements) private void
printAsAst
(PrintWriter out, TypeDefinition<?> definition, List<? extends TypeDefinition<?>> extensions) This will print out a runtime graphql schema element using its contained AST type definition.private static String
printAst
(InputValueWithState value, GraphQLInputType type) private void
printComments
(PrintWriter out, Object graphQLType, String prefix) private String
printComments
(Object graphQLType, String prefix) private <T> SchemaPrinter.SchemaElementPrinter
<T> private void
printFieldDefinitions
(PrintWriter out, Comparator<? super GraphQLSchemaElement> comparator, List<GraphQLFieldDefinition> fieldDefinitions) private void
printMultiLineDescription
(PrintWriter out, String prefix, List<String> lines) private void
printMultiLineHashDescription
(PrintWriter out, String prefix, List<String> lines) private void
printSchemaElement
(PrintWriter out, GraphQLSchemaElement schemaElement, GraphqlFieldVisibility visibility) private void
printSingleLineDescription
(PrintWriter out, String prefix, String s) private boolean
shouldPrintAsAst
(TypeDefinition<?> definition) This will return true if the options say to use the AST and we have an AST elementprivate static String
(package private) String
typeString
(GraphQLType rawType)
-
Field Details
-
ExcludeGraphQLSpecifiedDirectivesPredicate
This predicate excludes all directives which are specified by the GraphQL Specification. Printing these directives is optional. -
printers
-
options
-
-
Constructor Details
-
SchemaPrinter
public SchemaPrinter() -
SchemaPrinter
-
-
Method Details
-
print
This can print an in memory GraphQL IDL document back to a logical schema definition. If you want to turn a Introspection query result into a Document (and then into a printed schema) then useIntrospectionResultToSchema.createSchemaDefinition(java.util.Map)
first to get theDocument
and then print that.- Parameters:
schemaIDL
- the parsed schema IDL- Returns:
- the logical schema definition
-
print
This can print an in memory GraphQL schema back to a logical schema definition- Parameters:
schema
- the schema in play- Returns:
- the logical schema definition
-
isIntrospectionType
-
scalarPrinter
-
enumPrinter
-
printFieldDefinitions
private void printFieldDefinitions(PrintWriter out, Comparator<? super GraphQLSchemaElement> comparator, List<GraphQLFieldDefinition> fieldDefinitions) -
interfacePrinter
-
unionPrinter
-
directivePrinter
-
objectPrinter
-
inputObjectPrinter
-
shouldPrintAsAst
This will return true if the options say to use the AST and we have an AST element- Parameters:
definition
- the AST type definition- Returns:
- true if we should print using AST nodes
-
printAsAst
private void printAsAst(PrintWriter out, TypeDefinition<?> definition, List<? extends TypeDefinition<?>> extensions) This will print out a runtime graphql schema element using its contained AST type definition. This must be guarded by a called toshouldPrintAsAst(TypeDefinition)
- Parameters:
out
- the output writerdefinition
- the AST type definitionextensions
- a list of type definition extensions
-
printAst
-
schemaPrinter
-
getSchemaDirectives
-
typeString
-
argsString
-
argsString
-
directivesString
public String directivesString(Class<? extends GraphQLSchemaElement> parentType, GraphQLDirectiveContainer directiveContainer) -
directivesString
String directivesString(Class<? extends GraphQLSchemaElement> parentType, boolean isDeprecated, GraphQLDirectiveContainer directiveContainer) -
directivesString
private String directivesString(Class<? extends GraphQLSchemaElement> parentType, List<GraphQLAppliedDirective> directives) -
directiveString
-
isDeprecatedDirective
-
hasDeprecatedDirective
-
addDeprecatedDirectiveIfNeeded
private List<GraphQLAppliedDirective> addDeprecatedDirectiveIfNeeded(GraphQLDirectiveContainer directiveContainer) -
getDeprecationReason
-
directiveDefinition
-
printer
-
print
-
print
-
print
-
printSchemaElement
private void printSchemaElement(PrintWriter out, GraphQLSchemaElement schemaElement, GraphqlFieldVisibility visibility) -
printComments
-
printComments
-
printMultiLineHashDescription
-
printMultiLineDescription
-
printSingleLineDescription
-
hasAstDefinitionComments
-
getAstDefinitionComments
-
comments
-
hasDescription
-
getDescription
-
description
-
getComparator
private Comparator<? super GraphQLSchemaElement> getComparator(Class<? extends GraphQLSchemaElement> parentType, Class<? extends GraphQLSchemaElement> elementType) -
trimNewLineChars
-
isNullOrEmpty
-