ecoportal-api-graphql 0.4.2 → 0.4.4
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 +26 -2
- data/Rakefile +10 -10
- data/ecoportal-api-graphql.gemspec +22 -19
- data/lib/ecoportal/api/common/graphql/auth_service.rb +15 -15
- data/lib/ecoportal/api/common/graphql/class_helpers.rb +6 -3
- data/lib/ecoportal/api/common/graphql/client.rb +1 -1
- data/lib/ecoportal/api/common/graphql/hash_helpers.rb +60 -30
- data/lib/ecoportal/api/common/graphql/http_client.rb +15 -21
- data/lib/ecoportal/api/common/graphql/model/as_input.rb +40 -0
- data/lib/ecoportal/api/common/graphql/model/diffable/hash_diff.rb +60 -0
- data/lib/ecoportal/api/common/graphql/model/diffable.rb +32 -0
- data/lib/ecoportal/api/common/graphql/model.rb +17 -0
- data/lib/ecoportal/api/common/graphql/query_integration.rb +5 -2
- data/lib/ecoportal/api/common/graphql.rb +1 -2
- data/lib/ecoportal/api/graphql/base/action.rb +2 -0
- data/lib/ecoportal/api/graphql/base/action_category.rb +2 -0
- data/lib/ecoportal/api/graphql/base/contractor_entity.rb +2 -0
- data/lib/ecoportal/api/graphql/base/location_classification_type.rb +1 -1
- data/lib/ecoportal/api/graphql/base/location_node.rb +2 -0
- data/lib/ecoportal/api/graphql/base/location_structure.rb +1 -0
- data/lib/ecoportal/api/graphql/base/model.rb +1 -21
- data/lib/ecoportal/api/graphql/base/organization.rb +2 -0
- data/lib/ecoportal/api/graphql/base/page.rb +2 -0
- data/lib/ecoportal/api/graphql/base/person_member.rb +2 -0
- data/lib/ecoportal/api/graphql/error/locations_error.rb +2 -0
- data/lib/ecoportal/api/graphql/error/locations_validation_error.rb +2 -0
- data/lib/ecoportal/api/graphql/error/validation_errors.rb +1 -0
- data/lib/ecoportal/api/graphql/fragment.rb +2 -0
- data/lib/ecoportal/api/graphql/helpers/locations_tree.rb +10 -10
- data/lib/ecoportal/api/graphql/logic/base_query.rb +5 -2
- data/lib/ecoportal/api/graphql/logic/mutation.rb +3 -5
- data/lib/ecoportal/api/graphql/logic/payload.rb +2 -0
- data/lib/ecoportal/api/graphql/logic/query.rb +4 -1
- data/lib/ecoportal/api/graphql/logic/query_array.rb +1 -0
- data/lib/ecoportal/api/graphql/logic/query_connection.rb +2 -0
- data/lib/ecoportal/api/graphql/model/account.rb +2 -0
- data/lib/ecoportal/api/graphql/model/contractor_entity.rb +2 -2
- data/lib/ecoportal/api/graphql/model/location_node.rb +1 -1
- data/lib/ecoportal/api/graphql/model/user.rb +2 -0
- data/lib/ecoportal/api/graphql/payload/location_structure/apply_commands.rb +2 -0
- data/lib/ecoportal/api/graphql/payload/location_structure/command_execution_result.rb +2 -0
- data/lib/ecoportal/api/graphql/query/location_structures.rb +5 -4
- data/lib/ecoportal/api/graphql_version.rb +1 -1
- metadata +31 -28
- data/lib/ecoportal/api/common/graphql/doc_helpers.rb +0 -10
@@ -2,29 +2,9 @@ module Ecoportal
|
|
2
2
|
module API
|
3
3
|
class GraphQL
|
4
4
|
module Base
|
5
|
-
class Model < Ecoportal::API::Common::
|
6
|
-
include Ecoportal::API::Common::GraphQL::ClassHelpers
|
7
|
-
#include GraphModel::HashKeys
|
5
|
+
class Model < Ecoportal::API::Common::GraphQL::Model
|
8
6
|
class << self
|
9
7
|
attr_accessor :client
|
10
|
-
|
11
|
-
def as_input(hash, clientMutationId: "")
|
12
|
-
hash_input = hash.merge(clientMutationId: clientMutationId)
|
13
|
-
Ecoportal::API::Common::GraphQL::HashHelpers.remove_nil_keys_deep(hash_input, target: :id)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def as_update(ref = :last, ignore: [], sym_keys: false)
|
18
|
-
new_doc = as_json
|
19
|
-
ref_doc = ref == :total ? initial_doc : original_doc
|
20
|
-
Ecoportal::API::Common::HashDiff.diff(new_doc, ref_doc, ignore: ignore).yield_self do |out|
|
21
|
-
next out unless sym_keys
|
22
|
-
Ecoportal::API::Common::GraphQL::HashHelpers.keys_to_sym_deep(out)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def as_input(clientMutationId: "")
|
27
|
-
self.class.as_input(as_update(sym_keys: true), clientMutationId: clientMutationId)
|
28
8
|
end
|
29
9
|
end
|
30
10
|
end
|
@@ -3,6 +3,8 @@ module Ecoportal
|
|
3
3
|
class GraphQL
|
4
4
|
module Error
|
5
5
|
class LocationsError < Ecoportal::API::GraphQL::Base::Model
|
6
|
+
read_only!
|
7
|
+
|
6
8
|
passthrough :message, :conflictingIds
|
7
9
|
passthrough :type
|
8
10
|
embeds_many :validationErrors, klass: Ecoportal::API::GraphQL::Error::LocationsValidationError
|
@@ -2,6 +2,7 @@
|
|
2
2
|
module Fragment
|
3
3
|
include Ecoportal::API::Common::GraphQL::ClassHelpers
|
4
4
|
end
|
5
|
+
|
5
6
|
# Class to define/parse fragments
|
6
7
|
module Ecoportal
|
7
8
|
module API
|
@@ -28,6 +29,7 @@ module Ecoportal
|
|
28
29
|
|
29
30
|
def define(sym, heredoc, namespace: ::Fragment)
|
30
31
|
namespace.send(:remove_const, sym) if namespace.const_defined?(sym)
|
32
|
+
|
31
33
|
client.parse(heredoc).tap do |fragment|
|
32
34
|
without_warnings do
|
33
35
|
namespace.const_set(sym, fragment)
|
@@ -3,7 +3,7 @@ module Ecoportal
|
|
3
3
|
class GraphQL
|
4
4
|
module Helpers
|
5
5
|
module LocationsTree
|
6
|
-
RELEVANT_NODES_COUNT =
|
6
|
+
RELEVANT_NODES_COUNT = 1_000
|
7
7
|
|
8
8
|
def treeify(nodes)
|
9
9
|
parents = nodes.each_with_object({}) do |node, out|
|
@@ -21,15 +21,15 @@ module Ecoportal
|
|
21
21
|
class_names = class_types.map(&:name)
|
22
22
|
|
23
23
|
results << {
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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,
|
32
|
+
'nodes' => get_children(child.id, parents).compact
|
33
33
|
}
|
34
34
|
end
|
35
35
|
end
|
@@ -14,6 +14,7 @@ module Ecoportal
|
|
14
14
|
def accepted_params(*keys, default: :unused)
|
15
15
|
@accepted_params ||= []
|
16
16
|
return @accepted_params if keys.empty?
|
17
|
+
|
17
18
|
keys.map(&:to_sym).uniq.each do |key|
|
18
19
|
@accepted_params |= [key]
|
19
20
|
param_defaults[key] = default unless default == :unused
|
@@ -36,12 +37,14 @@ module Ecoportal
|
|
36
37
|
# @note it is meant for reusability of queries from different end-points
|
37
38
|
def field_name(str = nil)
|
38
39
|
return @field_name unless str
|
40
|
+
|
39
41
|
@field_name = nil
|
40
42
|
@field_name = str.to_s if str
|
41
43
|
end
|
42
44
|
|
43
45
|
def base_path(path = :unused)
|
44
46
|
return @base_path if path == :unused
|
47
|
+
|
45
48
|
path ||= []
|
46
49
|
path = path.to_s.split('.') if path.is_a?(String)
|
47
50
|
path = path.map(&:to_s).compact
|
@@ -51,8 +54,7 @@ module Ecoportal
|
|
51
54
|
|
52
55
|
include Ecoportal::API::Common::Concerns::Benchmarkable
|
53
56
|
|
54
|
-
attr_reader :client
|
55
|
-
attr_reader :base_path
|
57
|
+
attr_reader :client, :base_path
|
56
58
|
|
57
59
|
def initialize(client, path: nil, base_path: self.class.base_path)
|
58
60
|
@path = path
|
@@ -94,6 +96,7 @@ module Ecoportal
|
|
94
96
|
def graphql_query(path: self.path, raw_response: {}, **kargs, &block)
|
95
97
|
default_params = self.class.param_defaults.dup
|
96
98
|
query_params = self.class.slice_params(default_params.merge(kargs))
|
99
|
+
|
97
100
|
request(*path) do
|
98
101
|
raw_response[:data] = client.query(query_params, &block)
|
99
102
|
end
|
@@ -5,13 +5,13 @@ module Ecoportal
|
|
5
5
|
class Mutation < Ecoportal::API::GraphQL::Logic::BaseQuery
|
6
6
|
class GenericPayload
|
7
7
|
def initialize(*_args, **_kargs)
|
8
|
-
raise
|
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
11
|
|
12
12
|
class GenericInput
|
13
13
|
def initialize(*_args, **_kargs)
|
14
|
-
raise
|
14
|
+
raise 'Missuse error. You should define a input_class for a class that inherits from Mutation class.'
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -38,12 +38,10 @@ module Ecoportal
|
|
38
38
|
|
39
39
|
def as_input(value)
|
40
40
|
case value
|
41
|
-
when input_class
|
41
|
+
when input_class, Ecoportal::API::GraphQL::Base::Model
|
42
42
|
value.as_input
|
43
43
|
when Hash
|
44
44
|
value
|
45
|
-
when Ecoportal::API::GraphQL::Base::Model
|
46
|
-
value.as_input
|
47
45
|
# when Hash
|
48
46
|
# value = Helpers::Model::HashKeys.keys_to_sym_deep(value)
|
49
47
|
# Ecoportal::API::Base::Model.as_input(value)
|
@@ -5,7 +5,10 @@ module Ecoportal
|
|
5
5
|
class Query < Ecoportal::API::GraphQL::Logic::BaseQuery
|
6
6
|
class GenericItem
|
7
7
|
def initialize(*_args, **_kargs)
|
8
|
-
|
8
|
+
msg = "Missuse error. "
|
9
|
+
msg << "You should define a item_class for a class that "
|
10
|
+
msg << "inherits from Query class."
|
11
|
+
raise msg
|
9
12
|
end
|
10
13
|
end
|
11
14
|
class_resolver :item_class, GenericItem
|
@@ -8,6 +8,7 @@ module Ecoportal
|
|
8
8
|
|
9
9
|
def each(connection_block: nil, **kargs, &block)
|
10
10
|
return to_enum(:each, **kargs, connection_block: connection_block) unless block
|
11
|
+
|
11
12
|
cursor = nil
|
12
13
|
loop do
|
13
14
|
kargs.update(after: cursor) if cursor
|
@@ -21,6 +22,7 @@ module Ecoportal
|
|
21
22
|
|
22
23
|
def response_class
|
23
24
|
return connection_class if respond_to?(:connection_class)
|
25
|
+
|
24
26
|
@response_class ||= self.class.new_class(
|
25
27
|
item_class,
|
26
28
|
inherits: Ecoportal::API::GraphQL::Logic::Connection,
|
@@ -3,8 +3,8 @@ module Ecoportal
|
|
3
3
|
class GraphQL
|
4
4
|
module Model
|
5
5
|
class ContractorEntity < Ecoportal::API::GraphQL::Base::ContractorEntity
|
6
|
-
embeds_one :associatedPeople, klass: "Ecoportal::API::GraphQL::Connections::PersonMemberConnection"
|
7
|
-
embeds_many :leadContractors,
|
6
|
+
embeds_one :associatedPeople, read_only: true, klass: "Ecoportal::API::GraphQL::Connections::PersonMemberConnection"
|
7
|
+
embeds_many :leadContractors, read_only: true, klass: "Ecoportal::API::GraphQL::Model::PersonMember"
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
@@ -4,7 +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
|
+
embeds_many :ancestors, read_only: true, klass: Model::LocationNode
|
8
8
|
|
9
9
|
def parentId
|
10
10
|
parent&.id
|
@@ -4,6 +4,8 @@ module Ecoportal
|
|
4
4
|
module Payload
|
5
5
|
module LocationStructure
|
6
6
|
class ApplyCommands < Ecoportal::API::GraphQL::Base::Model
|
7
|
+
read_only!
|
8
|
+
|
7
9
|
passthrough :clientMutationId
|
8
10
|
embeds_one :structure, klass: Ecoportal::API::GraphQL::Model::LocationStructure
|
9
11
|
embeds_one :errors, klass: Ecoportal::API::GraphQL::Error::ValidationErrors, nullable: true
|
@@ -4,6 +4,8 @@ module Ecoportal
|
|
4
4
|
module Payload
|
5
5
|
module LocationStructure
|
6
6
|
class CommandExecutionResult < Ecoportal::API::GraphQL::Base::Model
|
7
|
+
read_only!
|
8
|
+
|
7
9
|
embeds_one :command, klass: Ecoportal::API::GraphQL::Payload::LocationStructure::CommandInterface
|
8
10
|
embeds_one :error, nullable: true, klass: Ecoportal::API::GraphQL::Error::LocationsError
|
9
11
|
passboolean :ok
|
@@ -15,14 +15,15 @@ module Ecoportal
|
|
15
15
|
def basic_block(&block)
|
16
16
|
final_block = block || default_query_block
|
17
17
|
proc {
|
18
|
-
query(
|
19
|
-
|
20
|
-
|
18
|
+
query(
|
19
|
+
includeArchived: :boolean,
|
20
|
+
includeUnpublished: :boolean,
|
21
|
+
includeArchivedNodes: :boolean
|
21
22
|
) {
|
22
23
|
currentOrganization {
|
23
24
|
locations {
|
24
25
|
structures(
|
25
|
-
includeArchived:
|
26
|
+
includeArchived: :includeArchived,
|
26
27
|
includeUnpublished: :includeUnpublished,
|
27
28
|
&final_block
|
28
29
|
)
|
metadata
CHANGED
@@ -1,35 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ecoportal-api-graphql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oscar Segura
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: pry
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '4'
|
19
|
+
version: '0.14'
|
23
20
|
type: :development
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
24
|
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
30
|
-
- - "<"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '4'
|
26
|
+
version: '0.14'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: rake
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -51,32 +45,32 @@ dependencies:
|
|
51
45
|
- !ruby/object:Gem::Version
|
52
46
|
version: '14'
|
53
47
|
- !ruby/object:Gem::Dependency
|
54
|
-
name:
|
48
|
+
name: redcarpet
|
55
49
|
requirement: !ruby/object:Gem::Requirement
|
56
50
|
requirements:
|
57
51
|
- - ">="
|
58
52
|
- !ruby/object:Gem::Version
|
59
|
-
version:
|
53
|
+
version: 3.6.0
|
60
54
|
- - "<"
|
61
55
|
- !ruby/object:Gem::Version
|
62
|
-
version: '
|
56
|
+
version: '4'
|
63
57
|
type: :development
|
64
58
|
prerelease: false
|
65
59
|
version_requirements: !ruby/object:Gem::Requirement
|
66
60
|
requirements:
|
67
61
|
- - ">="
|
68
62
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
63
|
+
version: 3.6.0
|
70
64
|
- - "<"
|
71
65
|
- !ruby/object:Gem::Version
|
72
|
-
version: '
|
66
|
+
version: '4'
|
73
67
|
- !ruby/object:Gem::Dependency
|
74
|
-
name:
|
68
|
+
name: rspec
|
75
69
|
requirement: !ruby/object:Gem::Requirement
|
76
70
|
requirements:
|
77
71
|
- - ">="
|
78
72
|
- !ruby/object:Gem::Version
|
79
|
-
version: 3.
|
73
|
+
version: 3.12.0
|
80
74
|
- - "<"
|
81
75
|
- !ruby/object:Gem::Version
|
82
76
|
version: '4'
|
@@ -86,7 +80,7 @@ dependencies:
|
|
86
80
|
requirements:
|
87
81
|
- - ">="
|
88
82
|
- !ruby/object:Gem::Version
|
89
|
-
version: 3.
|
83
|
+
version: 3.12.0
|
90
84
|
- - "<"
|
91
85
|
- !ruby/object:Gem::Version
|
92
86
|
version: '4'
|
@@ -119,19 +113,25 @@ dependencies:
|
|
119
113
|
- !ruby/object:Gem::Version
|
120
114
|
version: '0'
|
121
115
|
- !ruby/object:Gem::Dependency
|
122
|
-
name:
|
116
|
+
name: yard
|
123
117
|
requirement: !ruby/object:Gem::Requirement
|
124
118
|
requirements:
|
125
119
|
- - ">="
|
126
120
|
- !ruby/object:Gem::Version
|
127
|
-
version:
|
121
|
+
version: 0.9.34
|
122
|
+
- - "<"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '1'
|
128
125
|
type: :development
|
129
126
|
prerelease: false
|
130
127
|
version_requirements: !ruby/object:Gem::Requirement
|
131
128
|
requirements:
|
132
129
|
- - ">="
|
133
130
|
- !ruby/object:Gem::Version
|
134
|
-
version:
|
131
|
+
version: 0.9.34
|
132
|
+
- - "<"
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '1'
|
135
135
|
- !ruby/object:Gem::Dependency
|
136
136
|
name: ecoportal-api
|
137
137
|
requirement: !ruby/object:Gem::Requirement
|
@@ -141,7 +141,7 @@ dependencies:
|
|
141
141
|
version: '0.10'
|
142
142
|
- - ">="
|
143
143
|
- !ruby/object:Gem::Version
|
144
|
-
version: 0.10.
|
144
|
+
version: 0.10.8
|
145
145
|
type: :runtime
|
146
146
|
prerelease: false
|
147
147
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -151,7 +151,7 @@ dependencies:
|
|
151
151
|
version: '0.10'
|
152
152
|
- - ">="
|
153
153
|
- !ruby/object:Gem::Version
|
154
|
-
version: 0.10.
|
154
|
+
version: 0.10.8
|
155
155
|
- !ruby/object:Gem::Dependency
|
156
156
|
name: ecoportal-api-v2
|
157
157
|
requirement: !ruby/object:Gem::Requirement
|
@@ -161,7 +161,7 @@ dependencies:
|
|
161
161
|
version: '2.0'
|
162
162
|
- - ">="
|
163
163
|
- !ruby/object:Gem::Version
|
164
|
-
version: 2.0.
|
164
|
+
version: 2.0.15
|
165
165
|
type: :runtime
|
166
166
|
prerelease: false
|
167
167
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -171,7 +171,7 @@ dependencies:
|
|
171
171
|
version: '2.0'
|
172
172
|
- - ">="
|
173
173
|
- !ruby/object:Gem::Version
|
174
|
-
version: 2.0.
|
174
|
+
version: 2.0.15
|
175
175
|
- !ruby/object:Gem::Dependency
|
176
176
|
name: graphlient
|
177
177
|
requirement: !ruby/object:Gem::Requirement
|
@@ -220,9 +220,12 @@ files:
|
|
220
220
|
- lib/ecoportal/api/common/graphql/auth_service.rb
|
221
221
|
- lib/ecoportal/api/common/graphql/class_helpers.rb
|
222
222
|
- lib/ecoportal/api/common/graphql/client.rb
|
223
|
-
- lib/ecoportal/api/common/graphql/doc_helpers.rb
|
224
223
|
- lib/ecoportal/api/common/graphql/hash_helpers.rb
|
225
224
|
- lib/ecoportal/api/common/graphql/http_client.rb
|
225
|
+
- lib/ecoportal/api/common/graphql/model.rb
|
226
|
+
- lib/ecoportal/api/common/graphql/model/as_input.rb
|
227
|
+
- lib/ecoportal/api/common/graphql/model/diffable.rb
|
228
|
+
- lib/ecoportal/api/common/graphql/model/diffable/hash_diff.rb
|
226
229
|
- lib/ecoportal/api/common/graphql/patches.rb
|
227
230
|
- lib/ecoportal/api/common/graphql/query_integration.rb
|
228
231
|
- lib/ecoportal/api/graphql.rb
|
@@ -364,7 +367,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
364
367
|
- !ruby/object:Gem::Version
|
365
368
|
version: '0'
|
366
369
|
requirements: []
|
367
|
-
rubygems_version: 3.5.
|
370
|
+
rubygems_version: 3.5.23
|
368
371
|
signing_key:
|
369
372
|
specification_version: 4
|
370
373
|
summary: A collection of helpers for interacting with the ecoPortal GraphQL API
|