Class: Ecoportal::API::GraphQL::Payload::LocationStructure::ApplyCommands

Inherits:
Logic::Payload show all
Includes:
Error::LocationsError::FetchNested
Defined in:
lib/ecoportal/api/graphql/payload/location_structure/apply_commands.rb

Constant Summary

Constants included from Common::GraphQL::Model::Diffable

Common::GraphQL::Model::Diffable::DIFF_CLASS

Instance Method Summary collapse

Methods included from Error::LocationsError::FetchNested

#conflictingIds, #conflictingIds?, #locations_error?, #locations_error_doc, #validationErrors, #validationErrors?

Methods inherited from Logic::Payload

#success?

Methods included from Common::GraphQL::Model::AsInput

#as_input

Methods included from Common::GraphQL::Model::Diffable

#as_update, #dirty?

Instance Method Details

#error?Boolean Also known as: errors?

Returns:

  • (Boolean)


16
17
18
# File 'lib/ecoportal/api/graphql/payload/location_structure/apply_commands.rb', line 16

def error?
  super || result_errors? || locations_error?
end

#error_docObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ecoportal/api/graphql/payload/location_structure/apply_commands.rb', line 21

def error_doc
  err_doc = super
  return err_doc if err_doc

  if result_errors?
    {
      results: [
        result_errors.first&.error_doc
      ]
    }
  elsif locations_error?
    {
      locationsError: locations_error_doc
    }
  end
end

#result_errorsObject



42
43
44
# File 'lib/ecoportal/api/graphql/payload/location_structure/apply_commands.rb', line 42

def result_errors
  results.select(&:error?)
end

#result_errors?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/ecoportal/api/graphql/payload/location_structure/apply_commands.rb', line 38

def result_errors?
  result_errors.any?
end