Class: GraphQL::RemoteLoader::QueryMerger

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/remote_loader/query_merger.rb

Overview

Given a list of queries and their caller IDs, generate the merged and labeled GraphQL query to be sent off to the remote backend.

Class Method Summary collapse

Class Method Details

.merge(queries_and_caller_ids) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/graphql/remote_loader/query_merger.rb', line 9

def merge(queries_and_caller_ids)
  parsed_queries = queries_and_caller_ids.map do |query, caller_id|
    parsed_query = parse(query)

    parsed_query.definitions.each do |definition|
      attach_caller_id!(definition.children, caller_id)
    end

    parsed_query
  end

  merge_parsed_queries(parsed_queries).to_query_string
end