Class: GraphQLSchema
- Inherits:
-
Object
show all
- Defined in:
- lib/graphql_schema.rb,
lib/graphql_schema/version.rb
Defined Under Namespace
Modules: Deprecatable, NamedHash
Classes: EnumValue, Field, InputValue, Type, TypeDeclaration, TypeDefinition
Constant Summary
collapse
- VERSION =
"0.1.1"
Instance Method Summary
collapse
Constructor Details
#initialize(instrospection_result) ⇒ GraphQLSchema
Returns a new instance of GraphQLSchema.
5
6
7
|
# File 'lib/graphql_schema.rb', line 5
def initialize(instrospection_result)
@hash = instrospection_result.fetch('data').fetch('__schema')
end
|
Instance Method Details
#mutation_root_name ⇒ Object
17
18
19
20
21
|
# 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 ⇒ Object
13
14
15
|
# File 'lib/graphql_schema.rb', line 13
def query_root_name
@query_root_name ||= @hash.fetch('queryType').fetch('name')
end
|
#root_name?(type_name) ⇒ Boolean
9
10
11
|
# File 'lib/graphql_schema.rb', line 9
def root_name?(type_name)
type_name == query_root_name || type_name == mutation_root_name
end
|
#types ⇒ Object
23
24
25
|
# File 'lib/graphql_schema.rb', line 23
def types
@types ||= @hash.fetch('types').map{ |type_hash| TypeDefinition.new(type_hash) }.sort_by(&:name)
end
|