ecoportal-api-graphql 0.1.11 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -9
  3. data/ecoportal-api-graphql.gemspec +1 -1
  4. data/lib/ecoportal/api/common/graphql/query_integration.rb +5 -4
  5. data/lib/ecoportal/api/graphql/base/location_node.rb +15 -0
  6. data/lib/ecoportal/api/graphql/base/location_structure.rb +21 -0
  7. data/lib/ecoportal/api/graphql/base.rb +2 -10
  8. data/lib/ecoportal/api/graphql/builder/location_structure.rb +29 -0
  9. data/lib/ecoportal/api/graphql/builder.rb +10 -0
  10. data/lib/ecoportal/api/graphql/connection/action.rb +1 -1
  11. data/lib/ecoportal/api/graphql/connection/contractor_entity.rb +1 -1
  12. data/lib/ecoportal/api/graphql/connection/person_member.rb +1 -1
  13. data/lib/ecoportal/api/graphql/error/locations_error.rb +13 -0
  14. data/lib/ecoportal/api/graphql/error/locations_validation_error.rb +11 -0
  15. data/lib/ecoportal/api/graphql/{base → error}/validation_errors.rb +1 -1
  16. data/lib/ecoportal/api/graphql/error.rb +12 -0
  17. data/lib/ecoportal/api/graphql/fragment/location_node.rb +20 -0
  18. data/lib/ecoportal/api/graphql/fragment.rb +1 -1
  19. data/lib/ecoportal/api/graphql/helpers/{tag_tree.rb → locations_tree.rb} +10 -3
  20. data/lib/ecoportal/api/graphql/helpers.rb +1 -1
  21. data/lib/ecoportal/api/graphql/input/contractor_entity/create.rb +16 -0
  22. data/lib/ecoportal/api/graphql/input/contractor_entity/destroy.rb +13 -0
  23. data/lib/ecoportal/api/graphql/input/{update_contractor_entity.rb → contractor_entity/update.rb} +1 -1
  24. data/lib/ecoportal/api/graphql/input/contractor_entity.rb +14 -0
  25. data/lib/ecoportal/api/graphql/{base/id_diff_input.rb → input/id_diff.rb} +2 -2
  26. data/lib/ecoportal/api/graphql/input/location_structure/apply_commands.rb +48 -0
  27. data/lib/ecoportal/api/graphql/input/location_structure/archive_command.rb +13 -0
  28. data/lib/ecoportal/api/graphql/input/location_structure/command_interface.rb +26 -0
  29. data/lib/ecoportal/api/graphql/input/location_structure/delete_command.rb +13 -0
  30. data/lib/ecoportal/api/graphql/input/location_structure/insert_command.rb +13 -0
  31. data/lib/ecoportal/api/graphql/input/location_structure/move_command.rb +14 -0
  32. data/lib/ecoportal/api/graphql/input/location_structure/reorder_command.rb +13 -0
  33. data/lib/ecoportal/api/graphql/input/location_structure/unarchive_command.rb +13 -0
  34. data/lib/ecoportal/api/graphql/input/location_structure/update_command.rb +14 -0
  35. data/lib/ecoportal/api/graphql/input/location_structure.rb +20 -0
  36. data/lib/ecoportal/api/graphql/input.rb +3 -3
  37. data/lib/ecoportal/api/graphql/{base → logic}/connection.rb +1 -1
  38. data/lib/ecoportal/api/graphql/{base → logic}/mutation.rb +10 -1
  39. data/lib/ecoportal/api/graphql/{base → logic}/payload.rb +2 -2
  40. data/lib/ecoportal/api/graphql/{base → logic}/query.rb +3 -2
  41. data/lib/ecoportal/api/graphql/{base → logic}/query_array.rb +2 -2
  42. data/lib/ecoportal/api/graphql/{base → logic}/query_connection.rb +3 -3
  43. data/lib/ecoportal/api/graphql/logic.rb +15 -0
  44. data/lib/ecoportal/api/graphql/model/location_node.rb +11 -0
  45. data/lib/ecoportal/api/graphql/model/{tag_tree.rb → location_structure.rb} +2 -2
  46. data/lib/ecoportal/api/graphql/model/organization.rb +2 -2
  47. data/lib/ecoportal/api/graphql/model.rb +2 -2
  48. data/lib/ecoportal/api/graphql/mutation/contractor_entity/create.rb +40 -0
  49. data/lib/ecoportal/api/graphql/mutation/contractor_entity.rb +14 -0
  50. data/lib/ecoportal/api/graphql/mutation/location_structure/apply_commands.rb +61 -0
  51. data/lib/ecoportal/api/graphql/mutation/location_structure.rb +12 -0
  52. data/lib/ecoportal/api/graphql/mutation.rb +2 -1
  53. data/lib/ecoportal/api/graphql/payload/contractor_entity/create.rb +13 -0
  54. data/lib/ecoportal/api/graphql/payload/contractor_entity/destroy.rb +12 -0
  55. data/lib/ecoportal/api/graphql/payload/contractor_entity/update.rb +12 -0
  56. data/lib/ecoportal/api/graphql/payload/contractor_entity.rb +14 -0
  57. data/lib/ecoportal/api/graphql/payload/location_structure/apply_commands.rb +25 -0
  58. data/lib/ecoportal/api/graphql/payload/location_structure/command_execution_result.rb +15 -0
  59. data/lib/ecoportal/api/graphql/payload/location_structure/command_interface.rb +14 -0
  60. data/lib/ecoportal/api/graphql/payload/location_structure.rb +14 -0
  61. data/lib/ecoportal/api/graphql/payload.rb +2 -3
  62. data/lib/ecoportal/api/graphql/query/actions.rb +1 -1
  63. data/lib/ecoportal/api/graphql/query/contractor_entities.rb +1 -1
  64. data/lib/ecoportal/api/graphql/query/{tag_tree.rb → location_structure.rb} +12 -8
  65. data/lib/ecoportal/api/graphql/query/location_structures.rb +46 -0
  66. data/lib/ecoportal/api/graphql/query.rb +2 -2
  67. data/lib/ecoportal/api/graphql.rb +9 -2
  68. data/lib/ecoportal/api/graphql_version.rb +1 -1
  69. data/tests/loc_structure_get.rb +11 -0
  70. data/tests/loc_structure_update.rb +51 -0
  71. data/tests/loc_structures_get.rb +15 -0
  72. data/tests/local_libs.rb +2 -2
  73. metadata +63 -37
  74. data/lib/ecoportal/api/graphql/base/tag_tree.rb +0 -20
  75. data/lib/ecoportal/api/graphql/base/tag_tree_node.rb +0 -13
  76. data/lib/ecoportal/api/graphql/fragment/tag_tree_node.rb +0 -16
  77. data/lib/ecoportal/api/graphql/input/create_contractor_entity.rb +0 -14
  78. data/lib/ecoportal/api/graphql/input/destroy_contractor_entity.rb +0 -11
  79. data/lib/ecoportal/api/graphql/model/tag_tree_node.rb +0 -10
  80. data/lib/ecoportal/api/graphql/mutation/create_contractor_entity.rb +0 -38
  81. data/lib/ecoportal/api/graphql/payload/create_contractor_entity.rb +0 -11
  82. data/lib/ecoportal/api/graphql/payload/destroy_contractor_entity.rb +0 -10
  83. data/lib/ecoportal/api/graphql/payload/update_contractor_entity.rb +0 -10
  84. data/lib/ecoportal/api/graphql/query/tag_trees.rb +0 -37
  85. data/tests/tagtree_get.rb +0 -7
  86. data/tests/tagtrees_get.rb +0 -7
  87. /data/tests/{create_contractor_entity.rb → contractor_entity_create.rb} +0 -0
@@ -1,13 +1,18 @@
1
1
  module Ecoportal
2
2
  module API
3
3
  class GraphQL
4
- module Base
4
+ module Logic
5
5
  class Mutation
6
6
  class GenericPayload
7
7
  def initialize(*args, **kargs)
8
8
  raise "Missuse error. You should define a payload_class for a class that inherits from Mutation class."
9
9
  end
10
10
  end
11
+ class GenericInput
12
+ def initialize(*args, **kargs)
13
+ raise "Missuse error. You should define a input_class for a class that inherits from Mutation class."
14
+ end
15
+ end
11
16
 
12
17
  include Ecoportal::API::Common::GraphQL::ClassHelpers
13
18
 
@@ -22,6 +27,8 @@ module Ecoportal
22
27
  end
23
28
 
24
29
  class_resolver :payload_class, GenericPayload
30
+ class_resolver :input_class, GenericInput
31
+
25
32
  attr_reader :client
26
33
  attr_reader :base_path
27
34
 
@@ -67,6 +74,8 @@ module Ecoportal
67
74
 
68
75
  def as_input(value)
69
76
  case value
77
+ when input_class
78
+ value.as_input
70
79
  when Hash
71
80
  value
72
81
  when Ecoportal::API::GraphQL::Base::Model
@@ -1,7 +1,7 @@
1
1
  module Ecoportal
2
2
  module API
3
3
  class GraphQL
4
- module Base
4
+ module Logic
5
5
  class Payload < Ecoportal::API::GraphQL::Base::Model
6
6
  class GenericItem
7
7
  def initialize(*args, **kargs)
@@ -13,7 +13,7 @@ module Ecoportal
13
13
 
14
14
  class_resolver :item_class, GenericItem
15
15
  embeds_one :item, klass: :item_class
16
- embeds_one :errors, klass: Ecoportal::API::GraphQL::Base::ValidationErrors, nullable: true
16
+ embeds_one :errors, klass: Ecoportal::API::GraphQL::Error::ValidationErrors, nullable: true
17
17
 
18
18
  def success?
19
19
  !errors || errors.empty?
@@ -1,7 +1,7 @@
1
1
  module Ecoportal
2
2
  module API
3
3
  class GraphQL
4
- module Base
4
+ module Logic
5
5
  class Query
6
6
  class GenericItem
7
7
  def initialize(*args, **kargs)
@@ -80,9 +80,10 @@ module Ecoportal
80
80
  request(*path) do
81
81
  client.query(query_params, &block)
82
82
  end
83
- rescue Faraday::ParsingError => e
83
+ rescue Faraday::ParsingError, Graphlient::Errors::GraphQLError => e
84
84
  puts "Internal Error with these params:"
85
85
  pp kargs
86
+ pp block
86
87
  raise
87
88
  end
88
89
 
@@ -1,8 +1,8 @@
1
1
  module Ecoportal
2
2
  module API
3
3
  class GraphQL
4
- module Base
5
- class QueryArray < Ecoportal::API::GraphQL::Base::Query
4
+ module Logic
5
+ class QueryArray < Ecoportal::API::GraphQL::Logic::Query
6
6
  include Enumerable
7
7
 
8
8
  def each(item_block: nil, **kargs, &block)
@@ -1,8 +1,8 @@
1
1
  module Ecoportal
2
2
  module API
3
3
  class GraphQL
4
- module Base
5
- class QueryConnection < Ecoportal::API::GraphQL::Base::Query
4
+ module Logic
5
+ class QueryConnection < Ecoportal::API::GraphQL::Logic::Query
6
6
  accepted_params :searchConf, :after, :before, :first, :last
7
7
  include Enumerable
8
8
 
@@ -25,7 +25,7 @@ module Ecoportal
25
25
  return connection_class if respond_to?(:connection_class)
26
26
  @response_class ||= self.class.new_class(
27
27
  item_class,
28
- inherits: Ecoportal::API::GraphQL::Base::Connection,
28
+ inherits: Ecoportal::API::GraphQL::Logic::Connection,
29
29
  namespace: "Ecoportal::API::GraphQL::Connection"
30
30
  ) do |klass|
31
31
  klass.item_class = item_class
@@ -0,0 +1,15 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Logic
5
+ end
6
+ end
7
+ end
8
+ end
9
+
10
+ require 'ecoportal/api/graphql/logic/query'
11
+ require 'ecoportal/api/graphql/logic/mutation'
12
+ require 'ecoportal/api/graphql/logic/connection'
13
+ require 'ecoportal/api/graphql/logic/query_array'
14
+ require 'ecoportal/api/graphql/logic/query_connection'
15
+ require 'ecoportal/api/graphql/logic/payload'
@@ -0,0 +1,11 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Model
5
+ class LocationNode < Ecoportal::API::GraphQL::Base::LocationNode
6
+ embeds_one :parent, klass: Model::LocationNode, nullable: true
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -2,8 +2,8 @@ module Ecoportal
2
2
  module API
3
3
  class GraphQL
4
4
  module Model
5
- class TagTree < Ecoportal::API::GraphQL::Base::TagTree
6
- embeds_many :nodes, klass: Ecoportal::API::GraphQL::Model::TagTreeNode, order_key: :weight
5
+ class LocationStructure < Ecoportal::API::GraphQL::Base::LocationStructure
6
+ embeds_many :nodes, klass: Ecoportal::API::GraphQL::Model::LocationNode, order_key: :weight
7
7
  end
8
8
  end
9
9
  end
@@ -12,8 +12,8 @@ module Ecoportal
12
12
  DEFAULT_PATH.dup.push(*add)
13
13
  end
14
14
 
15
- query :tagTree, query_klass: "Ecoportal::API::GraphQL::Query::TagTree"
16
- query :tagTrees, query_klass: "Ecoportal::API::GraphQL::Query::TagTrees"
15
+ query :LocationStructure, subpath: "locations", query_klass: "Ecoportal::API::GraphQL::Query::LocationStructure"
16
+ query :LocationStructures, subpath: "locations", query_klass: "Ecoportal::API::GraphQL::Query::LocationStructures"
17
17
  query :contractorEntities, query_klass: "Ecoportal::API::GraphQL::Query::ContractorEntities"
18
18
  #contractorEntity,
19
19
  query :actions, query_klass: "Ecoportal::API::GraphQL::Query::Actions"
@@ -7,8 +7,8 @@ module Ecoportal
7
7
  end
8
8
  end
9
9
 
10
- require 'ecoportal/api/graphql/model/tag_tree_node'
11
- require 'ecoportal/api/graphql/model/tag_tree'
10
+ require 'ecoportal/api/graphql/model/location_node'
11
+ require 'ecoportal/api/graphql/model/location_structure'
12
12
  require 'ecoportal/api/graphql/model/account'
13
13
  require 'ecoportal/api/graphql/model/user'
14
14
  require 'ecoportal/api/graphql/model/person_member'
@@ -0,0 +1,40 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Mutation
5
+ module ContractorEntity
6
+ class Create < Ecoportal::API::GraphQL::Logic::Mutation
7
+ field_name :createContractorEntity
8
+
9
+ class_resolver :payload_class, Ecoportal::API::GraphQL::Payload::ContractorEntity::Create
10
+ class_resolver :input_class, Ecoportal::API::GraphQL::Model::ContractorEntity
11
+
12
+ private
13
+
14
+ def basic_block(&block)
15
+ payload_block = block || default_payload_block
16
+ Proc.new {
17
+ mutation(input: :CreateContractorEntityInput!) {
18
+ createContractorEntity(input: :input, &payload_block)
19
+ }
20
+ }
21
+ end
22
+
23
+ def default_payload_block
24
+ Proc.new {
25
+ clientMutationId
26
+ errors {
27
+ details
28
+ fullMessages
29
+ }
30
+ item {
31
+ ___Fragment__ContractorEntity
32
+ }
33
+ }
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,14 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Mutation
5
+ module ContractorEntity
6
+ end
7
+ end
8
+ end
9
+ end
10
+ end
11
+
12
+ require_relative 'contractor_entity/create'
13
+ # require_relative 'contractor_entity/destroy'
14
+ # require_relative 'contractor_entity/update'
@@ -0,0 +1,61 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Mutation
5
+ module LocationStructure
6
+ class ApplyCommands < Ecoportal::API::GraphQL::Logic::Mutation
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
10
+
11
+ private
12
+
13
+ def basic_block(&block)
14
+ payload_block = block || default_payload_block
15
+ Proc.new {
16
+ mutation(input: :ApplyCommandsToLocationStructureInput!) {
17
+ applyCommandsToLocationStructure(input: :input, &payload_block)
18
+ }
19
+ }
20
+ end
21
+
22
+ def default_payload_block
23
+ Proc.new {
24
+ clientMutationId
25
+ error {
26
+ message
27
+ conflictingIds
28
+ validationErrors {
29
+ error
30
+ message
31
+ }
32
+ }
33
+ results {
34
+ command {
35
+ id
36
+ state
37
+ __typename
38
+ }
39
+ ok
40
+ error {
41
+ conflictingIds
42
+ message
43
+ validationErrors {
44
+ error
45
+ message
46
+ }
47
+ }
48
+ }
49
+ structure {
50
+ nodes(includeArchived: true) {
51
+ ___Ecoportal__API__GraphQL__Fragment__LocationNode
52
+ }
53
+ }
54
+ }
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,12 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Mutation
5
+ module LocationStructure
6
+ end
7
+ end
8
+ end
9
+ end
10
+ end
11
+
12
+ require_relative 'location_structure/apply_commands'
@@ -7,4 +7,5 @@ module Ecoportal
7
7
  end
8
8
  end
9
9
 
10
- require 'ecoportal/api/graphql/mutation/create_contractor_entity'
10
+ require 'ecoportal/api/graphql/mutation/location_structure'
11
+ require 'ecoportal/api/graphql/mutation/contractor_entity'
@@ -0,0 +1,13 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Payload
5
+ module ContractorEntity
6
+ class Create < Ecoportal::API::GraphQL::Logic::Payload
7
+ class_resolver :item_class, "Ecoportal::API::GraphQL::Model::ContractorEntity"
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Payload
5
+ module ContractorEntity
6
+ class Destroy < Ecoportal::API::GraphQL::Payload::ContractorEntity::Create
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Payload
5
+ module ContractorEntity
6
+ class Update < Ecoportal::API::GraphQL::Payload::ContractorEntity::Create
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,14 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Payload
5
+ module ContractorEntity
6
+ end
7
+ end
8
+ end
9
+ end
10
+ end
11
+
12
+ require_relative 'contractor_entity/create'
13
+ require_relative 'contractor_entity/destroy'
14
+ require_relative 'contractor_entity/update'
@@ -0,0 +1,25 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Payload
5
+ module LocationStructure
6
+ class ApplyCommands < Ecoportal::API::GraphQL::Base::Model
7
+ passthrough :clientMutationId
8
+ embeds_one :structure, klass: Ecoportal::API::GraphQL::Model::LocationStructure
9
+ embeds_one :errors, klass: Ecoportal::API::GraphQL::Error::ValidationErrors, nullable: true
10
+ embeds_one :error, klass: Ecoportal::API::GraphQL::Error::LocationsError, nullable: true
11
+ embeds_many :results, read_only: true, klass: Ecoportal::API::GraphQL::Payload::LocationStructure::CommandExecutionResult
12
+
13
+ def success?
14
+ !errors?
15
+ end
16
+
17
+ def errors?
18
+ errors && !errors.empty?
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,15 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Payload
5
+ module LocationStructure
6
+ class CommandExecutionResult < Ecoportal::API::GraphQL::Base::Model
7
+ embeds_one :command, klass: Ecoportal::API::GraphQL::Payload::LocationStructure::CommandInterface
8
+ embeds_one :error, klass: Ecoportal::API::GraphQL::Error::LocationsError
9
+ passboolean :ok
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,14 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Payload
5
+ module LocationStructure
6
+ class CommandInterface < Ecoportal::API::GraphQL::Base::Model
7
+ passkey :id
8
+ passthrough :state
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Payload
5
+ module LocationStructure
6
+ end
7
+ end
8
+ end
9
+ end
10
+ end
11
+
12
+ require_relative 'location_structure/command_interface'
13
+ require_relative 'location_structure/command_execution_result'
14
+ require_relative 'location_structure/apply_commands'
@@ -7,6 +7,5 @@ module Ecoportal
7
7
  end
8
8
  end
9
9
 
10
- require 'ecoportal/api/graphql/payload/create_contractor_entity'
11
- require 'ecoportal/api/graphql/payload/update_contractor_entity'
12
- require 'ecoportal/api/graphql/payload/destroy_contractor_entity'
10
+ require 'ecoportal/api/graphql/payload/location_structure'
11
+ require 'ecoportal/api/graphql/payload/contractor_entity'
@@ -2,7 +2,7 @@ module Ecoportal
2
2
  module API
3
3
  class GraphQL
4
4
  module Query
5
- class Actions < Ecoportal::API::GraphQL::Base::QueryConnection
5
+ class Actions < Ecoportal::API::GraphQL::Logic::QueryConnection
6
6
  field_name :actions
7
7
 
8
8
  class_resolver :item_class, Ecoportal::API::GraphQL::Model::Action
@@ -2,7 +2,7 @@ module Ecoportal
2
2
  module API
3
3
  class GraphQL
4
4
  module Query
5
- class ContractorEntities < Ecoportal::API::GraphQL::Base::QueryConnection
5
+ class ContractorEntities < Ecoportal::API::GraphQL::Logic::QueryConnection
6
6
  field_name :contractorEntities
7
7
 
8
8
  class_resolver :item_class, Ecoportal::API::GraphQL::Model::ContractorEntity
@@ -2,32 +2,36 @@ module Ecoportal
2
2
  module API
3
3
  class GraphQL
4
4
  module Query
5
- class TagTree < Ecoportal::API::GraphQL::Base::Query
5
+ class LocationStructure < Ecoportal::API::GraphQL::Logic::Query
6
6
  accepted_params :id
7
- field_name :tagTree
7
+ field_name :structure
8
8
 
9
- class_resolver :item_class, Ecoportal::API::GraphQL::Model::TagTree
9
+ class_resolver :item_class, Ecoportal::API::GraphQL::Model::LocationStructure
10
10
 
11
11
  private
12
12
 
13
13
  def basic_block(&block)
14
- final_block = block || default_tree_block
14
+ final_block = block || default_query_block
15
15
  Proc.new {
16
16
  query(id: :id!) {
17
17
  currentOrganization {
18
- tagTree(id: :id, &final_block)
18
+ locations {
19
+ structure(id: :id, &final_block)
20
+ }
19
21
  }
20
22
  }
21
23
  }
22
24
  end
23
25
 
24
- def default_tree_block
26
+ def default_query_block
25
27
  Proc.new {
26
28
  id
27
29
  name
30
+ archived
31
+ weight
28
32
  visitorManagementEnabled
29
- nodes {
30
- ___Ecoportal__API__GraphQL__Fragment__TagTreeNode
33
+ nodes(includeArchived: true) {
34
+ ___Ecoportal__API__GraphQL__Fragment__LocationNode
31
35
  }
32
36
  }
33
37
  end
@@ -0,0 +1,46 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Query
5
+ class LocationStructures < Ecoportal::API::GraphQL::Logic::QueryArray
6
+ accepted_params :includeArchived, :includeUnpublished
7
+ field_name :structures
8
+
9
+ class_resolver :item_class, Ecoportal::API::GraphQL::Model::LocationStructure
10
+
11
+ private
12
+
13
+ def basic_block(&block)
14
+ final_block = block || default_query_block
15
+ Proc.new {
16
+ query(includeArchived: :boolean, includeUnpublished: :boolean) {
17
+ currentOrganization {
18
+ locations {
19
+ structures(
20
+ includeArchived: :includeArchived,
21
+ includeUnpublished: :includeUnpublished,
22
+ &final_block
23
+ )
24
+ }
25
+ }
26
+ }
27
+ }
28
+ end
29
+
30
+ def default_query_block
31
+ Proc.new {
32
+ id
33
+ name
34
+ archived
35
+ weight
36
+ visitorManagementEnabled
37
+ nodes(includeArchived: true) {
38
+ ___Ecoportal__API__GraphQL__Fragment__LocationNode
39
+ }
40
+ }
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -7,7 +7,7 @@ module Ecoportal
7
7
  end
8
8
  end
9
9
 
10
- require 'ecoportal/api/graphql/query/tag_tree'
11
- require 'ecoportal/api/graphql/query/tag_trees'
10
+ require 'ecoportal/api/graphql/query/location_structure'
11
+ require 'ecoportal/api/graphql/query/location_structures'
12
12
  require 'ecoportal/api/graphql/query/actions'
13
13
  require 'ecoportal/api/graphql/query/contractor_entities'
@@ -30,12 +30,16 @@ module Ecoportal
30
30
  createContractorEntityMutation.query(input: input, &block)
31
31
  end
32
32
 
33
+ # Gives a builder to use different options to modify a reporting structure
34
+ def locationStructure
35
+ Ecoportal::API::GraphQL::Builder::LocationStructure.new(client)
36
+ end
37
+
33
38
  private
34
39
 
35
40
  def createContractorEntityMutation
36
- Ecoportal::API::GraphQL::Mutation::CreateContractorEntity.new(client)
41
+ Ecoportal::API::GraphQL::Mutation::ContractorEntity::Create.new(client)
37
42
  end
38
-
39
43
  end
40
44
  end
41
45
  end
@@ -43,9 +47,12 @@ end
43
47
  require 'ecoportal/api/graphql/helpers'
44
48
  require 'ecoportal/api/graphql/base'
45
49
  require 'ecoportal/api/graphql/model'
50
+ require 'ecoportal/api/graphql/error'
51
+ require 'ecoportal/api/graphql/logic'
46
52
  require 'ecoportal/api/graphql/connection'
47
53
  require 'ecoportal/api/graphql/payload'
48
54
  require 'ecoportal/api/graphql/input'
49
55
  require 'ecoportal/api/graphql/fragment'
50
56
  require 'ecoportal/api/graphql/query'
51
57
  require 'ecoportal/api/graphql/mutation'
58
+ require 'ecoportal/api/graphql/builder'
@@ -1,5 +1,5 @@
1
1
  module Ecoportal
2
2
  module API
3
- GRAPQL_VERSION = "0.1.11"
3
+ GRAPQL_VERSION = "0.2.1"
4
4
  end
5
5
  end
@@ -0,0 +1,11 @@
1
+ require_relative 'local_libs'
2
+
3
+ STRUCT_ID = "592642a4ae0c6a00236b110d" # mini test
4
+ # STRUCT_ID = "626745bcba616a001f7e5011" # wcc
5
+
6
+
7
+ api = Ecoportal::API::GraphQL.new
8
+ api.currentOrganization.LocationStructure(id: STRUCT_ID).tap do |tree|
9
+ puts "'#{tree.name}' Structure (#{tree.id})"
10
+ pp tree.treeify
11
+ end