Module: GraphQL::Groups::ClassMethods

Defined in:
lib/graphql/groups.rb

Instance Method Summary collapse

Instance Method Details

#group(name, type, **options) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'lib/graphql/groups.rb', line 33

def group(name, type, **options)
  field name, type, extras: [:lookahead], null: false, **options

  define_method name do |lookahead: nil|
    pending_queries = QueryBuilder.parse(lookahead, object, context)
    query_results = pending_queries.map(&:execute)
    GraphQL::Groups::ResultTransformer.new.run(query_results)
  end
end