Sha256: 453b82ef069df62efa1f9e87e91f8168a131ec48c0b9408bd829acf2d42404fc

Contents?: true

Size: 1.02 KB

Versions: 7

Compression:

Stored size: 1.02 KB

Contents

require "graphql"

module GraphQL::Relay
  module Walker
    # 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.
    def self.query_string(schema)
      QueryBuilder.new(schema).query_string
    end

    # 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.
    def self.walk(from_id:, &blk)
      queue = Queue.new
      queue.add_gid(from_id)
      queue.each_frame(&blk)
    end

  end
end

require "graphql/relay/walker/queue"
require "graphql/relay/walker/frame"
require "graphql/relay/walker/query_builder"

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
graphql-relay-walker-0.0.9 lib/graphql/relay/walker.rb
graphql-relay-walker-0.0.8 lib/graphql/relay/walker.rb
graphql-relay-walker-0.0.7 lib/graphql/relay/walker.rb
graphql-relay-walker-0.0.6 lib/graphql/relay/walker.rb
graphql-relay-walker-0.0.5 lib/graphql/relay/walker.rb
graphql-relay-walker-0.0.4 lib/graphql/relay/walker.rb
graphql-relay-walker-0.0.3 lib/graphql/relay/walker.rb