Class: GraphQL::Relay::KeycloakRepresentationIteratorConnection

Inherits:
BaseConnection
  • Object
show all
Defined in:
lib/keycloak/graphql/keycloak_representation_iterator_connection.rb

Instance Method Summary collapse

Instance Method Details

#cursor_from_node(item) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/keycloak/graphql/keycloak_representation_iterator_connection.rb', line 4

def cursor_from_node(item)
  item_index = paged_nodes.index(item)
  if item_index.nil?
    raise("Can't generate cursor, item not found in connection: #{item}")
  else
    offset = item_index + (paged_nodes_offset || 0)

    encode(offset.to_s)
  end
end

#firstObject



25
26
27
28
29
30
31
# File 'lib/keycloak/graphql/keycloak_representation_iterator_connection.rb', line 25

def first
  return @first if defined? @first

  @first = get_limited_arg(:first)
  @first = max_page_size if @first && max_page_size && @first > max_page_size
  @first
end

#has_next_pageObject

TODO: support ‘before`



16
17
18
# File 'lib/keycloak/graphql/keycloak_representation_iterator_connection.rb', line 16

def has_next_page
  sliced_nodes_count >= (first || max_page_size)
end

#has_previous_pageObject

TODO: support ‘before`



21
22
23
# File 'lib/keycloak/graphql/keycloak_representation_iterator_connection.rb', line 21

def has_previous_page
  false
end

#lastObject



33
34
35
36
37
38
39
# File 'lib/keycloak/graphql/keycloak_representation_iterator_connection.rb', line 33

def last
  return @last if defined? @last

  @last = get_limited_arg(:last)
  @last = max_page_size if @last && max_page_size && @last > max_page_size
  @last
end