Module: GraphQL::Schema::Printer
Overview
Used to convert your GraphQL::Schema to a GraphQL schema string
Instance Method Summary collapse
-
#print_introspection_schema ⇒ Object
Return the GraphQL schema string for the introspection type system.
-
#print_schema(schema, context: nil, only: nil, except: nil) ⇒ Object
Return a GraphQL schema string for the defined types in the schema.
Instance Method Details
#print_introspection_schema ⇒ Object
Return the GraphQL schema string for the introspection type system
33 34 35 36 37 38 39 40 41 |
# File 'lib/graphql/schema/printer.rb', line 33 def print_introspection_schema query_root = ObjectType.define(name: "Root") schema = GraphQL::Schema.define(query: query_root) blacklist = ->(m, ctx) { m == query_root } warden = GraphQL::Schema::Warden.new(blacklist, schema: schema, context: nil) print_filtered_schema(schema, warden: warden) end |
#print_schema(schema, context: nil, only: nil, except: nil) ⇒ Object
Return a GraphQL schema string for the defined types in the schema
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/graphql/schema/printer.rb', line 18 def print_schema(schema, context: nil, only: nil, except: nil) blacklist = if only ->(m, ctx) { !(IS_USER_DEFINED_MEMBER.call(m) && only.call(m, ctx)) } elsif except ->(m, ctx) { !IS_USER_DEFINED_MEMBER.call(m) || except.call(m, ctx) } else ->(m, ctx) { !IS_USER_DEFINED_MEMBER.call(m) } end warden = GraphQL::Schema::Warden.new(blacklist, schema: schema, context: context) print_filtered_schema(schema, warden: warden) end |