ecoportal-api-graphql 1.3.1 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/CHANGELOG.md +46 -7
  4. data/ecoportal-api-graphql.gemspec +1 -1
  5. data/lib/ecoportal/api/common/graphql/client.rb +2 -1
  6. data/lib/ecoportal/api/common/graphql/query_integration.rb +5 -5
  7. data/lib/ecoportal/api/common.graphql.rb +1 -1
  8. data/lib/ecoportal/api/graphql/base/action.rb +1 -1
  9. data/lib/ecoportal/api/graphql/base/action_category.rb +1 -1
  10. data/lib/ecoportal/api/graphql/base/contractor_entity.rb +1 -1
  11. data/lib/ecoportal/api/graphql/base/date_time.rb +1 -1
  12. data/lib/ecoportal/api/graphql/base/field.rb +1 -1
  13. data/lib/ecoportal/api/graphql/base/file_attachment.rb +1 -1
  14. data/lib/ecoportal/api/graphql/base/file_container.rb +1 -1
  15. data/lib/ecoportal/api/graphql/base/location_classification_type.rb +1 -1
  16. data/lib/ecoportal/api/graphql/base/location_node.rb +3 -5
  17. data/lib/ecoportal/api/graphql/base/location_structure/draft/structure.rb +37 -0
  18. data/lib/ecoportal/api/graphql/base/location_structure/draft.rb +89 -0
  19. data/lib/ecoportal/api/graphql/base/location_structure.rb +9 -5
  20. data/lib/ecoportal/api/graphql/base/organization.rb +1 -1
  21. data/lib/ecoportal/api/graphql/base/page.rb +1 -1
  22. data/lib/ecoportal/api/graphql/base/page_info.rb +1 -1
  23. data/lib/ecoportal/api/graphql/base/person_member.rb +1 -1
  24. data/lib/ecoportal/api/graphql/base/resource.rb +1 -1
  25. data/lib/ecoportal/api/graphql/builder/action.rb +3 -3
  26. data/lib/ecoportal/api/graphql/builder/contractor_entity.rb +3 -3
  27. data/lib/ecoportal/api/graphql/builder/location_structure/draft.rb +64 -0
  28. data/lib/ecoportal/api/graphql/builder/location_structure.rb +9 -3
  29. data/lib/ecoportal/api/graphql/connection/action.rb +2 -2
  30. data/lib/ecoportal/api/graphql/connection/action_category.rb +2 -2
  31. data/lib/ecoportal/api/graphql/connection/contractor_entity.rb +2 -2
  32. data/lib/ecoportal/api/graphql/connection/person_member.rb +2 -2
  33. data/lib/ecoportal/api/graphql/error/locations_error/fetch_nested.rb +49 -0
  34. data/lib/ecoportal/api/graphql/error/locations_error.rb +15 -4
  35. data/lib/ecoportal/api/graphql/error/locations_validation_error.rb +5 -1
  36. data/lib/ecoportal/api/graphql/error/validation_errors.rb +5 -1
  37. data/lib/ecoportal/api/graphql/fragment/location_draft.rb +39 -0
  38. data/lib/ecoportal/api/graphql/fragment/locations_error.rb +18 -0
  39. data/lib/ecoportal/api/graphql/fragment.rb +4 -2
  40. data/lib/ecoportal/api/graphql/input/action/archive.rb +1 -2
  41. data/lib/ecoportal/api/graphql/input/action/create.rb +1 -1
  42. data/lib/ecoportal/api/graphql/input/contractor_entity/create.rb +1 -1
  43. data/lib/ecoportal/api/graphql/input/contractor_entity/destroy.rb +1 -2
  44. data/lib/ecoportal/api/graphql/input/contractor_entity/update.rb +1 -1
  45. data/lib/ecoportal/api/graphql/input/id_diff.rb +1 -1
  46. data/lib/ecoportal/api/graphql/input/location_structure/apply_commands.rb +2 -3
  47. data/lib/ecoportal/api/graphql/input/location_structure/archive_command.rb +1 -1
  48. data/lib/ecoportal/api/graphql/input/location_structure/delete_command.rb +1 -1
  49. data/lib/ecoportal/api/graphql/input/location_structure/draft/add_commands.rb +49 -0
  50. data/lib/ecoportal/api/graphql/input/location_structure/draft/create.rb +15 -0
  51. data/lib/ecoportal/api/graphql/input/location_structure/draft/delete.rb +15 -0
  52. data/lib/ecoportal/api/graphql/input/location_structure/draft/drop_bad_commands.rb +16 -0
  53. data/lib/ecoportal/api/graphql/input/location_structure/draft/publish.rb +16 -0
  54. data/lib/ecoportal/api/graphql/input/location_structure/draft.rb +19 -0
  55. data/lib/ecoportal/api/graphql/input/location_structure/insert_command.rb +1 -1
  56. data/lib/ecoportal/api/graphql/input/location_structure/move_command.rb +1 -1
  57. data/lib/ecoportal/api/graphql/input/location_structure/reorder_command.rb +1 -1
  58. data/lib/ecoportal/api/graphql/input/location_structure/unarchive_command.rb +1 -1
  59. data/lib/ecoportal/api/graphql/input/location_structure/update_command.rb +1 -1
  60. data/lib/ecoportal/api/graphql/input/location_structure.rb +1 -1
  61. data/lib/ecoportal/api/graphql/input/search.rb +1 -1
  62. data/lib/ecoportal/api/graphql/input/search_filter.rb +1 -1
  63. data/lib/ecoportal/api/graphql/input/search_sorter.rb +1 -1
  64. data/lib/ecoportal/api/graphql/interface/base_page.rb +2 -2
  65. data/lib/ecoportal/api/graphql/{input/location_structure/command_interface.rb → interface/location_structure/command.rb} +9 -5
  66. data/lib/ecoportal/api/graphql/interface/location_structure/node.rb +43 -0
  67. data/lib/ecoportal/api/graphql/interface/location_structure/nodes.rb +28 -0
  68. data/lib/ecoportal/api/graphql/interface/location_structure.rb +14 -0
  69. data/lib/ecoportal/api/graphql/interface.rb +1 -1
  70. data/lib/ecoportal/api/graphql/logic/base_model.rb +13 -0
  71. data/lib/ecoportal/api/graphql/logic/base_query.rb +31 -9
  72. data/lib/ecoportal/api/graphql/logic/connection.rb +2 -2
  73. data/lib/ecoportal/api/graphql/logic/input.rb +11 -0
  74. data/lib/ecoportal/api/graphql/logic/mutation.rb +6 -11
  75. data/lib/ecoportal/api/graphql/logic/payload.rb +16 -3
  76. data/lib/ecoportal/api/graphql/logic/query.rb +1 -1
  77. data/lib/ecoportal/api/graphql/logic/query_array.rb +1 -1
  78. data/lib/ecoportal/api/graphql/logic/query_connection.rb +6 -6
  79. data/lib/ecoportal/api/graphql/logic.rb +2 -0
  80. data/lib/ecoportal/api/graphql/model/account.rb +1 -1
  81. data/lib/ecoportal/api/graphql/model/action.rb +1 -1
  82. data/lib/ecoportal/api/graphql/model/contractor_entity.rb +1 -1
  83. data/lib/ecoportal/api/graphql/model/field.rb +1 -1
  84. data/lib/ecoportal/api/graphql/model/file_attachment.rb +1 -1
  85. data/lib/ecoportal/api/graphql/model/file_container.rb +2 -2
  86. data/lib/ecoportal/api/graphql/model/location_node.rb +3 -5
  87. data/lib/ecoportal/api/graphql/model/location_structure/draft/structure.rb +15 -0
  88. data/lib/ecoportal/api/graphql/model/location_structure/draft.rb +15 -0
  89. data/lib/ecoportal/api/graphql/model/location_structure.rb +5 -1
  90. data/lib/ecoportal/api/graphql/model/organization.rb +26 -9
  91. data/lib/ecoportal/api/graphql/model/page.rb +1 -1
  92. data/lib/ecoportal/api/graphql/model/person_member.rb +2 -2
  93. data/lib/ecoportal/api/graphql/model/resource.rb +1 -1
  94. data/lib/ecoportal/api/graphql/model/user.rb +1 -1
  95. data/lib/ecoportal/api/graphql/mutation/action/archive.rb +3 -3
  96. data/lib/ecoportal/api/graphql/mutation/action/create.rb +3 -3
  97. data/lib/ecoportal/api/graphql/mutation/action/update.rb +3 -3
  98. data/lib/ecoportal/api/graphql/mutation/contractor_entity/create.rb +3 -3
  99. data/lib/ecoportal/api/graphql/mutation/contractor_entity/destroy.rb +3 -3
  100. data/lib/ecoportal/api/graphql/mutation/location_structure/apply_commands.rb +9 -16
  101. data/lib/ecoportal/api/graphql/mutation/location_structure/draft/add_commands.rb +55 -0
  102. data/lib/ecoportal/api/graphql/mutation/location_structure/draft/create.rb +54 -0
  103. data/lib/ecoportal/api/graphql/mutation/location_structure/draft/delete.rb +43 -0
  104. data/lib/ecoportal/api/graphql/mutation/location_structure/draft/drop_bad_commands.rb +56 -0
  105. data/lib/ecoportal/api/graphql/mutation/location_structure/draft/publish.rb +66 -0
  106. data/lib/ecoportal/api/graphql/mutation/location_structure/draft.rb +18 -0
  107. data/lib/ecoportal/api/graphql/mutation/location_structure.rb +1 -0
  108. data/lib/ecoportal/api/graphql/payload/action/archive.rb +1 -1
  109. data/lib/ecoportal/api/graphql/payload/action/create.rb +1 -1
  110. data/lib/ecoportal/api/graphql/payload/action/update.rb +1 -1
  111. data/lib/ecoportal/api/graphql/payload/contractor_entity/create.rb +1 -1
  112. data/lib/ecoportal/api/graphql/payload/contractor_entity/destroy.rb +1 -1
  113. data/lib/ecoportal/api/graphql/payload/contractor_entity/update.rb +1 -1
  114. data/lib/ecoportal/api/graphql/payload/location_structure/apply_commands.rb +32 -9
  115. data/lib/ecoportal/api/graphql/payload/location_structure/command_execution_result.rb +26 -3
  116. data/lib/ecoportal/api/graphql/payload/location_structure/draft/add_commands.rb +27 -0
  117. data/lib/ecoportal/api/graphql/payload/location_structure/draft/create.rb +34 -0
  118. data/lib/ecoportal/api/graphql/payload/location_structure/draft/delete.rb +27 -0
  119. data/lib/ecoportal/api/graphql/payload/location_structure/draft/drop_bad_commands.rb +41 -0
  120. data/lib/ecoportal/api/graphql/payload/location_structure/draft/publish.rb +56 -0
  121. data/lib/ecoportal/api/graphql/payload/location_structure/draft.rb +18 -0
  122. data/lib/ecoportal/api/graphql/payload/location_structure.rb +1 -1
  123. data/lib/ecoportal/api/graphql/query/action.rb +2 -2
  124. data/lib/ecoportal/api/graphql/query/action_categories.rb +3 -3
  125. data/lib/ecoportal/api/graphql/query/actions.rb +3 -3
  126. data/lib/ecoportal/api/graphql/query/contractor_entities.rb +3 -3
  127. data/lib/ecoportal/api/graphql/query/location_classifications.rb +2 -2
  128. data/lib/ecoportal/api/graphql/query/location_structure/draft.rb +62 -0
  129. data/lib/ecoportal/api/graphql/query/location_structure.rb +17 -4
  130. data/lib/ecoportal/api/graphql/query/location_structures.rb +5 -3
  131. data/lib/ecoportal/api/graphql.rb +14 -14
  132. data/lib/ecoportal/api/graphql_version.rb +1 -1
  133. metadata +37 -8
  134. data/lib/ecoportal/api/graphql/base_model.rb +0 -11
  135. data/lib/ecoportal/api/graphql/interface/location_node.rb +0 -39
  136. data/lib/ecoportal/api/graphql/payload/location_structure/command_interface.rb +0 -14
@@ -3,10 +3,10 @@ module Ecoportal
3
3
  class GraphQL
4
4
  module Mutation
5
5
  module LocationStructure
6
- class ApplyCommands < Ecoportal::API::GraphQL::Logic::Mutation
6
+ class ApplyCommands < Logic::Mutation
7
7
  field_name :applyCommandsToLocationStructure
8
- class_resolver :payload_class, Ecoportal::API::GraphQL::Payload::LocationStructure::ApplyCommands
9
- class_resolver :input_class, Ecoportal::API::GraphQL::Input::LocationStructure::ApplyCommands
8
+ class_resolver :payload_class, Payload::LocationStructure::ApplyCommands
9
+ class_resolver :input_class, Input::LocationStructure::ApplyCommands
10
10
 
11
11
  private
12
12
 
@@ -14,7 +14,10 @@ module Ecoportal
14
14
  payload_block = block || default_payload_block
15
15
  proc {
16
16
  mutation(input: :ApplyCommandsToLocationStructureInput!) {
17
- applyCommandsToLocationStructure(input: :input, &payload_block)
17
+ applyCommandsToLocationStructure(
18
+ input: :input,
19
+ &payload_block
20
+ )
18
21
  }
19
22
  }
20
23
  end
@@ -23,12 +26,7 @@ module Ecoportal
23
26
  proc {
24
27
  clientMutationId
25
28
  error {
26
- message
27
- conflictingIds
28
- validationErrors {
29
- error
30
- message
31
- }
29
+ ___Ecoportal__API__GraphQL__Fragment__LocationsError
32
30
  }
33
31
  results {
34
32
  ok
@@ -38,12 +36,7 @@ module Ecoportal
38
36
  __typename
39
37
  }
40
38
  error {
41
- conflictingIds
42
- message
43
- validationErrors {
44
- error
45
- message
46
- }
39
+ ___Ecoportal__API__GraphQL__Fragment__LocationsError
47
40
  }
48
41
  }
49
42
  structure {
@@ -0,0 +1,55 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Mutation
5
+ module LocationStructure
6
+ module Draft
7
+ class AddCommands < Logic::Mutation
8
+ field_name :addCommandsToLocationDraft
9
+
10
+ class_resolver :payload_class, Payload::LocationStructure::Draft::AddCommands
11
+ class_resolver :input_class, Input::LocationStructure::Draft::AddCommands
12
+
13
+ private
14
+
15
+ def basic_block(&block)
16
+ payload_block = block || default_payload_block
17
+ proc {
18
+ mutation(
19
+ input: :AddCommandsToLocationDraftInput!
20
+ ) {
21
+ addCommandsToLocationDraft(
22
+ input: :input,
23
+ &payload_block
24
+ )
25
+ }
26
+ }
27
+ end
28
+
29
+ def default_payload_block
30
+ proc {
31
+ clientMutationId
32
+ draft {
33
+ ___Ecoportal__API__GraphQL__Fragment__LocationDraft
34
+ structure {
35
+ nodes(
36
+ includeArchived: true
37
+ ) {
38
+ ___Ecoportal__API__GraphQL__Fragment__LocationNode
39
+ }
40
+ }
41
+ }
42
+ ok
43
+ errors {
44
+ details
45
+ fullMessages
46
+ }
47
+ }
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,54 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Mutation
5
+ module LocationStructure
6
+ module Draft
7
+ class Create < Logic::Mutation
8
+ field_name :createLocationDraft
9
+
10
+ class_resolver :payload_class, Payload::LocationStructure::Draft::Create
11
+ class_resolver :input_class, Input::LocationStructure::Draft::Create
12
+
13
+ private
14
+
15
+ def basic_block(&block)
16
+ payload_block = block || default_payload_block
17
+ proc {
18
+ mutation(
19
+ input: :CreateLocationDraftInput!
20
+ ) {
21
+ createLocationDraft(
22
+ input: :input,
23
+ &payload_block
24
+ )
25
+ }
26
+ }
27
+ end
28
+
29
+ def default_payload_block
30
+ proc {
31
+ clientMutationId
32
+ draft {
33
+ ___Ecoportal__API__GraphQL__Fragment__LocationDraft
34
+ structure {
35
+ nodes(
36
+ includeArchived: true
37
+ ) {
38
+ ___Ecoportal__API__GraphQL__Fragment__LocationNode
39
+ }
40
+ }
41
+ }
42
+ errors {
43
+ details
44
+ fullMessages
45
+ }
46
+ }
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,43 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Mutation
5
+ module LocationStructure
6
+ module Draft
7
+ class Delete < Logic::Mutation
8
+ field_name :deleteLocationDraft
9
+
10
+ class_resolver :payload_class, Payload::LocationStructure::Draft::Delete
11
+ class_resolver :input_class, Input::LocationStructure::Draft::Delete
12
+
13
+ private
14
+
15
+ def basic_block(&block)
16
+ payload_block = block || default_payload_block
17
+ proc {
18
+ mutation(input: :DeleteLocationDraftInput!) {
19
+ deleteLocationDraft(
20
+ input: :input,
21
+ &payload_block
22
+ )
23
+ }
24
+ }
25
+ end
26
+
27
+ def default_payload_block
28
+ proc {
29
+ clientMutationId
30
+ ok
31
+ errors {
32
+ details
33
+ fullMessages
34
+ }
35
+ }
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,56 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Mutation
5
+ module LocationStructure
6
+ class DropBadCommands < Logic::Mutation
7
+ field_name :dropBadCommandsFromLocationDraft
8
+
9
+ class_resolver :payload_class, Payload::LocationStructure::Draft::DropBadCommands
10
+ class_resolver :input_class, Input::LocationStructure::Draft::DropBadCommands
11
+
12
+ private
13
+
14
+ def basic_block(&block)
15
+ payload_block = block || default_payload_block
16
+ proc {
17
+ mutation(
18
+ input: :DropBadCommandsFromLocationDraftInput!
19
+ ) {
20
+ dropBadCommandsFromLocationDraft(
21
+ input: :input,
22
+ &payload_block
23
+ )
24
+ }
25
+ }
26
+ end
27
+
28
+ def default_payload_block
29
+ proc {
30
+ clientMutationId
31
+ draft {
32
+ ___Ecoportal__API__GraphQL__Fragment__LocationDraft
33
+ structure {
34
+ nodes(
35
+ includeArchived: true
36
+ ) {
37
+ ___Ecoportal__API__GraphQL__Fragment__LocationNode
38
+ }
39
+ }
40
+ }
41
+ ok
42
+ error {
43
+ ___Ecoportal__API__GraphQL__Fragment__LocationsError
44
+ }
45
+ errors {
46
+ details
47
+ fullMessages
48
+ }
49
+ }
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,66 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Mutation
5
+ module LocationStructure
6
+ module Draft
7
+ class Publish < Logic::Mutation
8
+ field_name :applyLocationDraft
9
+
10
+ class_resolver :payload_class, Payload::LocationStructure::Draft::Publish
11
+ class_resolver :input_class, Input::LocationStructure::Draft::Publish
12
+
13
+ private
14
+
15
+ def basic_block(&block)
16
+ payload_block = block || default_payload_block
17
+ proc {
18
+ mutation(
19
+ input: :ApplyLocationDraftInput!
20
+ ) {
21
+ applyLocationDraft(
22
+ input: :input,
23
+ &payload_block
24
+ )
25
+ }
26
+ }
27
+ end
28
+
29
+ def default_payload_block
30
+ proc {
31
+ clientMutationId
32
+ structure {
33
+ nodes(
34
+ includeArchived: true
35
+ ) {
36
+ ___Ecoportal__API__GraphQL__Fragment__LocationNode
37
+ }
38
+ }
39
+ ok
40
+ error {
41
+ ___Ecoportal__API__GraphQL__Fragment__LocationsError
42
+ }
43
+ errors {
44
+ details
45
+ fullMessages
46
+ }
47
+ results {
48
+ ok
49
+ command {
50
+ id
51
+ state
52
+ __typename
53
+ }
54
+ error {
55
+ ___Ecoportal__API__GraphQL__Fragment__LocationsError
56
+ }
57
+ }
58
+ }
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,18 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Mutation
5
+ module LocationStructure
6
+ module Draft
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
13
+
14
+ require_relative 'draft/create'
15
+ require_relative 'draft/publish'
16
+ require_relative 'draft/delete'
17
+ require_relative 'draft/add_commands'
18
+ require_relative 'draft/drop_bad_commands'
@@ -10,3 +10,4 @@ module Ecoportal
10
10
  end
11
11
 
12
12
  require_relative 'location_structure/apply_commands'
13
+ require_relative 'location_structure/draft'
@@ -3,7 +3,7 @@ module Ecoportal
3
3
  class GraphQL
4
4
  module Payload
5
5
  module Action
6
- class Archive < Ecoportal::API::GraphQL::Logic::Payload
6
+ class Archive < Logic::Payload
7
7
  class_resolver :item_class, "Ecoportal::API::GraphQL::Model::Action"
8
8
  end
9
9
  end
@@ -3,7 +3,7 @@ module Ecoportal
3
3
  class GraphQL
4
4
  module Payload
5
5
  module Action
6
- class Create < Ecoportal::API::GraphQL::Logic::Payload
6
+ class Create < Logic::Payload
7
7
  class_resolver :item_class, "Ecoportal::API::GraphQL::Model::Action"
8
8
  end
9
9
  end
@@ -3,7 +3,7 @@ module Ecoportal
3
3
  class GraphQL
4
4
  module Payload
5
5
  module Action
6
- class Update < Ecoportal::API::GraphQL::Logic::Payload
6
+ class Update < Logic::Payload
7
7
  class_resolver :item_class, "Ecoportal::API::GraphQL::Model::Action"
8
8
  end
9
9
  end
@@ -3,7 +3,7 @@ module Ecoportal
3
3
  class GraphQL
4
4
  module Payload
5
5
  module ContractorEntity
6
- class Create < Ecoportal::API::GraphQL::Logic::Payload
6
+ class Create < Logic::Payload
7
7
  class_resolver :item_class, "Ecoportal::API::GraphQL::Model::ContractorEntity"
8
8
  end
9
9
  end
@@ -3,7 +3,7 @@ module Ecoportal
3
3
  class GraphQL
4
4
  module Payload
5
5
  module ContractorEntity
6
- class Destroy < Ecoportal::API::GraphQL::Payload::ContractorEntity::Create
6
+ class Destroy < Payload::ContractorEntity::Create
7
7
  end
8
8
  end
9
9
  end
@@ -3,7 +3,7 @@ module Ecoportal
3
3
  class GraphQL
4
4
  module Payload
5
5
  module ContractorEntity
6
- class Update < Ecoportal::API::GraphQL::Payload::ContractorEntity::Create
6
+ class Update < Payload::ContractorEntity::Create
7
7
  end
8
8
  end
9
9
  end
@@ -3,21 +3,44 @@ module Ecoportal
3
3
  class GraphQL
4
4
  module Payload
5
5
  module LocationStructure
6
- class ApplyCommands < Ecoportal::API::GraphQL::BaseModel
6
+ class ApplyCommands < Logic::Payload
7
7
  read_only!
8
8
 
9
9
  passthrough :clientMutationId
10
- embeds_one :structure, klass: Ecoportal::API::GraphQL::Model::LocationStructure
11
- embeds_one :errors, klass: Ecoportal::API::GraphQL::Error::ValidationErrors, nullable: true
12
- embeds_one :error, klass: Ecoportal::API::GraphQL::Error::LocationsError, nullable: true
13
- embeds_many :results, read_only: true, klass: Ecoportal::API::GraphQL::Payload::LocationStructure::CommandExecutionResult
10
+ embeds_one :structure, klass: Model::LocationStructure
11
+ embeds_one :error, klass: Error::LocationsError, nullable: true
12
+ embeds_many :results, read_only: true, klass: Payload::LocationStructure::CommandExecutionResult
14
13
 
15
- def success?
16
- !errors?
14
+ include Error::LocationsError::FetchNested
15
+
16
+ def error?
17
+ super || result_errors? || locations_error?
18
+ end
19
+ alias_method :errors?, :error? # backward compatibility
20
+
21
+ def error_doc
22
+ err_doc = super
23
+ return err_doc if err_doc
24
+
25
+ if result_errors?
26
+ {
27
+ results: [
28
+ result_errors.first&.error_doc
29
+ ]
30
+ }
31
+ elsif locations_error?
32
+ {
33
+ locationsError: locations_error_doc
34
+ }
35
+ end
36
+ end
37
+
38
+ def result_errors?
39
+ result_errors.any?
17
40
  end
18
41
 
19
- def errors?
20
- errors && !errors.empty?
42
+ def result_errors
43
+ results.select(&:error?)
21
44
  end
22
45
  end
23
46
  end
@@ -3,12 +3,35 @@ module Ecoportal
3
3
  class GraphQL
4
4
  module Payload
5
5
  module LocationStructure
6
- class CommandExecutionResult < Ecoportal::API::GraphQL::BaseModel
6
+ class CommandExecutionResult < Logic::BaseModel
7
7
  read_only!
8
8
 
9
- embeds_one :command, klass: Ecoportal::API::GraphQL::Payload::LocationStructure::CommandInterface
10
- embeds_one :error, nullable: true, klass: Ecoportal::API::GraphQL::Error::LocationsError
9
+ embeds_one :command, klass: Interface::LocationStructure::Command
10
+ embeds_one :error, nullable: true, klass: Error::LocationsError
11
11
  passboolean :ok
12
+ alias_method :ok?, :ok
13
+
14
+ include Error::LocationsError::FetchNested
15
+
16
+ def error?
17
+ !ok? || locations_error?
18
+ end
19
+
20
+ def error_doc
21
+ if locations_error?
22
+ {
23
+ locationsError: locations_error_doc
24
+ }
25
+ elsif !ok?
26
+ {
27
+ ok: false
28
+ }
29
+ end
30
+ end
31
+
32
+ def success?
33
+ !error?
34
+ end
12
35
  end
13
36
  end
14
37
  end
@@ -0,0 +1,27 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Payload
5
+ module LocationStructure
6
+ module Draft
7
+ class AddCommands < Create
8
+ passboolean :ok
9
+ alias_method :ok?, :ok
10
+
11
+ def error?
12
+ super || !ok?
13
+ end
14
+
15
+ def error_doc
16
+ err_doc = super
17
+ return err_doc if err_doc
18
+
19
+ { ok: false } unless ok?
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,34 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Payload
5
+ module LocationStructure
6
+ module Draft
7
+ class Create < Logic::Payload
8
+ class_resolver :item_class, "Ecoportal::API::GraphQL::Model::LocationStructure::Draft"
9
+
10
+ embeds_one :draft, klass: :item_class
11
+ alias_method :item, :draft
12
+
13
+ def error?
14
+ super ||
15
+ draft.error?
16
+ end
17
+
18
+ def error_doc
19
+ err_doc = super
20
+ return err_doc if err_doc
21
+
22
+ if draft.error? && draft.respond_to?(:error_doc)
23
+ {
24
+ draft: draft.error_doc
25
+ }
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,27 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Payload
5
+ module LocationStructure
6
+ module Draft
7
+ class Delete < Logic::Payload
8
+ passboolean :ok
9
+ alias_method :ok?, :ok
10
+
11
+ def error?
12
+ super || !ok?
13
+ end
14
+
15
+ def error_doc
16
+ err_doc = super
17
+ return err_doc if err_doc
18
+
19
+ { ok: false } unless ok?
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,41 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Payload
5
+ module LocationStructure
6
+ module Draft
7
+ class DropBadCommands < AddCommands
8
+ passboolean :ok
9
+ alias_method :ok?, :ok
10
+
11
+ embeds_one :error, klass: Error::LocationsError, nullable: true
12
+
13
+ include Error::LocationsError::FetchNested
14
+
15
+ def error?
16
+ super ||
17
+ !ok? ||
18
+ locations_error?
19
+ end
20
+
21
+ def error_doc
22
+ err_doc = super
23
+ return err_doc if err_doc
24
+
25
+ if locations_error?
26
+ {
27
+ locationsError: locations_error_doc
28
+ }
29
+ elsif !ok?
30
+ {
31
+ ok: false
32
+ }
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end