class GraphQLSchema
Constants
- VERSION
Public Class Methods
new(instrospection_result)
click to toggle source
# File lib/graphql_schema.rb, line 5 def initialize(instrospection_result) @hash = instrospection_result.fetch('data').fetch('__schema') end
Public Instance Methods
directives()
click to toggle source
# File lib/graphql_schema.rb, line 23 def directives @directives ||= @hash.fetch('directives').map do |directive| Directive.new(directive) end.sort_by(&:name) end
mutation_root_name()
click to toggle source
# File lib/graphql_schema.rb, line 17 def mutation_root_name if mutation_type = @hash.fetch('mutationType') mutation_type.fetch('name') end end
query_root_name()
click to toggle source
# File lib/graphql_schema.rb, line 13 def query_root_name @query_root_name ||= @hash.fetch('queryType').fetch('name') end
root_name?(type_name)
click to toggle source
# File lib/graphql_schema.rb, line 9 def root_name?(type_name) type_name == query_root_name || type_name == mutation_root_name end
types()
click to toggle source
# File lib/graphql_schema.rb, line 29 def types @types ||= @hash.fetch('types').map{ |type_hash| TypeDefinition.new(type_hash) }.sort_by(&:name) end
types_by_name()
click to toggle source
# File lib/graphql_schema.rb, line 33 def types_by_name @types_by_name ||= types.map { |type| [type.name, type] }.to_h end