module GraphQL::Relay::Walker

Public Class Methods

query_string(schema, except: nil, only: nil) click to toggle source

Build a query that starts with a relay node and grabs the IDs of all its connections and node fields.

schema - The GraphQL::Schema to build a query for.

Returns a String query.

# File lib/graphql/relay/walker.rb, line 11
def self.query_string(schema, except: nil, only: nil)
  QueryBuilder.new(schema, except: except, only: only).query_string
end
walk(from_id:, &blk) click to toggle source

Start traversing a graph, starting from the given relay node ID.

from_id: - The `ID!` id to start walking from. &blk - A block to call with each Walker::Frame that is visited.

This block is responsible for executing a query for the frame's
GID, storing the results in the frame, and enqueuing further
node IDs to visit.

Returns nothing.

# File lib/graphql/relay/walker.rb, line 24
def self.walk(from_id:, &blk)
  queue = Queue.new
  queue.add_gid(from_id)
  queue.each_frame(&blk)
end