Module: GraphQL::Schema::TypeExpression Private

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

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Class Method Summary collapse

Class Method Details

.build_type(type_owner, ast_node) ⇒ Class, ...

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Fetch a type from a type map by its AST specification. Return nil if not found.

Parameters:

Returns:


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/graphql/schema/type_expression.rb', line 11

def self.build_type(type_owner, ast_node)
  case ast_node
  when GraphQL::Language::Nodes::TypeName
    type_owner.get_type(ast_node.name)
  when GraphQL::Language::Nodes::NonNullType
    ast_inner_type = ast_node.of_type
    inner_type = build_type(type_owner, ast_inner_type)
    wrap_type(inner_type, :to_non_null_type)
  when GraphQL::Language::Nodes::ListType
    ast_inner_type = ast_node.of_type
    inner_type = build_type(type_owner, ast_inner_type)
    wrap_type(inner_type, :to_list_type)
  else
    raise "Invariant: unexpected type from ast: #{ast_node.inspect}"
  end
end