module GraphQL::Schema::Member::RelayShortcuts

Public Instance Methods

connection_type() click to toggle source
# File lib/graphql/schema/member/relay_shortcuts.rb, line 50
def connection_type
  @connection_type ||= begin
    conn_name = self.graphql_name + "Connection"
    edge_type_class = self.edge_type
    Class.new(connection_type_class) do
      graphql_name(conn_name)
      edge_type(edge_type_class)
    end
  end
end
connection_type_class(new_connection_type_class = nil) click to toggle source
# File lib/graphql/schema/member/relay_shortcuts.rb, line 23
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!
    for ancestor in self.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() click to toggle source
# File lib/graphql/schema/member/relay_shortcuts.rb, line 39
def edge_type
  @edge_type ||= begin
    edge_name = self.graphql_name + "Edge"
    node_type_class = self
    Class.new(edge_type_class) do
      graphql_name(edge_name)
      node_type(node_type_class)
    end
  end
end
edge_type_class(new_edge_type_class = nil) click to toggle source
# File lib/graphql/schema/member/relay_shortcuts.rb, line 7
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!
    for ancestor in self.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

Protected Instance Methods

configured_connection_type_class() click to toggle source
# File lib/graphql/schema/member/relay_shortcuts.rb, line 63
def configured_connection_type_class
  @connection_type_class
end
configured_edge_type_class() click to toggle source
# File lib/graphql/schema/member/relay_shortcuts.rb, line 67
def configured_edge_type_class
  @edge_type_class
end