@@ -45,12 +45,16 @@ class Printer
45
45
# @param except [<#call(member, ctx)>]
46
46
# @param introspection [Boolean] Should include the introspection types in the string?
47
47
def initialize ( schema , context : nil , only : nil , except : nil , introspection : false )
48
- @schema = schema
49
- @context = context
48
+ @document_generator = GraphQL ::Language ::DocumentFromSchemaDefinition . new (
49
+ schema ,
50
+ context : context ,
51
+ only : only ,
52
+ except : except ,
53
+ include_introspection_types : introspection ,
54
+ include_built_ins : false ,
55
+ )
50
56
51
- blacklist = build_blacklist ( only , except , introspection : introspection )
52
- filter = GraphQL ::Filter . new ( except : blacklist )
53
- @warden = GraphQL ::Schema ::Warden . new ( filter , schema : @schema , context : @context )
57
+ @schema = schema
54
58
end
55
59
56
60
# Return the GraphQL schema string for the introspection type system
@@ -74,17 +78,8 @@ def self.print_schema(schema, **args)
74
78
75
79
# Return a GraphQL schema string for the defined types in the schema
76
80
def print_schema
77
- directive_definitions = warden . directives . map { |directive | print_directive ( directive ) }
78
-
79
- printable_types = warden . types . reject ( &:default_scalar? )
80
-
81
- type_definitions = printable_types
82
- . sort_by ( &:name )
83
- . map { |type | print_type ( type ) }
84
-
85
- [ print_schema_definition ] . compact
86
- . concat ( directive_definitions )
87
- . concat ( type_definitions ) . join ( "\n \n " )
81
+ document = @document_generator . document
82
+ document . to_query_string
88
83
end
89
84
90
85
def print_type ( type )
0 commit comments