Sha256: b7907e51f5dfb9ee461e1b4567daab0723165890cd993285e46ed77c31d43231

Contents?: true

Size: 672 Bytes

Versions: 1

Compression:

Stored size: 672 Bytes

Contents

module GraphQL::Batch
  class QueryContainer
    attr_accessor :query_listener, :result

    def each_query
      raise NotImplementedError
    end

    def complete(result)
      if result.is_a?(QueryContainer)
        result.query_listener = self
        register_queries(result)
      else
        if instance_variable_defined?(:@result)
          raise "Query was already completed"
        end
        @result = result
        query_listener.query_completed(self)
      end
    end

    def query_completed(query)
      complete(query.result)
    end

    def register_queries(query_container)
      query_listener.register_queries(query_container)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
graphql-batch-0.1.0 lib/graphql/batch/query_container.rb