Sha256: 6437c47cd96dc24eb387a446528b5a597252a0f041f28376aa626820030b4831

Contents?: true

Size: 1.17 KB

Versions: 4

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

require 'graphql/groups/version'

require 'graphql'

require 'graphql/groups/utils'
require 'graphql/groups/group_type_registry'
require 'graphql/groups/schema/group_field'
require 'graphql/groups/schema/aggregate_field'
require 'graphql/groups/schema/aggregate_type'

require 'graphql/groups/has_aggregates'
require 'graphql/groups/has_groups'

require 'graphql/groups/schema/group_result_type'
require 'graphql/groups/schema/group_type'

require 'graphql/groups/query_result'
require 'graphql/groups/pending_query'
require 'graphql/groups/query_builder_context'
require 'graphql/groups/query_builder'
require 'graphql/groups/result_transformer'


module GraphQL
  module Groups
    def self.included(base)
      base.extend ClassMethods
    end

    module ClassMethods
      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
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
graphql-groups-0.2.3 lib/graphql/groups.rb
graphql-groups-0.2.2 lib/graphql/groups.rb
graphql-groups-0.2.1 lib/graphql/groups.rb
graphql-groups-0.2.0 lib/graphql/groups.rb