ecoportal-api-graphql 0.1.4 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -4
- data/lib/ecoportal/api/common/graphql/auth_service.rb +0 -1
- data/lib/ecoportal/api/common/graphql/class_helpers.rb +9 -0
- data/lib/ecoportal/api/common/graphql/patches/query.rb +27 -0
- data/lib/ecoportal/api/common/graphql/patches.rb +1 -0
- data/lib/ecoportal/api/common/graphql.rb +1 -0
- data/lib/ecoportal/api/graphql/fragment/action.rb +53 -0
- data/lib/ecoportal/api/graphql/fragment/pagination.rb +1 -1
- data/lib/ecoportal/api/graphql/fragment.rb +18 -17
- data/lib/ecoportal/api/graphql/query/actions.rb +2 -45
- data/lib/ecoportal/api/graphql/query/contractor_entities.rb +1 -7
- data/lib/ecoportal/api/graphql.rb +1 -1
- data/lib/ecoportal/api/graphql_version.rb +1 -1
- data/tests/actions_get.rb +0 -1
- data/tests/local_libs.rb +4 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c0e5dcda795491dd4687054d51f9b3888f707f320ed079742c54cbde74464ad
|
4
|
+
data.tar.gz: ab434f8f1f410692b0ac8f4a3cd549293045e17e469b2b09a14c1fbe85123f06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3d127b631c0c567cd7831d5e1cda50f5474e1d4c262716e000aa324045b2fc228452ed2d968b620b9b58c43000b4526af5d2916e525b81af2c12999e23a00bd
|
7
|
+
data.tar.gz: 5c86f610a220829e975bef5ff3e459801247a7cda07368dafc2fc2278b81aed8f2535b187b6ee8682d61bc15bfb23ea84c048dac6df48c219d6f4ccb5fff84bd
|
data/CHANGELOG.md
CHANGED
@@ -1,12 +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.7] - 2022-09-xx
|
5
5
|
|
6
6
|
### Added
|
7
|
-
|
8
7
|
### Changed
|
9
|
-
|
10
8
|
### Fixed
|
11
9
|
|
12
10
|
### ToDo
|
@@ -16,13 +14,27 @@ All notable changes to this project will be documented in this file.
|
|
16
14
|
- Analyse how to "DSL" currentOrganization.action.activities
|
17
15
|
- review `path` tracking
|
18
16
|
|
17
|
+
## [0.1.6] - 2022-09-19
|
18
|
+
|
19
|
+
### Fixed
|
20
|
+
- Call to **private** method `remove_const` in `Ecoportal::API::GraphQL::Fragment#define`
|
21
|
+
|
22
|
+
## [0.1.5] - 2022-09-19
|
23
|
+
|
24
|
+
### Added
|
25
|
+
- Patch `GraphQL::Query#append_node` so we can use Fragments in blocks using `___` as start of the constant, and `__` for namespace separator
|
26
|
+
- Issue/feature request: https://github.com/ashkan18/graphlient/issues/93
|
27
|
+
- `Ecoportal::API::GraphQL::Fragment#define` provided that client scripts can create their own fragments in their own namespace
|
28
|
+
- Exposed `Ecoportal::API::GraphQL#fragments`
|
29
|
+
- It will always (re)define in the `Fragment` root namespace
|
30
|
+
|
19
31
|
## [0.1.4] - 2022-09-16
|
20
32
|
|
21
33
|
### Fixed
|
22
34
|
- Able to inject connection block to `each`
|
23
35
|
- Error handling delegated to parent class (`QueryConnection`)
|
24
36
|
- Retrieve `id` on elements of `Array`
|
25
|
-
|
37
|
+
|
26
38
|
## [0.1.3] - 2022-09-15
|
27
39
|
|
28
40
|
### Fixed
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Graphlient
|
2
|
+
class Query
|
3
|
+
private
|
4
|
+
|
5
|
+
def append_node(node, args, arg_processor: nil, &block)
|
6
|
+
if node.to_s.start_with?("___")
|
7
|
+
node = node.to_s.gsub("___", "...").gsub("__", "::").to_sym
|
8
|
+
end
|
9
|
+
|
10
|
+
# add field
|
11
|
+
@query_str << "\n#{indent}#{node}"
|
12
|
+
# add filter
|
13
|
+
hash_arguments = hash_arg(args)
|
14
|
+
@query_str << "(#{args_str(hash_arguments, arg_processor: arg_processor)})" if hash_arguments
|
15
|
+
|
16
|
+
if block_given?
|
17
|
+
@indents += 1
|
18
|
+
@query_str << '{'
|
19
|
+
instance_eval(&block)
|
20
|
+
@query_str << '}'
|
21
|
+
@indents -= 1
|
22
|
+
end
|
23
|
+
|
24
|
+
@query_str << "\n#{indent}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'patches/query'
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Ecoportal
|
2
|
+
module API
|
3
|
+
class GraphQL
|
4
|
+
class Fragment
|
5
|
+
fragment :Action, <<~'GRAPHQL'
|
6
|
+
fragment on Action {
|
7
|
+
id
|
8
|
+
altId
|
9
|
+
actionCategory {
|
10
|
+
name
|
11
|
+
value
|
12
|
+
}
|
13
|
+
standaloneAction
|
14
|
+
status
|
15
|
+
relativeStatus
|
16
|
+
archived
|
17
|
+
tags
|
18
|
+
name
|
19
|
+
description
|
20
|
+
assignedTo {
|
21
|
+
id
|
22
|
+
name
|
23
|
+
email
|
24
|
+
}
|
25
|
+
createdAt {
|
26
|
+
dateTime
|
27
|
+
timeZone
|
28
|
+
}
|
29
|
+
dueDate {
|
30
|
+
dateTime
|
31
|
+
timeZone
|
32
|
+
}
|
33
|
+
completedAt {
|
34
|
+
dateTime
|
35
|
+
timeZone
|
36
|
+
}
|
37
|
+
completer {
|
38
|
+
name
|
39
|
+
email
|
40
|
+
}
|
41
|
+
linkedResources {
|
42
|
+
id
|
43
|
+
page {
|
44
|
+
name
|
45
|
+
mouldCounter
|
46
|
+
}
|
47
|
+
}
|
48
|
+
}
|
49
|
+
GRAPHQL
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -1,17 +1,15 @@
|
|
1
|
+
# Namespace to create custom fragments from client scripts
|
2
|
+
module Fragment
|
3
|
+
include Ecoportal::API::Common::GraphQL::ClassHelpers
|
4
|
+
end
|
5
|
+
# Class to define/parse fragments
|
1
6
|
module Ecoportal
|
2
7
|
module API
|
3
8
|
class GraphQL
|
4
9
|
class Fragment
|
5
|
-
|
6
|
-
def const?(value)
|
7
|
-
begin
|
8
|
-
const_get(value)
|
9
|
-
rescue NameError => e
|
10
|
-
return false
|
11
|
-
end
|
12
|
-
true
|
13
|
-
end
|
10
|
+
include Ecoportal::API::Common::GraphQL::ClassHelpers
|
14
11
|
|
12
|
+
class << self
|
15
13
|
def fragment(sym, heredoc)
|
16
14
|
fragments[sym] = heredoc
|
17
15
|
end
|
@@ -28,17 +26,19 @@ module Ecoportal
|
|
28
26
|
parse
|
29
27
|
end
|
30
28
|
|
29
|
+
def define(sym, heredoc, namespace: ::Fragment)
|
30
|
+
namespace.send(:remove_const, sym) if namespace.const?(sym)
|
31
|
+
client.parse(heredoc).tap do |fragment|
|
32
|
+
namespace.const_set(sym, fragment)
|
33
|
+
::Fragment.const_set(sym, fragment) unless namespace == ::Fragment
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
31
37
|
private
|
32
38
|
|
33
39
|
def parse
|
34
40
|
fragments = self.class.fragments.each_with_object({}) do |(sym, heredoc), out|
|
35
|
-
|
36
|
-
fragment = self.class.get_const(sym)
|
37
|
-
else
|
38
|
-
fragment = client.parse(heredoc)
|
39
|
-
self.class.const_set(sym, fragment)
|
40
|
-
end
|
41
|
-
out[sym] = fragment
|
41
|
+
out[sym] = define(sym, heredoc, namespace: self.class)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
@@ -46,5 +46,6 @@ module Ecoportal
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
require 'ecoportal/api/graphql/fragment/contractor_entity'
|
50
49
|
require 'ecoportal/api/graphql/fragment/pagination'
|
50
|
+
require 'ecoportal/api/graphql/fragment/action'
|
51
|
+
require 'ecoportal/api/graphql/fragment/contractor_entity'
|
@@ -39,52 +39,9 @@ module Ecoportal
|
|
39
39
|
|
40
40
|
def default_connection_block
|
41
41
|
Proc.new {
|
42
|
-
|
43
|
-
pageInfo {
|
44
|
-
endCursor
|
45
|
-
}
|
42
|
+
___Ecoportal__API__GraphQL__Fragment__Pagination
|
46
43
|
nodes {
|
47
|
-
|
48
|
-
altId
|
49
|
-
actionCategory {
|
50
|
-
name
|
51
|
-
value
|
52
|
-
}
|
53
|
-
standaloneAction
|
54
|
-
status
|
55
|
-
relativeStatus
|
56
|
-
archived
|
57
|
-
tags
|
58
|
-
name
|
59
|
-
description
|
60
|
-
assignedTo {
|
61
|
-
id
|
62
|
-
name
|
63
|
-
email
|
64
|
-
}
|
65
|
-
createdAt {
|
66
|
-
dateTime
|
67
|
-
timeZone
|
68
|
-
}
|
69
|
-
dueDate {
|
70
|
-
dateTime
|
71
|
-
timeZone
|
72
|
-
}
|
73
|
-
completedAt {
|
74
|
-
dateTime
|
75
|
-
timeZone
|
76
|
-
}
|
77
|
-
completer {
|
78
|
-
name
|
79
|
-
email
|
80
|
-
}
|
81
|
-
linkedResources {
|
82
|
-
id
|
83
|
-
page {
|
84
|
-
name
|
85
|
-
mouldCounter
|
86
|
-
}
|
87
|
-
}
|
44
|
+
___Ecoportal__API__GraphQL__Fragment__Action
|
88
45
|
}
|
89
46
|
}
|
90
47
|
end
|
@@ -5,7 +5,7 @@ module Ecoportal
|
|
5
5
|
class GraphQL
|
6
6
|
include Ecoportal::API::Common::GraphQL::ClassHelpers
|
7
7
|
|
8
|
-
attr_reader :client
|
8
|
+
attr_reader :client, :fragments
|
9
9
|
|
10
10
|
# Creates a `GraphQL` object to interact with the ecoPortal `GraphQL API`.
|
11
11
|
# @param org_id [String] the id of the target organization.
|
data/tests/actions_get.rb
CHANGED
data/tests/local_libs.rb
CHANGED
@@ -12,3 +12,7 @@ $LOAD_PATH.unshift File.expand_path(api_v2_path)
|
|
12
12
|
require File.join(base_dir,'/ecoportal-api-v2/lib/ecoportal/api-v2')
|
13
13
|
api_path = '../lib'
|
14
14
|
$LOAD_PATH.unshift File.expand_path(api_path)
|
15
|
+
|
16
|
+
graphql = File.join(base_dir,'/ecoportal-api-graphql/lib')
|
17
|
+
$LOAD_PATH.unshift File.expand_path(graphql)
|
18
|
+
require_relative File.expand_path(File.join(graphql, 'ecoportal/api-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.6
|
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-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -194,6 +194,8 @@ files:
|
|
194
194
|
- lib/ecoportal/api/common/graphql/doc_helpers.rb
|
195
195
|
- lib/ecoportal/api/common/graphql/hash_helpers.rb
|
196
196
|
- lib/ecoportal/api/common/graphql/http_client.rb
|
197
|
+
- lib/ecoportal/api/common/graphql/patches.rb
|
198
|
+
- lib/ecoportal/api/common/graphql/patches/query.rb
|
197
199
|
- lib/ecoportal/api/graphql.rb
|
198
200
|
- lib/ecoportal/api/graphql/base.rb
|
199
201
|
- lib/ecoportal/api/graphql/base/action.rb
|
@@ -220,6 +222,7 @@ files:
|
|
220
222
|
- lib/ecoportal/api/graphql/connection/contractor_entity.rb
|
221
223
|
- lib/ecoportal/api/graphql/connection/person_member.rb
|
222
224
|
- lib/ecoportal/api/graphql/fragment.rb
|
225
|
+
- lib/ecoportal/api/graphql/fragment/action.rb
|
223
226
|
- lib/ecoportal/api/graphql/fragment/contractor_entity.rb
|
224
227
|
- lib/ecoportal/api/graphql/fragment/pagination.rb
|
225
228
|
- lib/ecoportal/api/graphql/input.rb
|