module GraphQL::Schema::TypeExpression
@api private
Public Class Methods
build_type(types, ast_node)
click to toggle source
Fetch a type from a type map by its AST specification. Return `nil` if not found. @param types [GraphQL::Schema::TypeMap] @param ast_node [GraphQL::Language::Nodes::AbstractNode] @return [GraphQL::BaseType, nil]
# 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)
click to toggle source
# 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