Module: GraphQL::Schema::TypeExpression

Defined in:
lib/graphql/schema/type_expression.rb

Class Method Summary collapse

Class Method Details

.build_type(schema, ast_node) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/graphql/schema/type_expression.rb', line 4

def self.build_type(schema, ast_node)
  case ast_node
  when GraphQL::Language::Nodes::TypeName
    type_name = ast_node.name
    schema.types[type_name]
  when GraphQL::Language::Nodes::NonNullType
    ast_inner_type = ast_node.of_type
    build_type(schema, ast_inner_type).to_non_null_type
  when GraphQL::Language::Nodes::ListType
    ast_inner_type = ast_node.of_type
    build_type(schema, ast_inner_type).to_list_type
  end
end