ecoportal-api-graphql 0.3.7 → 0.3.9
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -5
- data/lib/ecoportal/api/common/graphql/query_integration.rb +2 -2
- data/lib/ecoportal/api/graphql/base/action.rb +8 -7
- data/lib/ecoportal/api/graphql/base/file_attachment.rb +1 -1
- data/lib/ecoportal/api/graphql/base/location_classification_type.rb +13 -0
- data/lib/ecoportal/api/graphql/base/location_node.rb +6 -1
- data/lib/ecoportal/api/graphql/base/location_structure.rb +2 -2
- data/lib/ecoportal/api/graphql/base.rb +1 -0
- data/lib/ecoportal/api/graphql/builder/action.rb +25 -0
- data/lib/ecoportal/api/graphql/builder.rb +1 -0
- data/lib/ecoportal/api/graphql/fragment/location_node.rb +5 -0
- data/lib/ecoportal/api/graphql/fragment.rb +11 -2
- data/lib/ecoportal/api/graphql/helpers/locations_tree.rb +12 -5
- data/lib/ecoportal/api/graphql/input/action/archive.rb +15 -0
- data/lib/ecoportal/api/graphql/input/action.rb +12 -0
- data/lib/ecoportal/api/graphql/input.rb +1 -0
- data/lib/ecoportal/api/graphql/logic/base_query.rb +108 -0
- data/lib/ecoportal/api/graphql/logic/mutation.rb +1 -49
- data/lib/ecoportal/api/graphql/logic/query.rb +1 -85
- data/lib/ecoportal/api/graphql/logic/query_array.rb +0 -6
- data/lib/ecoportal/api/graphql/logic.rb +1 -0
- data/lib/ecoportal/api/graphql/model/action.rb +8 -9
- data/lib/ecoportal/api/graphql/model/location_node.rb +1 -0
- data/lib/ecoportal/api/graphql/model/location_structure.rb +2 -1
- data/lib/ecoportal/api/graphql/model/organization.rb +1 -0
- data/lib/ecoportal/api/graphql/mutation/action/archive.rb +41 -0
- data/lib/ecoportal/api/graphql/mutation/action.rb +12 -0
- data/lib/ecoportal/api/graphql/mutation.rb +1 -0
- data/lib/ecoportal/api/graphql/payload/action/archive.rb +13 -0
- data/lib/ecoportal/api/graphql/payload/action.rb +12 -0
- data/lib/ecoportal/api/graphql/payload.rb +1 -0
- data/lib/ecoportal/api/graphql/query/location_structure.rb +7 -1
- data/lib/ecoportal/api/graphql/query/location_structures.rb +11 -3
- data/lib/ecoportal/api/graphql.rb +5 -0
- data/lib/ecoportal/api/graphql_version.rb +1 -1
- metadata +11 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9ee1a2e7ea100fbb03bd2c617e771dafccf7bd443ded39285f230fb68790498
|
4
|
+
data.tar.gz: 9139ed6d2a6adf21990beeb7ffea0ad9dd03a1b80ff924e50249ba904cfa979f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18c0055c77d55072ab9dfadb521e5a740fae4e79e3eed45148c248f887d5ae5ae8f85f2460e788e3529e9274859f76ae3125775a8fbee66de9daf1d4bfe0f242
|
7
|
+
data.tar.gz: 0d8bb739aa1625bf87021160523d42fd885d1537239fbefa4edff0ce0cd2142ebd9488a4411703fba4cdd109bc0be3dc7d0c01f15927f83213e5701c9575e9c6
|
data/CHANGELOG.md
CHANGED
@@ -1,11 +1,6 @@
|
|
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
|
5
|
-
|
6
|
-
### Added
|
7
|
-
### Changed
|
8
|
-
### Fixed
|
9
4
|
|
10
5
|
### ToDo
|
11
6
|
- Add update operation for `ContractorEntity`
|
@@ -13,6 +8,26 @@ All notable changes to this project will be documented in this file.
|
|
13
8
|
- Analyse how to "DSL" currentOrganization.action.activities
|
14
9
|
- review `path` tracking
|
15
10
|
|
11
|
+
|
12
|
+
## [0.3.9] - 2023-06-xx
|
13
|
+
|
14
|
+
### Added
|
15
|
+
- `Ecoportal::API::GraphQL::Logic::BaseQuery`
|
16
|
+
- Added support for **default** values.
|
17
|
+
|
18
|
+
### Changed
|
19
|
+
### Fixed
|
20
|
+
|
21
|
+
## [0.3.8] - 2023-07-18
|
22
|
+
|
23
|
+
### Added
|
24
|
+
- Integration for archiving actions.
|
25
|
+
- `LocationNodeInterface` -> support for `classifications`
|
26
|
+
- `Treeify` to dump more data per node (classifications)
|
27
|
+
|
28
|
+
### Fixed
|
29
|
+
- Silenced waning messages when redefining `Fragment`s
|
30
|
+
|
16
31
|
## [0.3.7] - 2023-05-23
|
17
32
|
|
18
33
|
### 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::
|
32
|
-
raise "Expected query_klass to be of type Ecoportal::API::GraphQL::Logic::
|
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:
|
26
|
-
embeds_one :reminderDate, klass:
|
27
|
-
embeds_one :createdAt, klass:
|
28
|
-
embeds_one :updatedAt, klass:
|
29
|
-
embeds_one :completedAt, klass:
|
30
|
-
embeds_one :openededAt, klass:
|
31
|
-
embeds_one :closedAt, klass:
|
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:
|
10
|
+
embeds_one :attachmentUpdatedAt, klass: Base::DateTime
|
11
11
|
end
|
12
12
|
end
|
13
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
|
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
|
-
|
12
|
-
|
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
|
@@ -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
|
-
|
33
|
-
|
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"
|
21
|
-
"name"
|
22
|
-
"weight"
|
23
|
-
"
|
24
|
-
"
|
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,108 @@
|
|
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, :param_defaults
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def param_defaults
|
11
|
+
@param_defaults ||= {}
|
12
|
+
end
|
13
|
+
|
14
|
+
def accepted_params(*keys, default: :unused)
|
15
|
+
@accepted_params ||= []
|
16
|
+
return @accepted_params if keys.empty?
|
17
|
+
keys.map(&:to_sym).uniq.each do |key|
|
18
|
+
@accepted_params |= [key]
|
19
|
+
param_defaults[key] = default unless default == :unused
|
20
|
+
end
|
21
|
+
|
22
|
+
@accepted_params.push(*keys).tap {|ks| ks.uniq!}
|
23
|
+
@accepted_params
|
24
|
+
end
|
25
|
+
|
26
|
+
def clear_accepted_params
|
27
|
+
@param_defaults = {}
|
28
|
+
@accepted_params = []
|
29
|
+
end
|
30
|
+
|
31
|
+
def slice_params(kargs)
|
32
|
+
kargs.slice(*accepted_params)
|
33
|
+
end
|
34
|
+
|
35
|
+
# Used to obtain the full `path` in the GraphQL query by using `base_path`
|
36
|
+
# @note it is meant for reusability of queries from different end-points
|
37
|
+
def field_name(str = nil)
|
38
|
+
return @field_name unless str
|
39
|
+
@field_name = nil
|
40
|
+
@field_name = str.to_s if str
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
attr_reader :client
|
45
|
+
attr_reader :base_path
|
46
|
+
|
47
|
+
def initialize(client, path: nil, base_path: [])
|
48
|
+
@path = path
|
49
|
+
@base_path = base_path
|
50
|
+
@client = client
|
51
|
+
end
|
52
|
+
|
53
|
+
# Resolves the `path` by using `path` or `base_path` + `class.field_name`.
|
54
|
+
def path(field_name = self.class.field_name)
|
55
|
+
result = @path
|
56
|
+
result ||= default_path if self.respond_to?(:default_path, true)
|
57
|
+
result ||= (base_path + [field_name]) if base_path && field_name
|
58
|
+
result
|
59
|
+
end
|
60
|
+
|
61
|
+
# Query rely that manages the different blocks.
|
62
|
+
# @return [Class] an object of `response_class` with the results hanging from `path`.
|
63
|
+
def query(path: self.path, **kargs, &block)
|
64
|
+
graphql_query(path: path, **kargs, &basic_block(&block))
|
65
|
+
end
|
66
|
+
|
67
|
+
def response_class
|
68
|
+
raise "You should override this method in #{self.class}"
|
69
|
+
end
|
70
|
+
|
71
|
+
def access_point(path = [])
|
72
|
+
path.last
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
def basic_block
|
78
|
+
raise "This method should be implemented in the child class #{self.class}"
|
79
|
+
end
|
80
|
+
|
81
|
+
def graphql_query(path: self.path, **kargs, &block)
|
82
|
+
default_params = self.class.param_defaults.dup
|
83
|
+
query_params = self.class.slice_params(default_params.merge(kargs))
|
84
|
+
request(*path) do
|
85
|
+
client.query(query_params, &block)
|
86
|
+
end
|
87
|
+
rescue Faraday::ParsingError, Graphlient::Errors::GraphQLError => e
|
88
|
+
puts "Internal Error with these params:"
|
89
|
+
pp kargs
|
90
|
+
pp block
|
91
|
+
raise
|
92
|
+
end
|
93
|
+
|
94
|
+
def request(*path)
|
95
|
+
response = yield
|
96
|
+
wrap_response(response, path)
|
97
|
+
end
|
98
|
+
|
99
|
+
def wrap_response(response, path = [])
|
100
|
+
raise "Complete failure on request. Path: #{path}\n#{response.to_h.pretty_inspect}" unless res = response.to_h.dig(*path.dup.unshift("data"))
|
101
|
+
data = Ecoportal::API::Common::GraphQL::HashHelpers.deep_dup(res)
|
102
|
+
response_class.new(data)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
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
|
@@ -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
|
-
|
8
|
-
|
9
|
-
embeds_one :
|
10
|
-
embeds_one :
|
11
|
-
embeds_one :
|
12
|
-
embeds_one :
|
13
|
-
|
14
|
-
embeds_many :
|
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
|
@@ -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:
|
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
|
@@ -4,6 +4,8 @@ module Ecoportal
|
|
4
4
|
module Query
|
5
5
|
class LocationStructure < Ecoportal::API::GraphQL::Logic::Query
|
6
6
|
accepted_params :id
|
7
|
+
accepted_params :includeArchivedNodes, default: true
|
8
|
+
|
7
9
|
field_name :structure
|
8
10
|
|
9
11
|
class_resolver :item_class, Ecoportal::API::GraphQL::Model::LocationStructure
|
@@ -23,14 +25,18 @@ module Ecoportal
|
|
23
25
|
}
|
24
26
|
end
|
25
27
|
|
28
|
+
# At the moment it always retrieves archived nodes!!
|
29
|
+
# @note this is on purpose, as via API
|
30
|
+
# there isn't much sense in not including archived nodes.
|
26
31
|
def default_query_block
|
27
32
|
Proc.new {
|
28
33
|
id
|
29
34
|
name
|
30
35
|
archived
|
31
36
|
weight
|
37
|
+
updatedAt
|
32
38
|
visitorManagementEnabled
|
33
|
-
nodes(includeArchived:
|
39
|
+
nodes(includeArchived: :includeArchivedNodes) {
|
34
40
|
___Ecoportal__API__GraphQL__Fragment__LocationNode
|
35
41
|
}
|
36
42
|
}
|
@@ -3,7 +3,9 @@ module Ecoportal
|
|
3
3
|
class GraphQL
|
4
4
|
module Query
|
5
5
|
class LocationStructures < Ecoportal::API::GraphQL::Logic::QueryArray
|
6
|
-
accepted_params :includeArchived, :includeUnpublished
|
6
|
+
accepted_params :includeArchived, :includeUnpublished, default: false
|
7
|
+
accepted_params :includeArchivedNodes, default: true
|
8
|
+
|
7
9
|
field_name :structures
|
8
10
|
|
9
11
|
class_resolver :item_class, Ecoportal::API::GraphQL::Model::LocationStructure
|
@@ -13,7 +15,10 @@ module Ecoportal
|
|
13
15
|
def basic_block(&block)
|
14
16
|
final_block = block || default_query_block
|
15
17
|
Proc.new {
|
16
|
-
query(includeArchived: :boolean,
|
18
|
+
query(includeArchived: :boolean,
|
19
|
+
includeUnpublished: :boolean,
|
20
|
+
includeArchivedNodes: :boolean
|
21
|
+
) {
|
17
22
|
currentOrganization {
|
18
23
|
locations {
|
19
24
|
structures(
|
@@ -27,6 +32,9 @@ module Ecoportal
|
|
27
32
|
}
|
28
33
|
end
|
29
34
|
|
35
|
+
# At the moment it always retrieves archived nodes!!
|
36
|
+
# @note this is on purpose, as via API
|
37
|
+
# there isn't much sense in not including archived nodes.
|
30
38
|
def default_query_block
|
31
39
|
Proc.new {
|
32
40
|
id
|
@@ -34,7 +42,7 @@ module Ecoportal
|
|
34
42
|
archived
|
35
43
|
weight
|
36
44
|
visitorManagementEnabled
|
37
|
-
nodes(includeArchived:
|
45
|
+
nodes(includeArchived: :includeArchivedNodes) {
|
38
46
|
___Ecoportal__API__GraphQL__Fragment__LocationNode
|
39
47
|
}
|
40
48
|
}
|
@@ -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
|
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.
|
4
|
+
version: 0.3.9
|
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-
|
11
|
+
date: 2023-08-03 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
|