Sha256: abea34bd35199593a169aa5f715861b6fbdea2672f629f3cf0d0eb29fb72450b
Contents?: true
Size: 1.99 KB
Versions: 3
Compression:
Stored size: 1.99 KB
Contents
module Ecoportal module API class GraphQL module Logic class Mutation < Ecoportal::API::GraphQL::Logic::BaseQuery class GenericPayload def initialize(*args, **kargs) raise "Missuse error. You should define a payload_class for a class that inherits from Mutation class." end end class GenericInput def initialize(*args, **kargs) raise "Missuse error. You should define a input_class for a class that inherits from Mutation class." end end class_resolver :payload_class, GenericPayload class_resolver :input_class, GenericInput # Query rely that manages the different blocks. # @return [Class] an object of `response_class` with the results hanving from `path`. def query(input:, path: self.path, &block) request(*path) do client.query(input: as_input(input), &basic_block(&block)) end rescue Faraday::ParsingError, Graphlient::Errors::FaradayServerError => e puts "Internal Error with these input ('#{input.class}'):" pp input raise end def response_class payload_class end private def as_input(value) case value when input_class value.as_input when Hash value when Ecoportal::API::GraphQL::Base::Model value.as_input when Hash value = Helpers::Model::HashKeys.keys_to_sym_deep(value) Ecoportal::API::Base::Model.as_input(value) when Enumerable value.map {|v| as_input(v)} else raise ArgumentError.new("Expecting Hash, GraphQL::Base::Model or Enumerable. Unsupported type '#{value.class}'.") end end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems