ecoportal-api-graphql 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +12 -4
- data/ecoportal-api-graphql.gemspec +1 -1
- data/lib/ecoportal/api/common/graphql/patches/query.rb +26 -4
- data/lib/ecoportal/api/common/graphql/query_integration.rb +41 -0
- data/lib/ecoportal/api/common/graphql.rb +1 -0
- data/lib/ecoportal/api/graphql/model/organization.rb +9 -46
- data/lib/ecoportal/api/graphql/query/tag_tree.rb +38 -0
- data/lib/ecoportal/api/graphql/query.rb +1 -0
- data/lib/ecoportal/api/graphql_version.rb +1 -1
- data/tests/local_libs.rb +4 -2
- data/tests/tagtree_get.rb +7 -0
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a149d79e773d8c7a3036e78bd729fbd9630937284517854656738f97acd0022
|
4
|
+
data.tar.gz: 491b8e694b341cdad48467f062243dd7677228083f9fde3765f4249b76c270f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df671787213260d751f1f381d4ec0706a98fc68690a32d01fdfe8448ff9cf4ae4d3e9d2154ad1ba0fbce6d900a89fbc2ce32015cdf9df047850fa7b1cfa63771
|
7
|
+
data.tar.gz: 28fe2d48c1ce8417e9803554ae6d6d27b5539129163dee98853f6e4837dd46e78b35f73945ec19e98850505b76932460966a57e3f6812971cc43292d229a1967
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
-
## [0.1.
|
4
|
+
## [0.1.10] - 2022-09-xx
|
5
5
|
|
6
6
|
### Added
|
7
|
-
### Changed
|
7
|
+
### Changed
|
8
8
|
### Fixed
|
9
9
|
|
10
10
|
### ToDo
|
@@ -14,6 +14,16 @@ All notable changes to this project will be documented in this file.
|
|
14
14
|
- Analyse how to "DSL" currentOrganization.action.activities
|
15
15
|
- review `path` tracking
|
16
16
|
|
17
|
+
## [0.1.9] - 2022-09-26
|
18
|
+
|
19
|
+
### Added
|
20
|
+
- `Ecoportal::API::GraphQL::Query::TagTree`
|
21
|
+
|
22
|
+
### Changed
|
23
|
+
- **upgraded** `ecoportal-api-v2` gem dependency
|
24
|
+
- added `Ecoportal::API::Common::GraphQL::QueryIntegration`
|
25
|
+
- restructured `Ecoportal::API::GraphQL::Model::Organization` class
|
26
|
+
|
17
27
|
## [0.1.8] - 2022-09-23
|
18
28
|
|
19
29
|
### Added
|
@@ -23,8 +33,6 @@ All notable changes to this project will be documented in this file.
|
|
23
33
|
- **upgraded** `ecoportal-api-v2` gem dependency
|
24
34
|
- Restructured the `Query` inheritance chain to make things simpler
|
25
35
|
|
26
|
-
### Fixed
|
27
|
-
|
28
36
|
## [0.1.6] - 2022-09-19
|
29
37
|
|
30
38
|
### Fixed
|
@@ -29,6 +29,6 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.add_development_dependency "redcarpet", ">= 3.5.1", "< 3.6"
|
30
30
|
spec.add_development_dependency "pry" , ">= 0.14"
|
31
31
|
|
32
|
-
spec.add_dependency 'ecoportal-api-v2', '>= 0.
|
32
|
+
spec.add_dependency 'ecoportal-api-v2', '>= 0.9.1', '< 0.10'
|
33
33
|
spec.add_dependency 'graphlient', '>= 0.6.0', '< 0.7'
|
34
34
|
end
|
@@ -1,11 +1,33 @@
|
|
1
1
|
module Graphlient
|
2
2
|
class Query
|
3
|
+
FRAGMENT_DEFITION = /___(?<const>[A-Z][a-zA-Z0-9_]*(__[A-Z][a-zA-Z0-9_]*)*)/
|
4
|
+
|
5
|
+
def initialize(&block)
|
6
|
+
@indents = 0
|
7
|
+
@query_str = ''
|
8
|
+
@variables = []
|
9
|
+
evaluate(&block)
|
10
|
+
end
|
11
|
+
|
3
12
|
private
|
4
13
|
|
5
|
-
def
|
6
|
-
|
7
|
-
|
14
|
+
def evaluate(&block)
|
15
|
+
@last_block = block || self
|
16
|
+
(@context ||= {})[@last_block] ||= @last_block.binding
|
17
|
+
instance_eval(&block)
|
18
|
+
end
|
19
|
+
|
20
|
+
def resolve_fragment_constant(value)
|
21
|
+
return nil unless (match = value.to_s.match(FRAGMENT_DEFITION))
|
22
|
+
raw_const = match[:const].gsub('__', '::')
|
23
|
+
@context[@last_block].eval(raw_const).tap do |const|
|
24
|
+
msg = "Expected constant #{raw_const} to be GraphQL::Client::FragmentDefinition. Given #{const.class}"
|
25
|
+
raise Graphlient::Errors::Error, msg unless const.is_a? GraphQL::Client::FragmentDefinition
|
8
26
|
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def append_node(node, args, arg_processor: nil, &block)
|
30
|
+
node = "...#{resolve_fragment_constant(node)}".to_sym if node.to_s.start_with?('___')
|
9
31
|
|
10
32
|
# add field
|
11
33
|
@query_str << "\n#{indent}#{node}"
|
@@ -16,7 +38,7 @@ module Graphlient
|
|
16
38
|
if block_given?
|
17
39
|
@indents += 1
|
18
40
|
@query_str << '{'
|
19
|
-
|
41
|
+
evaluate(&block)
|
20
42
|
@query_str << '}'
|
21
43
|
@indents -= 1
|
22
44
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Ecoportal
|
2
|
+
module API
|
3
|
+
module Common
|
4
|
+
module GraphQL
|
5
|
+
module QueryIntegration
|
6
|
+
include Ecoportal::API::Common::GraphQL::ClassHelpers::ClassMethods
|
7
|
+
|
8
|
+
attr_accessor :client
|
9
|
+
attr_reader :path
|
10
|
+
|
11
|
+
# @!macro [attach] query
|
12
|
+
# @method $1
|
13
|
+
# The $1 query integration
|
14
|
+
# @return [Collection::$1, $1]
|
15
|
+
# @return [Connection::$1, $1]
|
16
|
+
def query(method, query_klass:)
|
17
|
+
method = method.to_sym
|
18
|
+
class_method = "#{method}_query_class".to_sym
|
19
|
+
|
20
|
+
define_method(method) do |**kargs, &block|
|
21
|
+
if kargs.empty? && !block_given?
|
22
|
+
method(class_method).call
|
23
|
+
else
|
24
|
+
method(class_method).call.query(**kargs, &block)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
define_method(class_method) do
|
29
|
+
resolve_class(query_klass).tap do |klass|
|
30
|
+
unless klass <= Ecoportal::API::GraphQL::Base::Query
|
31
|
+
raise "Expected query_klass to be of type Ecoportal::API::GraphQL::Base::Query. Given: #{klass}"
|
32
|
+
end
|
33
|
+
end.new(client, base_path: path)
|
34
|
+
end
|
35
|
+
private class_method
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -14,3 +14,4 @@ require 'ecoportal/api/common/graphql/class_helpers'
|
|
14
14
|
require 'ecoportal/api/common/graphql/doc_helpers'
|
15
15
|
require 'ecoportal/api/common/graphql/hash_helpers'
|
16
16
|
require 'ecoportal/api/common/graphql/patches'
|
17
|
+
require 'ecoportal/api/common/graphql/query_integration'
|
@@ -6,61 +6,24 @@ module Ecoportal
|
|
6
6
|
DEFAULT_PATH = ["currentOrganization"]
|
7
7
|
|
8
8
|
class << self
|
9
|
+
extend Ecoportal::API::Common::GraphQL::QueryIntegration
|
10
|
+
|
9
11
|
def path(*add)
|
10
12
|
DEFAULT_PATH.dup.push(*add)
|
11
13
|
end
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
def tagTrees(**kargs, &block)
|
17
|
-
if kargs.empty? && !block_given?
|
18
|
-
tagTreesQuery
|
19
|
-
else
|
20
|
-
tagTreesQuery.query(**kargs, &block)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
#tagTree
|
25
|
-
|
26
|
-
#register, registers
|
27
|
-
#personMembers, attachablePersonMembers
|
15
|
+
query :tagTree, query_klass: "Ecoportal::API::GraphQL::Query::TagTree"
|
16
|
+
query :tagTrees, query_klass: "Ecoportal::API::GraphQL::Query::TagTrees"
|
17
|
+
query :contractorEntities, query_klass: "Ecoportal::API::GraphQL::Query::ContractorEntities"
|
28
18
|
#contractorEntity,
|
29
|
-
|
30
|
-
# @return [Connection::ContractorEntity, Query::ContractorEntities]
|
31
|
-
def contractorEntities(**kargs, &block)
|
32
|
-
if kargs.empty? && !block_given?
|
33
|
-
contractorEntitiesQuery
|
34
|
-
else
|
35
|
-
contractorEntitiesQuery.query(**kargs, &block)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
# @return [Connection::Action, Query::Actions]
|
40
|
-
def actions(**kargs, &block)
|
41
|
-
if kargs.empty? && !block_given?
|
42
|
-
actionsQuery
|
43
|
-
else
|
44
|
-
actionsQuery.query(**kargs, &block)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
19
|
+
query :actions, query_klass: "Ecoportal::API::GraphQL::Query::Actions"
|
48
20
|
#action, actionsByPage, actionsCounter
|
49
21
|
#actionCategories
|
50
22
|
|
51
|
-
|
52
|
-
|
53
|
-
def tagTreesQuery
|
54
|
-
Ecoportal::API::GraphQL::Query::TagTrees.new(client, base_path: path)
|
55
|
-
end
|
56
|
-
|
57
|
-
def contractorEntitiesQuery
|
58
|
-
Ecoportal::API::GraphQL::Query::ContractorEntities.new(client, base_path: path)
|
59
|
-
end
|
23
|
+
#userGroup, userGroups
|
60
24
|
|
61
|
-
|
62
|
-
|
63
|
-
end
|
25
|
+
#register, registers
|
26
|
+
#personMembers, attachablePersonMembers
|
64
27
|
end
|
65
28
|
end
|
66
29
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Ecoportal
|
2
|
+
module API
|
3
|
+
class GraphQL
|
4
|
+
module Query
|
5
|
+
class TagTree < Ecoportal::API::GraphQL::Base::Query
|
6
|
+
accepted_params :id
|
7
|
+
field_name :tagTree
|
8
|
+
|
9
|
+
class_resolver :item_class, Ecoportal::API::GraphQL::Model::TagTree
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def basic_block(&block)
|
14
|
+
final_block = block || default_tree_block
|
15
|
+
Proc.new {
|
16
|
+
query(id: :id!) {
|
17
|
+
currentOrganization {
|
18
|
+
tagTree(id: :id, &final_block)
|
19
|
+
}
|
20
|
+
}
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
def default_tree_block
|
25
|
+
Proc.new {
|
26
|
+
id
|
27
|
+
name
|
28
|
+
visitorManagementEnabled
|
29
|
+
nodes {
|
30
|
+
___Ecoportal__API__GraphQL__Fragment__TagTreeNode
|
31
|
+
}
|
32
|
+
}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/tests/local_libs.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'byebug'
|
1
2
|
base_dir = 'C:/ruby_scripts/git'
|
2
3
|
|
3
4
|
api_path = File.join(base_dir,'/ecoportal-api/lib')
|
@@ -10,8 +11,9 @@ api_v2_path = File.join(base_dir,'/ecoportal-api-v2/lib')
|
|
10
11
|
$LOAD_PATH.unshift File.expand_path(api_v2_path)
|
11
12
|
#require 'ecoportal/api-v2'
|
12
13
|
require File.join(base_dir,'/ecoportal-api-v2/lib/ecoportal/api-v2')
|
13
|
-
|
14
|
-
$LOAD_PATH.unshift File.
|
14
|
+
|
15
|
+
# $LOAD_PATH.unshift File.join(base_dir,'/graphlient/lib')
|
16
|
+
# require File.join(base_dir,'/graphlient/lib/graphlient')
|
15
17
|
|
16
18
|
graphql = File.join(base_dir,'/ecoportal-api-graphql/lib')
|
17
19
|
$LOAD_PATH.unshift File.expand_path(graphql)
|
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.1.
|
4
|
+
version: 0.1.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: 2022-09-
|
11
|
+
date: 2022-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -130,20 +130,20 @@ dependencies:
|
|
130
130
|
requirements:
|
131
131
|
- - ">="
|
132
132
|
- !ruby/object:Gem::Version
|
133
|
-
version: 0.
|
133
|
+
version: 0.9.1
|
134
134
|
- - "<"
|
135
135
|
- !ruby/object:Gem::Version
|
136
|
-
version: '0.
|
136
|
+
version: '0.10'
|
137
137
|
type: :runtime
|
138
138
|
prerelease: false
|
139
139
|
version_requirements: !ruby/object:Gem::Requirement
|
140
140
|
requirements:
|
141
141
|
- - ">="
|
142
142
|
- !ruby/object:Gem::Version
|
143
|
-
version: 0.
|
143
|
+
version: 0.9.1
|
144
144
|
- - "<"
|
145
145
|
- !ruby/object:Gem::Version
|
146
|
-
version: '0.
|
146
|
+
version: '0.10'
|
147
147
|
- !ruby/object:Gem::Dependency
|
148
148
|
name: graphlient
|
149
149
|
requirement: !ruby/object:Gem::Requirement
|
@@ -196,6 +196,7 @@ files:
|
|
196
196
|
- lib/ecoportal/api/common/graphql/http_client.rb
|
197
197
|
- lib/ecoportal/api/common/graphql/patches.rb
|
198
198
|
- lib/ecoportal/api/common/graphql/patches/query.rb
|
199
|
+
- lib/ecoportal/api/common/graphql/query_integration.rb
|
199
200
|
- lib/ecoportal/api/graphql.rb
|
200
201
|
- lib/ecoportal/api/graphql/base.rb
|
201
202
|
- lib/ecoportal/api/graphql/base/action.rb
|
@@ -259,11 +260,13 @@ files:
|
|
259
260
|
- lib/ecoportal/api/graphql/query.rb
|
260
261
|
- lib/ecoportal/api/graphql/query/actions.rb
|
261
262
|
- lib/ecoportal/api/graphql/query/contractor_entities.rb
|
263
|
+
- lib/ecoportal/api/graphql/query/tag_tree.rb
|
262
264
|
- lib/ecoportal/api/graphql/query/tag_trees.rb
|
263
265
|
- lib/ecoportal/api/graphql_version.rb
|
264
266
|
- tests/actions_get.rb
|
265
267
|
- tests/contractor_entities_get.rb
|
266
268
|
- tests/local_libs.rb
|
269
|
+
- tests/tagtree_get.rb
|
267
270
|
- tests/tagtrees_get.rb
|
268
271
|
homepage: https://www.ecoportal.com
|
269
272
|
licenses:
|