lib/graphql/execution/lookahead.rb
# Like {#selection}, but for all nodes.
# It returns a list of Lookaheads for all Selections
#
# If `arguments:` is provided, each provided key/value will be matched
# against the arguments in each selection. This method will filter the selections
# if any of the given `arguments:` do not match the given selection.
#
# @example getting the name of a selection
#   def articles(lookahead:)
#     next_lookaheads = lookahead.selections # => [#<GraphQL::Execution::Lookahead ...>, ...]
#     next_lookaheads.map(&:name) #=> [:full_content, :title]
#   end
#
# @param arguments [Hash] Arguments which must match in the selection
# @return [Array<GraphQL::Execution::Lookahead>]
Like {#selection}, but for all nodes.
It returns a list of Lookaheads for all Selections

If `arguments:` is provided, each provided key/value will be matched
against the arguments in each selection. This method will filter the selections
if any of the given `arguments:` do not match the given selection.
Like { #selection } but for all nodes . It returns a list of Lookaheads for all Selections If ` arguments : ` is provided each provided key / value will be matched against the arguments in each selection . This method will filter the selections if any of the given ` arguments : ` do not match the given selection .
def selections(arguments: nil)
        subselections_by_type = {}
        subselections_on_type = subselections_by_type[@selected_type] = {}
        @ast_nodes.each do |node|
          find_selections(subselections_by_type, subselections_on_type, @selected_type, node.selections, arguments)
        end
        subselections = []
        subselections_by_type.each do |type, ast_nodes_by_response_key|
          ast_nodes_by_response_key.each do |response_key, ast_nodes|
            field_defn = FieldHelpers.get_field(@query.schema, type, ast_nodes.first.name)
            lookahead = Lookahead.new(query: @query, ast_nodes: ast_nodes, field: field_defn, owner_type: type)
            subselections.push(lookahead)
          end
        end
        subselections
      end
def selections ( arguments : nil ) subselections_by_type = { } subselections_on_type = subselections_by_type [ @selected_type ] = { } @ast_nodes . each do | node | find_selections ( subselections_by_type , subselections_on_type , @selected_type , node . selections , arguments ) end subselections = [ ] subselections_by_type . each do | type , ast_nodes_by_response_key | ast_nodes_by_response_key . each do | response_key , ast_nodes | field_defn = FieldHelpers . get_field ( @query . schema , type , ast_nodes . first . name ) lookahead = Lookahead . new ( query : @query , ast_nodes : ast_nodes , field : field_defn , owner_type : type ) subselections . push ( lookahead ) end end subselections end
Like {#selection}, but for all nodes.
Like { #selection } but for all nodes .
None
Array<GraphQL::Execution::Lookahead>
arguments
Arguments which must match in the selection
Arguments which must match in the selection
example
getting the name of a selection def articles(lookahead:) next_lookaheads = lookahead.selections # => [#, ...] next_lookaheads.map(&:name) #=> [:full_content, :title] end
getting the name of a selection def articles ( lookahead : ) next_lookaheads = lookahead . selections # = > [ # ... ] next_lookaheads . map ( & : name ) # = > [ : full_content : title ] end