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(types, ast_node) ⇒ GraphQL::BaseType?

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.


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

def self.build_type(types, ast_node)
  case ast_node
  when GraphQL::Language::Nodes::TypeName
    types.fetch(ast_node.name, nil)
  when GraphQL::Language::Nodes::NonNullType
    ast_inner_type = ast_node.of_type
    inner_type = build_type(types, ast_inner_type)
    wrap_type(inner_type, GraphQL::NonNullType)
  when GraphQL::Language::Nodes::ListType
    ast_inner_type = ast_node.of_type
    inner_type = build_type(types, ast_inner_type)
    wrap_type(inner_type, GraphQL::ListType)
  end
end

.wrap_type(type, wrapper) ⇒ Object

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.


26
27
28
29
30
31
32
# File 'lib/graphql/schema/type_expression.rb', line 26

def self.wrap_type(type, wrapper)
  if type.nil?
    nil
  else
    wrapper.new(of_type: type)
  end
end