ecoportal-api-graphql 0.3.7 → 0.3.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -1
  3. data/lib/ecoportal/api/common/graphql/query_integration.rb +2 -2
  4. data/lib/ecoportal/api/graphql/base/action.rb +8 -7
  5. data/lib/ecoportal/api/graphql/base/file_attachment.rb +1 -1
  6. data/lib/ecoportal/api/graphql/base/location_classification_type.rb +13 -0
  7. data/lib/ecoportal/api/graphql/base/location_node.rb +6 -1
  8. data/lib/ecoportal/api/graphql/base/location_structure.rb +2 -2
  9. data/lib/ecoportal/api/graphql/base.rb +1 -0
  10. data/lib/ecoportal/api/graphql/builder/action.rb +25 -0
  11. data/lib/ecoportal/api/graphql/builder.rb +1 -0
  12. data/lib/ecoportal/api/graphql/fragment/location_node.rb +5 -0
  13. data/lib/ecoportal/api/graphql/fragment.rb +11 -2
  14. data/lib/ecoportal/api/graphql/helpers/locations_tree.rb +12 -5
  15. data/lib/ecoportal/api/graphql/input/action/archive.rb +15 -0
  16. data/lib/ecoportal/api/graphql/input/action.rb +12 -0
  17. data/lib/ecoportal/api/graphql/input.rb +1 -0
  18. data/lib/ecoportal/api/graphql/logic/base_query.rb +96 -0
  19. data/lib/ecoportal/api/graphql/logic/mutation.rb +1 -49
  20. data/lib/ecoportal/api/graphql/logic/query.rb +1 -85
  21. data/lib/ecoportal/api/graphql/logic.rb +1 -0
  22. data/lib/ecoportal/api/graphql/model/action.rb +8 -9
  23. data/lib/ecoportal/api/graphql/model/location_node.rb +1 -0
  24. data/lib/ecoportal/api/graphql/model/location_structure.rb +2 -1
  25. data/lib/ecoportal/api/graphql/model/organization.rb +1 -0
  26. data/lib/ecoportal/api/graphql/mutation/action/archive.rb +41 -0
  27. data/lib/ecoportal/api/graphql/mutation/action.rb +12 -0
  28. data/lib/ecoportal/api/graphql/mutation.rb +1 -0
  29. data/lib/ecoportal/api/graphql/payload/action/archive.rb +13 -0
  30. data/lib/ecoportal/api/graphql/payload/action.rb +12 -0
  31. data/lib/ecoportal/api/graphql/payload.rb +1 -0
  32. data/lib/ecoportal/api/graphql/query/location_structure.rb +4 -0
  33. data/lib/ecoportal/api/graphql/query/location_structures.rb +3 -0
  34. data/lib/ecoportal/api/graphql.rb +5 -0
  35. data/lib/ecoportal/api/graphql_version.rb +1 -1
  36. metadata +11 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bd7ef3abb802c44e3a6b9d2f278252c605fd64003d01f6f1860c538b54c91242
4
- data.tar.gz: ac55ed853e4c31b4b4c4e8fc6402cca4fa11c25db4426e68d3083191fbaee84a
3
+ metadata.gz: 954a7b6f24cb89c28f8a6b02503353e9bc9453e07ca862a3862a9b2c371c9f07
4
+ data.tar.gz: 6ef1faafa1dc3d93752c4c241d362266c7314a2db1ea3ab03b7aad8f81fef4d7
5
5
  SHA512:
6
- metadata.gz: 3a0e972ae3de8ac79493f9a3f232eea0ce71c76b988f3364b5b24271b42e04de897416abe57d179f2ff348b9a9c24c85de717c7c0a7d695c0a1c530bfca1dd58
7
- data.tar.gz: edf46381032eb29602deda89fe1aa41748c5c34e926f6711a08a174e3985cdad763c1c97685fe281e54fbf9850093c71e295fd244a3f56f051a01574fe9ad9ab
6
+ metadata.gz: a22aad41024397365cccf44321c72bfdf702e56729691b5d7e4a7169e076c1b1ed11ab5c14f0e379fff65d35ff35220c34d2238db5ec47ad01a4f7c553767901
7
+ data.tar.gz: afd2b3bbeabcafcba32ad6769fa5551c463689e0a5e0d9d0f34b3684eca5732f300c7300b935c70e7e490e2b960b6dd848e87cf3b1f9bf27058e723fa52de9eb
data/CHANGELOG.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
- ## [0.3.8] - 2023-04-xx
4
+ ## [0.3.9] - 2023-06-xx
5
5
 
6
6
  ### Added
7
7
  ### Changed
@@ -13,6 +13,16 @@ All notable changes to this project will be documented in this file.
13
13
  - Analyse how to "DSL" currentOrganization.action.activities
14
14
  - review `path` tracking
15
15
 
16
+ ## [0.3.8] - 2023-07-xx
17
+
18
+ ### Added
19
+ - Integration for archiving actions.
20
+ - `LocationNodeInterface` -> support for `classifications`
21
+ - `Treeify` to dump more data per node (classifications)
22
+
23
+ ### Fixed
24
+ - Silenced waning messages when redefining `Fragment`s
25
+
16
26
  ## [0.3.7] - 2023-05-23
17
27
 
18
28
  ### Fixed
@@ -28,8 +28,8 @@ module Ecoportal
28
28
  define_method(class_method) do
29
29
  final_path = path + [subpath].flatten.compact
30
30
  resolve_class(query_klass).tap do |klass|
31
- unless klass <= Ecoportal::API::GraphQL::Logic::Query
32
- raise "Expected query_klass to be of type Ecoportal::API::GraphQL::Logic::Query. Given: #{klass}"
31
+ unless klass <= Ecoportal::API::GraphQL::Logic::BaseQuery
32
+ raise "Expected query_klass to be of type Ecoportal::API::GraphQL::Logic::BaseQuery. Given: #{klass}"
33
33
  end
34
34
  end.new(client, base_path: final_path)
35
35
  end
@@ -22,13 +22,14 @@ module Ecoportal
22
22
  passthrough :completerId
23
23
 
24
24
  passthrough :timeZone
25
- embeds_one :dueDate, klass: GraphQL::Base::DateTime
26
- embeds_one :reminderDate, klass: GraphQL::Base::DateTime
27
- embeds_one :createdAt, klass: GraphQL::Base::DateTime
28
- embeds_one :updatedAt, klass: GraphQL::Base::DateTime
29
- embeds_one :completedAt, klass: GraphQL::Base::DateTime
30
- embeds_one :openededAt, klass: GraphQL::Base::DateTime
31
- embeds_one :closedAt, klass: GraphQL::Base::DateTime
25
+ embeds_one :dueDate, klass: Base::DateTime
26
+ embeds_one :reminderDate, klass: Base::DateTime
27
+ embeds_one :createdAt, klass: Base::DateTime
28
+ embeds_one :updatedAt, klass: Base::DateTime
29
+ embeds_one :completedAt, klass: Base::DateTime
30
+ embeds_one :openededAt, klass: Base::DateTime
31
+ embeds_one :closedAt, klass: Base::DateTime
32
+ embeds_one :dueOrClosedDate, klass: Base::DateTime
32
33
  end
33
34
  end
34
35
  end
@@ -7,7 +7,7 @@ module Ecoportal
7
7
  passthrough :attachmentFileSize, :attachmentFileName, :attachmentContentType
8
8
  passthrough :urlType, :activeName
9
9
  passthrough :userId, :userName
10
- embeds_one :attachmentUpdatedAt, klass: GraphQL::Base::DateTime
10
+ embeds_one :attachmentUpdatedAt, klass: Base::DateTime
11
11
  end
12
12
  end
13
13
  end
@@ -0,0 +1,13 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Base
5
+ class LocationClassificationType < Ecoportal::API::GraphQL::Base::Model
6
+ passkey :id
7
+ passthrough :name
8
+ passboolean :active
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -4,11 +4,16 @@ module Ecoportal
4
4
  module Base
5
5
  class LocationNode < Ecoportal::API::GraphQL::Base::Model
6
6
  passkey :id
7
- passthrough :name, :parent, :parentId
7
+ passthrough :name
8
8
  passthrough :weight
9
9
  embeds_one :parent, klass: Base::LocationNode, nullable: true
10
10
  passboolean :archived
11
11
  passthrough :archivedToken
12
+ embeds_many :classifications, klass: Base::LocationClassificationType
13
+
14
+ def parentId
15
+ parent&.id
16
+ end
12
17
  end
13
18
  end
14
19
  end
@@ -8,8 +8,8 @@ module Ecoportal
8
8
  passkey :id
9
9
  passthrough :name, :weight
10
10
  passboolean :archived, :published, :visitorManagementEnabled
11
- embeds_many :nodes, klass: Ecoportal::API::GraphQL::Base::LocationNode, order_key: :weight
12
- passthrough :draft
11
+ embeds_one :updatedAt, klass: Base::DateTime
12
+ embeds_many :nodes, klass: Base::LocationNode, order_key: :weight
13
13
 
14
14
  def treeify
15
15
  self.class.treeify(nodes)
@@ -10,6 +10,7 @@ end
10
10
  require 'ecoportal/api/graphql/base/model'
11
11
  require 'ecoportal/api/graphql/base/date_time'
12
12
  require 'ecoportal/api/graphql/base/page_info'
13
+ require 'ecoportal/api/graphql/base/location_classification_type'
13
14
  require 'ecoportal/api/graphql/base/location_node'
14
15
  require 'ecoportal/api/graphql/base/location_structure'
15
16
  require 'ecoportal/api/graphql/base/person_member'
@@ -0,0 +1,25 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Builder
5
+ class Action
6
+ attr_reader :client
7
+
8
+ def initialize(client)
9
+ @client = client
10
+ end
11
+
12
+ def archive(**kargs, &block)
13
+ archiveMutation.query(**kargs, &block)
14
+ end
15
+
16
+ private
17
+
18
+ def archiveMutation
19
+ Ecoportal::API::GraphQL::Mutation::Action::Archive.new(client)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -8,3 +8,4 @@ module Ecoportal
8
8
  end
9
9
 
10
10
  require 'ecoportal/api/graphql/builder/location_structure'
11
+ require 'ecoportal/api/graphql/builder/action'
@@ -13,6 +13,11 @@ module Ecoportal
13
13
  id
14
14
  name
15
15
  }
16
+ classifications {
17
+ active
18
+ id
19
+ name
20
+ }
16
21
  }
17
22
  GRAPHQL
18
23
  end
@@ -29,13 +29,22 @@ module Ecoportal
29
29
  def define(sym, heredoc, namespace: ::Fragment)
30
30
  namespace.send(:remove_const, sym) if namespace.const_defined?(sym)
31
31
  client.parse(heredoc).tap do |fragment|
32
- namespace.const_set(sym, fragment)
33
- ::Fragment.const_set(sym, fragment) unless namespace == ::Fragment
32
+ without_warnings do
33
+ namespace.const_set(sym, fragment)
34
+ ::Fragment.const_set(sym, fragment) unless namespace == ::Fragment
35
+ end
34
36
  end
35
37
  end
36
38
 
37
39
  private
38
40
 
41
+ def without_warnings
42
+ original_verbose, $VERBOSE = $VERBOSE, nil
43
+ yield if block_given?
44
+ ensure
45
+ $VERBOSE = original_verbose
46
+ end
47
+
39
48
  def parse
40
49
  fragments = self.class.fragments.each_with_object({}) do |(sym, heredoc), out|
41
50
  out[sym] = define(sym, heredoc, namespace: self.class)
@@ -16,12 +16,19 @@ module Ecoportal
16
16
 
17
17
  def get_children(node_id, parents)
18
18
  (parents[node_id&.upcase] ||= []).each_with_object([]) do |child, results|
19
+ class_types = child.classifications || []
20
+ class_ids = class_types.map(&:id)
21
+ class_names = class_types.map(&:name)
22
+
19
23
  results << {
20
- "id" => child.id,
21
- "name" => child.name,
22
- "weight" => child.weight,
23
- "archived" => child.archived,
24
- "archived_token" => child.archivedToken,
24
+ "id" => child.id,
25
+ "name" => child.name,
26
+ "weight" => child.weight,
27
+ "parent_id" => node_id,
28
+ "archived" => child.archived,
29
+ "archived_token" => child.archivedToken,
30
+ "classifications" => class_ids,
31
+ "classification_names" => class_names,
25
32
  "nodes" => get_children(child.id, parents).compact
26
33
  }
27
34
  end
@@ -0,0 +1,15 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Input
5
+ module Action
6
+ class Archive < Ecoportal::API::GraphQL::Base::Model
7
+ passkey :id
8
+ passthrough :clientMutationId
9
+ passthrough :updateMode
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,12 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Input
5
+ module Action
6
+ end
7
+ end
8
+ end
9
+ end
10
+ end
11
+
12
+ require_relative 'action/archive'
@@ -13,3 +13,4 @@ require 'ecoportal/api/graphql/input/search_sorter'
13
13
  require 'ecoportal/api/graphql/input/search'
14
14
  require 'ecoportal/api/graphql/input/location_structure'
15
15
  require 'ecoportal/api/graphql/input/contractor_entity'
16
+ require 'ecoportal/api/graphql/input/action'
@@ -0,0 +1,96 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Logic
5
+ class BaseQuery
6
+ include Ecoportal::API::Common::GraphQL::ClassHelpers
7
+ inheritable_attrs :accepted_params
8
+
9
+ class << self
10
+ def accepted_params(*keys)
11
+ @accepted_params ||= []
12
+ return @accepted_params if keys.empty?
13
+ @accepted_params.push(*keys).tap {|ks| ks.uniq!}
14
+ end
15
+
16
+ def clear_accepted_params
17
+ @accepted_params = []
18
+ end
19
+
20
+ def slice_params(kargs)
21
+ kargs.slice(*accepted_params)
22
+ end
23
+
24
+ # Used to obtain the full `path` in the GraphQL query by using `base_path`
25
+ # @note it is meant for reusability of queries from different end-points
26
+ def field_name(str = nil)
27
+ return @field_name unless str
28
+ @field_name = nil
29
+ @field_name = str.to_s if str
30
+ end
31
+ end
32
+
33
+ attr_reader :client
34
+ attr_reader :base_path
35
+
36
+ def initialize(client, path: nil, base_path: [])
37
+ @path = path
38
+ @base_path = base_path
39
+ @client = client
40
+ end
41
+
42
+ # Resolves the `path` by using `path` or `base_path` + `class.field_name`.
43
+ def path(field_name = self.class.field_name)
44
+ result = @path
45
+ result ||= default_path if self.respond_to?(:default_path, true)
46
+ result ||= (base_path + [field_name]) if base_path && field_name
47
+ result
48
+ end
49
+
50
+ # Query rely that manages the different blocks.
51
+ # @return [Class] an object of `response_class` with the results hanging from `path`.
52
+ def query(path: self.path, **kargs, &block)
53
+ graphql_query(path: path, **kargs, &basic_block(&block))
54
+ end
55
+
56
+ def response_class
57
+ raise "You should override this method in #{self.class}"
58
+ end
59
+
60
+ def access_point(path = [])
61
+ path.last
62
+ end
63
+
64
+ private
65
+
66
+ def basic_block
67
+ raise "This method should be implemented in the child class #{self.class}"
68
+ end
69
+
70
+ def graphql_query(path: self.path, **kargs, &block)
71
+ query_params = self.class.slice_params(kargs)
72
+ request(*path) do
73
+ client.query(query_params, &block)
74
+ end
75
+ rescue Faraday::ParsingError, Graphlient::Errors::GraphQLError => e
76
+ puts "Internal Error with these params:"
77
+ pp kargs
78
+ pp block
79
+ raise
80
+ end
81
+
82
+ def request(*path)
83
+ response = yield
84
+ wrap_response(response, path)
85
+ end
86
+
87
+ def wrap_response(response, path = [])
88
+ raise "Complete failure on request. Path: #{path}\n#{response.to_h.pretty_inspect}" unless res = response.to_h.dig(*path.dup.unshift("data"))
89
+ data = Ecoportal::API::Common::GraphQL::HashHelpers.deep_dup(res)
90
+ response_class.new(data)
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
@@ -2,7 +2,7 @@ module Ecoportal
2
2
  module API
3
3
  class GraphQL
4
4
  module Logic
5
- class Mutation
5
+ class Mutation < Ecoportal::API::GraphQL::Logic::BaseQuery
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."
@@ -14,38 +14,9 @@ module Ecoportal
14
14
  end
15
15
  end
16
16
 
17
- include Ecoportal::API::Common::GraphQL::ClassHelpers
18
-
19
- class << self
20
- # Used to obtain the full `path` in the GraphQL query by using `base_path`
21
- # @note it is meant for reusability of queries from different end-points
22
- def field_name(str = nil)
23
- return @field_name unless str
24
- @field_name = nil
25
- @field_name = str.to_s if str
26
- end
27
- end
28
-
29
17
  class_resolver :payload_class, GenericPayload
30
18
  class_resolver :input_class, GenericInput
31
19
 
32
- attr_reader :client
33
- attr_reader :base_path
34
-
35
- def initialize(client, path: nil, base_path: [])
36
- @path = path
37
- @base_path = base_path
38
- @client = client
39
- end
40
-
41
- # Resolves the `path` by using `path` or `base_path` + `class.field_name`.
42
- def path(field_name = self.class.field_name)
43
- result = @path
44
- result ||= default_path if self.respond_to?(:default_path, true)
45
- result ||= (base_path + [field_name]) if base_path && field_name
46
- result
47
- end
48
-
49
20
  # Query rely that manages the different blocks.
50
21
  # @return [Class] an object of `response_class` with the results hanving from `path`.
51
22
  def query(input:, path: self.path, &block)
@@ -62,16 +33,8 @@ module Ecoportal
62
33
  payload_class
63
34
  end
64
35
 
65
- def access_point(path = [])
66
- path.last
67
- end
68
-
69
36
  private
70
37
 
71
- def basic_block(&block)
72
- raise "This method should be implemented in the child class #{self.class}"
73
- end
74
-
75
38
  def as_input(value)
76
39
  case value
77
40
  when input_class
@@ -89,17 +52,6 @@ module Ecoportal
89
52
  raise ArgumentError.new("Expecting Hash, GraphQL::Base::Model or Enumerable. Unsupported type '#{value.class}'.")
90
53
  end
91
54
  end
92
-
93
- def request(*path)
94
- response = yield
95
- wrap_response(response, path)
96
- end
97
-
98
- def wrap_response(response, path = [])
99
- raise "Complete failure on request. Path: #{path}" unless res = response.to_h.dig(*path.dup.unshift("data"))
100
- data = Ecoportal::API::Common::GraphQL::HashHelpers.deep_dup(res)
101
- response_class.new(data)
102
- end
103
55
  end
104
56
  end
105
57
  end
@@ -2,101 +2,17 @@ module Ecoportal
2
2
  module API
3
3
  class GraphQL
4
4
  module Logic
5
- class Query
5
+ class Query < Ecoportal::API::GraphQL::Logic::BaseQuery
6
6
  class GenericItem
7
7
  def initialize(*args, **kargs)
8
8
  raise "Missuse error. You should define a item_class for a class that inherits from Query class."
9
9
  end
10
10
  end
11
-
12
- include Ecoportal::API::Common::GraphQL::ClassHelpers
13
-
14
- inheritable_attrs :accepted_params
15
-
16
- class << self
17
- def accepted_params(*keys)
18
- @accepted_params ||= []
19
- return @accepted_params if keys.empty?
20
- @accepted_params.push(*keys).tap {|ks| ks.uniq!}
21
- end
22
-
23
- def clear_accepted_params
24
- @accepted_params = []
25
- end
26
-
27
- def slice_params(kargs)
28
- kargs.slice(*accepted_params)
29
- end
30
-
31
- # Used to obtain the full `path` in the GraphQL query by using `base_path`
32
- # @note it is meant for reusability of queries from different end-points
33
- def field_name(str = nil)
34
- return @field_name unless str
35
- @field_name = nil
36
- @field_name = str.to_s if str
37
- end
38
- end
39
-
40
11
  class_resolver :item_class, GenericItem
41
- attr_reader :client
42
- attr_reader :base_path
43
-
44
- def initialize(client, path: nil, base_path: nil)
45
- @path = path
46
- @base_path = base_path
47
- @client = client
48
- end
49
-
50
- # Resolves the `path` by using `path` or `base_path` + `class.field_name`.
51
- def path(field_name = self.class.field_name)
52
- result = @path
53
- result ||= default_path if self.respond_to?(:default_path, true)
54
- result ||= (base_path + [field_name]) if base_path && field_name
55
- result
56
- end
57
-
58
- # Query rely that manages the different blocks.
59
- # @return [Class] an object of `response_class` with the results hanging from `path`.
60
- def query(path: self.path, **kargs, &block)
61
- graphql_query(path: path, **kargs, &basic_block(&block))
62
- end
63
12
 
64
13
  def response_class
65
14
  item_class
66
15
  end
67
-
68
- def access_point(path = [])
69
- path.last
70
- end
71
-
72
- private
73
-
74
- def basic_block
75
- raise "This method should be implemented in the child class #{self.class}"
76
- end
77
-
78
- def graphql_query(path: self.path, **kargs, &block)
79
- query_params = self.class.slice_params(kargs)
80
- request(*path) do
81
- client.query(query_params, &block)
82
- end
83
- rescue Faraday::ParsingError, Graphlient::Errors::GraphQLError => e
84
- puts "Internal Error with these params:"
85
- pp kargs
86
- pp block
87
- raise
88
- end
89
-
90
- def request(*path)
91
- response = yield
92
- wrap_response(response, path)
93
- end
94
-
95
- def wrap_response(response, path = [])
96
- raise "Complete failure on request. Path: #{path}" unless res = response.to_h.dig(*path.dup.unshift("data"))
97
- data = Ecoportal::API::Common::GraphQL::HashHelpers.deep_dup(res)
98
- response_class.new(data)
99
- end
100
16
  end
101
17
  end
102
18
  end
@@ -7,6 +7,7 @@ module Ecoportal
7
7
  end
8
8
  end
9
9
 
10
+ require 'ecoportal/api/graphql/logic/base_query'
10
11
  require 'ecoportal/api/graphql/logic/query'
11
12
  require 'ecoportal/api/graphql/logic/mutation'
12
13
  require 'ecoportal/api/graphql/logic/connection'
@@ -4,15 +4,14 @@ module Ecoportal
4
4
  module Model
5
5
  class Action < Ecoportal::API::GraphQL::Base::Action
6
6
  embeds_one :actionCategory, klass: GraphQL::Base::ActionCategory
7
- embeds_one :dueOrClosedDate, klass: GraphQL::Base::DateTime
8
- embeds_many :assignedTo, klass: GraphQL::Model::PersonMember
9
- embeds_one :creator, klass: GraphQL::Model::PersonMember
10
- embeds_one :creatorUser, klass: GraphQL::Model::User
11
- embeds_one :updater, klass: GraphQL::Model::PersonMember
12
- embeds_one :updaterUser, klass: GraphQL::Model::User
13
- embeds_one :completer, klass: GraphQL::Model::PersonMember
14
- embeds_many :fileContainers, klass: GraphQL::Model::FileContainer
15
- embeds_many :linkedResources, klass: GraphQL::Model::Resource
7
+ embeds_many :assignedTo, klass: Model::PersonMember
8
+ embeds_one :creator, klass: Model::PersonMember
9
+ embeds_one :creatorUser, klass: Model::User
10
+ embeds_one :updater, klass: Model::PersonMember
11
+ embeds_one :updaterUser, klass: Model::User
12
+ embeds_one :completer, klass: Model::PersonMember
13
+ embeds_many :fileContainers, klass: Model::FileContainer
14
+ embeds_many :linkedResources, klass: Model::Resource
16
15
  #embeds_many :activities, klass: GraphQL::Activity::Action
17
16
  end
18
17
  end
@@ -4,6 +4,7 @@ module Ecoportal
4
4
  module Model
5
5
  class LocationNode < Ecoportal::API::GraphQL::Base::LocationNode
6
6
  embeds_one :parent, klass: Model::LocationNode, nullable: true
7
+ embeds_many :ancestors, klass: Model::LocationNode
7
8
  end
8
9
  end
9
10
  end
@@ -3,7 +3,8 @@ module Ecoportal
3
3
  class GraphQL
4
4
  module Model
5
5
  class LocationStructure < Ecoportal::API::GraphQL::Base::LocationStructure
6
- embeds_many :nodes, klass: Ecoportal::API::GraphQL::Model::LocationNode, order_key: :weight
6
+ embeds_many :nodes, klass: Model::LocationNode, order_key: :weight
7
+ embeds_one :lastUpdatedBy, klass: "Ecoportal::API::GraphQL::Model::User"
7
8
  end
8
9
  end
9
10
  end
@@ -17,6 +17,7 @@ module Ecoportal
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"
20
+ query :archiveAction, query_klass: "Ecoportal::API::GraphQL::Mutation::Action::Archive"
20
21
  #action, actionsByPage, actionsCounter
21
22
  #actionCategories
22
23
 
@@ -0,0 +1,41 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Mutation
5
+ module Action
6
+ class Archive < Ecoportal::API::GraphQL::Logic::Mutation
7
+ field_name :archiveAction
8
+ accepted_params :id
9
+
10
+ class_resolver :payload_class, Ecoportal::API::GraphQL::Payload::Action::Archive
11
+ class_resolver :input_class, Ecoportal::API::GraphQL::Input::Action::Archive
12
+
13
+ private
14
+
15
+ def basic_block(&block)
16
+ payload_block = block || default_payload_block
17
+ Proc.new {
18
+ mutation(input: :ArchiveActionInput!) {
19
+ archiveAction(input: :input, &payload_block)
20
+ }
21
+ }
22
+ end
23
+
24
+ def default_payload_block
25
+ Proc.new {
26
+ clientMutationId
27
+ errors {
28
+ details
29
+ fullMessages
30
+ }
31
+ item {
32
+ ___Fragment__Action
33
+ }
34
+ }
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,12 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Mutation
5
+ module Action
6
+ end
7
+ end
8
+ end
9
+ end
10
+ end
11
+
12
+ require_relative 'action/archive'
@@ -9,3 +9,4 @@ end
9
9
 
10
10
  require 'ecoportal/api/graphql/mutation/location_structure'
11
11
  require 'ecoportal/api/graphql/mutation/contractor_entity'
12
+ require 'ecoportal/api/graphql/mutation/action'
@@ -0,0 +1,13 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Payload
5
+ module Action
6
+ class Archive < Ecoportal::API::GraphQL::Logic::Payload
7
+ class_resolver :item_class, "Ecoportal::API::GraphQL::Model::Action"
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 Action
6
+ end
7
+ end
8
+ end
9
+ end
10
+ end
11
+
12
+ require_relative 'action/archive'
@@ -9,3 +9,4 @@ end
9
9
 
10
10
  require 'ecoportal/api/graphql/payload/location_structure'
11
11
  require 'ecoportal/api/graphql/payload/contractor_entity'
12
+ require 'ecoportal/api/graphql/payload/action'
@@ -23,12 +23,16 @@ module Ecoportal
23
23
  }
24
24
  end
25
25
 
26
+ # At the moment it always retrieves archived nodes!!
27
+ # @note this is on purpose, as via API
28
+ # there isn't much sense in not including archived nodes.
26
29
  def default_query_block
27
30
  Proc.new {
28
31
  id
29
32
  name
30
33
  archived
31
34
  weight
35
+ updatedAt
32
36
  visitorManagementEnabled
33
37
  nodes(includeArchived: true) {
34
38
  ___Ecoportal__API__GraphQL__Fragment__LocationNode
@@ -27,6 +27,9 @@ module Ecoportal
27
27
  }
28
28
  end
29
29
 
30
+ # At the moment it always retrieves archived nodes!!
31
+ # @note this is on purpose, as via API
32
+ # there isn't much sense in not including archived nodes.
30
33
  def default_query_block
31
34
  Proc.new {
32
35
  id
@@ -36,6 +36,11 @@ module Ecoportal
36
36
  Ecoportal::API::GraphQL::Builder::LocationStructure.new(client)
37
37
  end
38
38
 
39
+ # Gives a builder to use different options to play with action
40
+ def action
41
+ Ecoportal::API::GraphQL::Builder::Action.new(client)
42
+ end
43
+
39
44
  private
40
45
 
41
46
  def createContractorEntityMutation
@@ -1,5 +1,5 @@
1
1
  module Ecoportal
2
2
  module API
3
- GRAPQL_VERSION = "0.3.7"
3
+ GRAPQL_VERSION = "0.3.8"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecoportal-api-graphql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 0.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-23 00:00:00.000000000 Z
11
+ date: 2023-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -205,6 +205,7 @@ files:
205
205
  - lib/ecoportal/api/graphql/base/field.rb
206
206
  - lib/ecoportal/api/graphql/base/file_attachment.rb
207
207
  - lib/ecoportal/api/graphql/base/file_container.rb
208
+ - lib/ecoportal/api/graphql/base/location_classification_type.rb
208
209
  - lib/ecoportal/api/graphql/base/location_node.rb
209
210
  - lib/ecoportal/api/graphql/base/location_structure.rb
210
211
  - lib/ecoportal/api/graphql/base/model.rb
@@ -214,6 +215,7 @@ files:
214
215
  - lib/ecoportal/api/graphql/base/person_member.rb
215
216
  - lib/ecoportal/api/graphql/base/resource.rb
216
217
  - lib/ecoportal/api/graphql/builder.rb
218
+ - lib/ecoportal/api/graphql/builder/action.rb
217
219
  - lib/ecoportal/api/graphql/builder/location_structure.rb
218
220
  - lib/ecoportal/api/graphql/connection.rb
219
221
  - lib/ecoportal/api/graphql/connection/action.rb
@@ -231,6 +233,8 @@ files:
231
233
  - lib/ecoportal/api/graphql/helpers.rb
232
234
  - lib/ecoportal/api/graphql/helpers/locations_tree.rb
233
235
  - lib/ecoportal/api/graphql/input.rb
236
+ - lib/ecoportal/api/graphql/input/action.rb
237
+ - lib/ecoportal/api/graphql/input/action/archive.rb
234
238
  - lib/ecoportal/api/graphql/input/contractor_entity.rb
235
239
  - lib/ecoportal/api/graphql/input/contractor_entity/create.rb
236
240
  - lib/ecoportal/api/graphql/input/contractor_entity/destroy.rb
@@ -250,6 +254,7 @@ files:
250
254
  - lib/ecoportal/api/graphql/input/search_filter.rb
251
255
  - lib/ecoportal/api/graphql/input/search_sorter.rb
252
256
  - lib/ecoportal/api/graphql/logic.rb
257
+ - lib/ecoportal/api/graphql/logic/base_query.rb
253
258
  - lib/ecoportal/api/graphql/logic/connection.rb
254
259
  - lib/ecoportal/api/graphql/logic/mutation.rb
255
260
  - lib/ecoportal/api/graphql/logic/payload.rb
@@ -271,11 +276,15 @@ files:
271
276
  - lib/ecoportal/api/graphql/model/resource.rb
272
277
  - lib/ecoportal/api/graphql/model/user.rb
273
278
  - lib/ecoportal/api/graphql/mutation.rb
279
+ - lib/ecoportal/api/graphql/mutation/action.rb
280
+ - lib/ecoportal/api/graphql/mutation/action/archive.rb
274
281
  - lib/ecoportal/api/graphql/mutation/contractor_entity.rb
275
282
  - lib/ecoportal/api/graphql/mutation/contractor_entity/create.rb
276
283
  - lib/ecoportal/api/graphql/mutation/location_structure.rb
277
284
  - lib/ecoportal/api/graphql/mutation/location_structure/apply_commands.rb
278
285
  - lib/ecoportal/api/graphql/payload.rb
286
+ - lib/ecoportal/api/graphql/payload/action.rb
287
+ - lib/ecoportal/api/graphql/payload/action/archive.rb
279
288
  - lib/ecoportal/api/graphql/payload/contractor_entity.rb
280
289
  - lib/ecoportal/api/graphql/payload/contractor_entity/create.rb
281
290
  - lib/ecoportal/api/graphql/payload/contractor_entity/destroy.rb