Sha256: b664a6c28ca7fb357ff380ef9868949927fd5302e1d28f9514328b9f7e4aaff0
Contents?: true
Size: 1.38 KB
Versions: 13
Compression:
Stored size: 1.38 KB
Contents
module Ecoportal module API module Common module GraphQL module QueryIntegration include Ecoportal::API::Common::GraphQL::ClassHelpers::ClassMethods attr_accessor :client attr_reader :path # @!macro [attach] query # @method $1 # The $1 query integration # @return [Collection::$1, $1] # @return [Connection::$1, $1] def query(method, query_klass:, subpath: []) method = method.to_sym class_method = "#{method}_query_class".to_sym define_method(method) do |**kargs, &block| if kargs.empty? && !block_given? method(class_method).call else method(class_method).call.query(**kargs, &block) end end define_method(class_method) do final_path = path + [subpath].flatten.compact resolve_class(query_klass).tap do |klass| unless klass <= Ecoportal::API::GraphQL::Logic::BaseQuery raise "Expected query_klass to be of type Ecoportal::API::GraphQL::Logic::BaseQuery. Given: #{klass}" end end.new(client, base_path: final_path) end private class_method end end end end end end
Version data entries
13 entries across 13 versions & 1 rubygems