Module: GraphQL::Schema::Member::RelayShortcuts

Included in:
Interface::DefinitionMethods, GraphQL::Schema::Member
Defined in:
lib/graphql/schema/member/relay_shortcuts.rb

Overview

-- @requires_ancestor: Module @requires_ancestor: GraphQL::Schema::Member::BaseDSLMethods

Instance Attribute Summary collapse

Instance Attribute Details

#connection_type ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/graphql/schema/member/relay_shortcuts.rb', line 61

def connection_type
  
  @connection_type ||= begin
    conn_name = self.graphql_name + "Connection"
    edge_type_class = self.edge_type
    Class.new(connection_type_class) do
      #: self as untyped
      graphql_name(conn_name)
      edge_type(edge_type_class)
    end
  end
end

#connection_type_class(new_connection_type_class = nil) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/graphql/schema/member/relay_shortcuts.rb', line 30

def connection_type_class(new_connection_type_class = nil)
  if new_connection_type_class
    
    @connection_type_class = new_connection_type_class
  else
    # Don't call `ancestor.connection_type_class`
    # because we don't want a fallback from any ancestors --
    # only apply the fallback if _no_ ancestor has a configured value!
    all_ancestors = self.ancestors #: Array[untyped]
    for ancestor in all_ancestors
      if ancestor.respond_to?(:configured_connection_type_class, true) && (ctc = ancestor.configured_connection_type_class)
        return ctc
      end
    end
    Types::Relay::BaseConnection
  end
end

#edge_type ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/graphql/schema/member/relay_shortcuts.rb', line 48

def edge_type
  
  @edge_type ||= begin
    edge_name = self.graphql_name + "Edge"
    node_type_class = self
    Class.new(edge_type_class) do
      #: self as untyped
      graphql_name(edge_name)
      node_type(node_type_class)
    end
  end
end

#edge_type_class(new_edge_type_class = nil) ⇒ Object



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

def edge_type_class(new_edge_type_class = nil)
  if new_edge_type_class
    
    @edge_type_class = new_edge_type_class
  else
    # Don't call `ancestor.edge_type_class`
    # because we don't want a fallback from any ancestors --
    # only apply the fallback if _no_ ancestor has a configured value!
    all_ancestors = self.ancestors #: Array[untyped]
    for ancestor in all_ancestors
      if ancestor.respond_to?(:configured_edge_type_class, true) && (etc = ancestor.configured_edge_type_class)
        return etc
      end
    end
    Types::Relay::BaseEdge
  end
end