ecoportal-api-graphql 1.3.4 → 1.3.5

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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -1
  3. data/ecoportal-api-graphql.gemspec +1 -1
  4. data/lib/ecoportal/api/common/graphql/auth_service.rb +12 -14
  5. data/lib/ecoportal/api/common/graphql/client.rb +10 -2
  6. data/lib/ecoportal/api/common/graphql/http_client.rb +86 -30
  7. data/lib/ecoportal/api/common/graphql.rb +1 -1
  8. data/lib/ecoportal/api/graphql/base/page/data_field.rb +12 -0
  9. data/lib/ecoportal/api/graphql/base/page/phased/stage.rb +14 -0
  10. data/lib/ecoportal/api/graphql/base/page/phased.rb +14 -0
  11. data/lib/ecoportal/api/graphql/base/page/section.rb +12 -0
  12. data/lib/ecoportal/api/graphql/base/page.rb +5 -1
  13. data/lib/ecoportal/api/graphql/base.rb +15 -15
  14. data/lib/ecoportal/api/graphql/builder/page.rb +41 -0
  15. data/lib/ecoportal/api/graphql/builder/register.rb +41 -0
  16. data/lib/ecoportal/api/graphql/builder.rb +5 -3
  17. data/lib/ecoportal/api/graphql/concerns/fragment_definitions.rb +75 -0
  18. data/lib/ecoportal/api/graphql/concerns.rb +10 -0
  19. data/lib/ecoportal/api/graphql/connection.rb +4 -4
  20. data/lib/ecoportal/api/graphql/error.rb +3 -3
  21. data/lib/ecoportal/api/graphql/fragment.rb +10 -54
  22. data/lib/ecoportal/api/graphql/helpers/locations_tree.rb +1 -0
  23. data/lib/ecoportal/api/graphql/helpers.rb +1 -1
  24. data/lib/ecoportal/api/graphql/input.rb +7 -7
  25. data/lib/ecoportal/api/graphql/logic/mutation.rb +6 -1
  26. data/lib/ecoportal/api/graphql/logic/query_array.rb +1 -0
  27. data/lib/ecoportal/api/graphql/logic/query_connection.rb +2 -0
  28. data/lib/ecoportal/api/graphql/logic.rb +9 -9
  29. data/lib/ecoportal/api/graphql/model/organization.rb +9 -6
  30. data/lib/ecoportal/api/graphql/model/page/data_field.rb +12 -0
  31. data/lib/ecoportal/api/graphql/model/page/phased/stage.rb +14 -0
  32. data/lib/ecoportal/api/graphql/model/page/phased.rb +20 -0
  33. data/lib/ecoportal/api/graphql/model/page/section.rb +12 -0
  34. data/lib/ecoportal/api/graphql/model/page.rb +5 -7
  35. data/lib/ecoportal/api/graphql/model/resource.rb +1 -1
  36. data/lib/ecoportal/api/graphql/model.rb +13 -13
  37. data/lib/ecoportal/api/graphql/mutation.rb +3 -3
  38. data/lib/ecoportal/api/graphql/payload.rb +3 -3
  39. data/lib/ecoportal/api/graphql/query/action_categories.rb +1 -0
  40. data/lib/ecoportal/api/graphql/query/contractor_entities.rb +1 -0
  41. data/lib/ecoportal/api/graphql/query.rb +7 -7
  42. data/lib/ecoportal/api/graphql.rb +12 -2
  43. data/lib/ecoportal/api/graphql_version.rb +1 -1
  44. data/tests/local_libs.rb +7 -7
  45. metadata +17 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5cc6136dc79d157acebf842f4b451e86a0f0266a5d239ad11dfa1f1db2f27ae7
4
- data.tar.gz: 0a484624cc89b965ecb36e33beeb24470041288167deb2d48f52933a2f5f1d46
3
+ metadata.gz: a601be8bd2712d265a92f530ea2737d1df427b73066daf3a7dd5eb4befdfb14d
4
+ data.tar.gz: 68152b23448092ec5da50a052c600ff5f768eb1ff5ae20db37de174af785ef3a
5
5
  SHA512:
6
- metadata.gz: aa8a69f025ff59c272b9b4285d76740d680e4a1757936ccc88383b9cda0335b1142842469cce72a330bc58bec970ca29ef1151b88761407f7938feeb4dbed220
7
- data.tar.gz: 5da6da6b51a4795ba03f148a7b50d73f2465aa1c424be3f5accaebcd8eae3e599c022132458eabc0448d66df31f990d9f66b8efb5886b51bdbb061351afda4e5
6
+ metadata.gz: 11ab235ee54f4a3c42986a5c1f5a066b4ed235c530ff7011bbf7d02cd30afe403d8d82c158aa1bd974a0b320f3bcbf52d19cfb45cfc5012b4c1cc1afb7ba30c4
7
+ data.tar.gz: 03c9e3ca74579879996c8a3edf44f03e240dcd79c6418a599fd4ff6eb05a2084d506037139207dcc8713f785fd23cf0f7486e829c8d87511127036235b7875f5
data/CHANGELOG.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
- ## [1.3.5] - 2025-09-xx
5
+ ## [1.3.6] - 2026-05-26
6
6
 
7
7
  ### Added
8
8
 
@@ -10,6 +10,13 @@ All notable changes to this project will be documented in this file.
10
10
 
11
11
  ### Fixed
12
12
 
13
+ ## [1.3.5] - 2026-05-26
14
+
15
+ ### Changed
16
+
17
+ - Moved `graphql` endpoint to `external/graphql`
18
+ - Missing env var (i.e. `ORG_ID`) will **raise** now an error (instead of just a print)
19
+
13
20
  ## [1.3.4] - 2025-09-04
14
21
 
15
22
  ### Added
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
32
32
  spec.add_development_dependency 'rubocop-rake', '~> 0'
33
33
  spec.add_development_dependency 'yard', '>= 0.9.34', '< 1'
34
34
 
35
- spec.add_dependency 'ecoportal-api', '~> 0.10', '>= 0.10.14'
35
+ spec.add_dependency 'ecoportal-api', '~> 0.10', '>= 0.10.15'
36
36
  spec.add_dependency 'ecoportal-api-v2', '~> 3.3', '>= 3.3.1'
37
37
  spec.add_dependency 'graphlient', '>= 0.8.0', '< 0.9'
38
38
  end
@@ -7,14 +7,13 @@ module Ecoportal
7
7
  TOKEN_AUTORENEW = 90 # minutes
8
8
 
9
9
  module InstanceMethods
10
- def session_token(host: server, version: nil, auto_renew: true)
11
- session_token_data(host: host, version: version).then do |body|
10
+ def session_token(host: server, auto_renew: true)
11
+ session_token_data(host: host).then do |body|
12
12
  next unless body
13
13
 
14
14
  if auto_renew && token_renew?(body['expires_in'])
15
15
  session_token_renewed(
16
16
  host: host,
17
- version: version,
18
17
  refresh_token: body['refresh_token']
19
18
  )
20
19
  else
@@ -23,15 +22,14 @@ module Ecoportal
23
22
  end
24
23
  end
25
24
 
26
- def session_token_renewed(host: server, version: nil, refresh_token: nil)
25
+ def session_token_renewed(host: server, refresh_token: nil)
27
26
  unless refresh_token
28
- return unless (body = session_token_data(host: host, version: version))
27
+ return unless (body = session_token_data(host: host))
29
28
  return unless (refresh_token = body['resfresh_token'])
30
29
  end
31
30
 
32
31
  session_refresh_token_data(
33
32
  host: host,
34
- version: version,
35
33
  refresh_token: refresh_token
36
34
  ).then do |bdy|
37
35
  bdy['access_token'] if bdy
@@ -40,8 +38,8 @@ module Ecoportal
40
38
 
41
39
  private
42
40
 
43
- def session_token_data(host: server, version: nil)
44
- http_client(host: host, version: version).post(
41
+ def session_token_data(host: server)
42
+ auth_http_client(host: host).post(
45
43
  '/oauth/token',
46
44
  data: {
47
45
  'grant_type' => 'password',
@@ -53,8 +51,8 @@ module Ecoportal
53
51
  end
54
52
  end
55
53
 
56
- def session_refresh_token_data(refresh_token:, host: server, version: nil)
57
- http_client(host: host, version: version).post(
54
+ def session_refresh_token_data(refresh_token:, host: server)
55
+ auth_http_client(host: host).post(
58
56
  '/oauth/token',
59
57
  data: {
60
58
  'grant_type' => 'refresh_token',
@@ -69,10 +67,10 @@ module Ecoportal
69
67
  (TOKEN_AUTORENEW * 60) > seconds
70
68
  end
71
69
 
72
- def http_client(host: server, version: nil)
73
- @http_client ||= Ecoportal::API::Common::GraphQL::HttpClient.new(
70
+ def auth_http_client(host: server)
71
+ @auth_http_client ||= Ecoportal::API::Common::GraphQL::HttpClient.new(
74
72
  host: host,
75
- version: version
73
+ version: 'http'
76
74
  )
77
75
  end
78
76
 
@@ -89,7 +87,7 @@ module Ecoportal
89
87
  end
90
88
 
91
89
  def fetch_env_required(name)
92
- abort("Missing ENV '#{name}'") unless ENV.key?(name)
90
+ raise "Missing ENV '#{name}'" unless ENV.key?(name)
93
91
  ENV[name]
94
92
  end
95
93
 
@@ -4,6 +4,8 @@ module Ecoportal
4
4
  module Common
5
5
  module GraphQL
6
6
  class Client < ::Graphlient::Client
7
+ ENDPOINT_PATH = 'external/graphql'.freeze
8
+
7
9
  attr_accessor :host
8
10
 
9
11
  READ_TIMEOUT = 90
@@ -42,7 +44,12 @@ module Ecoportal
42
44
  end
43
45
 
44
46
  def new(org_id: self.org_id, host: self.host, schema_path: host, no_schema: @no_schema)
45
- self.class.new(org_id: org_id, host: host, schema_path: schema_path, no_schema: no_schema)
47
+ self.class.new(
48
+ org_id: org_id,
49
+ host: host,
50
+ schema_path: schema_path,
51
+ no_schema: no_schema
52
+ )
46
53
  end
47
54
 
48
55
  def org_id
@@ -52,7 +59,8 @@ module Ecoportal
52
59
  private
53
60
 
54
61
  def url
55
- "#{Ecoportal::API::Common::GraphQL::HttpClient.base_url(host)}/api/#{org_id}/graphql"
62
+ base_url = Ecoportal::API::Common::GraphQL::HttpClient.base_url(host)
63
+ "#{base_url}/api/#{org_id}/#{ENDPOINT_PATH}"
56
64
  end
57
65
  end
58
66
  end
@@ -13,20 +13,36 @@ module Ecoportal
13
13
  end
14
14
  end
15
15
 
16
+ READ_TIMEOUT = 90
17
+ WRITE_TIMEOUT = 90
18
+
16
19
  attr_reader :host, :version
17
20
 
21
+ include Ecoportal::API::Common::GraphQL::AuthService
22
+
18
23
  def initialize(
24
+ email: nil,
25
+ pass: nil,
26
+ org_id: nil,
19
27
  api_key: nil,
20
- version: nil,
28
+ version: 'graphql',
21
29
  host: 'live.ecoportal.com',
22
30
  logger: ::Logger.new(IO::NULL),
23
- deep_logging: false
31
+ deep_logging: false,
32
+ no_schema: true
24
33
  )
25
- super
26
- end
34
+ @org_id = org_id
35
+ @user_email = email
36
+ @user_pass = pass
37
+ @no_schema = no_schema
38
+ @version = version
27
39
 
28
- def refresh_key(value)
29
- @api_key = value
40
+ super(
41
+ api_key: api_key,
42
+ host: host,
43
+ logger: logger,
44
+ deep_logging: deep_logging
45
+ )
30
46
  end
31
47
 
32
48
  # Creates a HTTP object adding the `X-ApiKey` or `X-ECOPORTAL-API-KEY` param to the header, depending on the API version.
@@ -35,52 +51,92 @@ module Ecoportal
35
51
  def base_request
36
52
  @base_request ||=
37
53
  case @version
38
- when NilClass
39
- HTTP.accept(:json)
40
- when 'v2'
41
- HTTP.headers('X-ECOPORTAL-API-KEY' => key_token).accept(:json)
54
+ when NilClass, 'http'
55
+ HTTP
56
+ when 'v1', 'v0'
57
+ HTTP.headers('X-ApiKey' => key_token)
58
+ when 'v2', 'v3'
59
+ HTTP.headers('X-ECOPORTAL-API-KEY' => key_token)
42
60
  when 'graphql'
43
- HTTP.headers('Authorization' => "Bearer #{key_token}").accept(:json)
44
- else
45
- HTTP.headers('X-ApiKey' => key_token).accept(:json)
61
+ HTTP.headers('Authorization' => "Bearer #{key_token}")
62
+ end.then do |request|
63
+ request.accept(:json).timeout(
64
+ read: READ_TIMEOUT,
65
+ write: WRITE_TIMEOUT
66
+ )
46
67
  end
47
68
  end
48
69
 
70
+ def org_id
71
+ @org_id || fetch_env_required('ORGANIZATION_ID')
72
+ end
73
+
49
74
  # Full URl builder of the request
50
75
  # @param path [String] the tail that completes the url of the request.
51
76
  # @return [String] the final url.
52
77
  def url_for(path)
53
- version? ? "#{base_url_api}#{path}" : "#{base_url}#{path}"
78
+ "#{api_url}#{path}"
54
79
  end
55
80
 
56
81
  private
57
82
 
58
- def version?
59
- !!@version
83
+ def key_token
84
+ return if http?
85
+ return session_token(host: host) if graphql?
86
+ return @api_key if api_key?
87
+ return ENV['ORG_INT_KEY'] if v0?
88
+
89
+ puts 'Api-key missing!'
60
90
  end
61
91
 
62
- def protocol
63
- @protocol ||= self.class.protocol(host)
92
+ def api_url
93
+ base_url.then do |url|
94
+ next "#{url}/api/#{version}" if v1_0? || v2_3?
95
+ next "#{url}/api/#{org_id}/graphql" if graphql?
96
+
97
+ url
98
+ end
64
99
  end
65
100
 
66
101
  def base_url
67
102
  @base_url ||= self.class.base_url(host)
68
103
  end
69
104
 
70
- def base_url_api
71
- @base_url_api ||= "#{base_url}/api/#{version}"
105
+ def protocol
106
+ @protocol ||= self.class.protocol(host)
72
107
  end
73
108
 
74
- def key_token
75
- if @api_key.nil? || @api_key.match(/\A\W*\z/)
76
- if (version == 'v0') && (key = ENV['ORG_INT_KEY'])
77
- key
78
- elsif !version.nil?
79
- puts 'Api-key missing!'
80
- end
81
- else
82
- @api_key
83
- end
109
+ def http?
110
+ return true if @version.nil?
111
+
112
+ @version == 'http'
113
+ end
114
+
115
+ def api_key?
116
+ @api_key && !@api_key.match(/\A\W*\z/)
117
+ end
118
+
119
+ def v1_0?
120
+ v1? || v0?
121
+ end
122
+
123
+ def v1?
124
+ @version == 'v1'
125
+ end
126
+
127
+ def v0?
128
+ @version == 'v0'
129
+ end
130
+
131
+ def v2_3?
132
+ return true if @version == 'v2'
133
+ return true if @version == 'v3'
134
+
135
+ false
136
+ end
137
+
138
+ def graphql?
139
+ @version == 'graphql'
84
140
  end
85
141
  end
86
142
  end
@@ -7,8 +7,8 @@ module Ecoportal
7
7
  end
8
8
  end
9
9
 
10
- require 'ecoportal/api/common/graphql/http_client'
11
10
  require 'ecoportal/api/common/graphql/auth_service'
11
+ require 'ecoportal/api/common/graphql/http_client'
12
12
  require 'ecoportal/api/common/graphql/client'
13
13
  require 'ecoportal/api/common/graphql/class_helpers'
14
14
  require 'ecoportal/api/common/graphql/hash_helpers'
@@ -0,0 +1,12 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Base
5
+ module Page
6
+ class DataField < Logic::BaseModel
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,14 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Base
5
+ module Page
6
+ class Phased
7
+ class Stage < Logic::BaseModel
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Base
5
+ module Page
6
+ class Phased < Interface::BasePage
7
+ require_relative 'phased/stage'
8
+
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,12 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Base
5
+ module Page
6
+ class Section < Logic::BaseModel
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -2,9 +2,13 @@ module Ecoportal
2
2
  module API
3
3
  class GraphQL
4
4
  module Base
5
- class Page < Interface::BasePage
5
+ module Page
6
6
  end
7
7
  end
8
8
  end
9
9
  end
10
10
  end
11
+
12
+ require_relative 'page/data_field'
13
+ require_relative 'page/section'
14
+ require_relative 'page/phased'
@@ -7,18 +7,18 @@ module Ecoportal
7
7
  end
8
8
  end
9
9
 
10
- require 'ecoportal/api/graphql/base/date_time'
11
- require 'ecoportal/api/graphql/base/page_info'
12
- require 'ecoportal/api/graphql/base/location_classification_type'
13
- require 'ecoportal/api/graphql/base/location_node'
14
- require 'ecoportal/api/graphql/base/location_structure'
15
- require 'ecoportal/api/graphql/base/person_member'
16
- require 'ecoportal/api/graphql/base/file_attachment'
17
- require 'ecoportal/api/graphql/base/file_container'
18
- require 'ecoportal/api/graphql/base/field'
19
- require 'ecoportal/api/graphql/base/page'
20
- require 'ecoportal/api/graphql/base/resource'
21
- require 'ecoportal/api/graphql/base/action_category'
22
- require 'ecoportal/api/graphql/base/action'
23
- require 'ecoportal/api/graphql/base/contractor_entity'
24
- require 'ecoportal/api/graphql/base/organization'
10
+ require_relative 'base/date_time'
11
+ require_relative 'base/page_info'
12
+ require_relative 'base/location_classification_type'
13
+ require_relative 'base/location_node'
14
+ require_relative 'base/location_structure'
15
+ require_relative 'base/person_member'
16
+ require_relative 'base/file_attachment'
17
+ require_relative 'base/file_container'
18
+ require_relative 'base/field'
19
+ require_relative 'base/page'
20
+ require_relative 'base/resource'
21
+ require_relative 'base/action_category'
22
+ require_relative 'base/action'
23
+ require_relative 'base/contractor_entity'
24
+ require_relative 'base/organization'
@@ -0,0 +1,41 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Builder
5
+ class Page
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
+ # def update(**kargs, &block)
17
+ # updateMutation.query(**kargs, &block)
18
+ # end
19
+
20
+ # def create(**kargs, &block)
21
+ # createMutation.query(**kargs, &block)
22
+ # end
23
+
24
+ private
25
+
26
+ # def archiveMutation
27
+ # Mutation::Page::Archive.new(client)
28
+ # end
29
+
30
+ # def updateMutation
31
+ # Mutation::Page::Update.new(client)
32
+ # end
33
+
34
+ # def createMutation
35
+ # Mutation::Page::Create.new(client)
36
+ # end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,41 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Builder
5
+ class Register
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
+ # def update(**kargs, &block)
17
+ # updateMutation.query(**kargs, &block)
18
+ # end
19
+
20
+ # def create(**kargs, &block)
21
+ # createMutation.query(**kargs, &block)
22
+ # end
23
+
24
+ private
25
+
26
+ # def archiveMutation
27
+ # Mutation::Register::Archive.new(client)
28
+ # end
29
+
30
+ # def updateMutation
31
+ # Mutation::Register::Update.new(client)
32
+ # end
33
+
34
+ # def createMutation
35
+ # Mutation::Register::Create.new(client)
36
+ # end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -7,6 +7,8 @@ module Ecoportal
7
7
  end
8
8
  end
9
9
 
10
- require 'ecoportal/api/graphql/builder/location_structure'
11
- require 'ecoportal/api/graphql/builder/action'
12
- require 'ecoportal/api/graphql/builder/contractor_entity'
10
+ require_relative 'builder/location_structure'
11
+ require_relative 'builder/action'
12
+ require_relative 'builder/contractor_entity'
13
+ require_relative 'builder/register'
14
+ require_relative 'builder/page'
@@ -0,0 +1,75 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Concerns
5
+ module FragmentDefinitions
6
+
7
+ class << self
8
+ private
9
+
10
+ def included(base)
11
+ super
12
+
13
+ base.send :include, Ecoportal::API::Common::GraphQL::ClassHelpers
14
+ base.extend ClassMethods
15
+ base.send :include, InstanceMethods
16
+ end
17
+ end
18
+
19
+ module ClassMethods
20
+ def fragment(sym, heredoc)
21
+ fragments[sym] = heredoc
22
+ end
23
+
24
+ def fragments
25
+ @fragments ||= {}
26
+ end
27
+ end
28
+
29
+ module InstanceMethods
30
+ attr_reader :client, :fragments
31
+
32
+ def initialize(client)
33
+ @client = client
34
+ parse
35
+ end
36
+
37
+ def define(sym, heredoc, namespace: ::Fragment)
38
+ namespace.send(:remove_const, sym) if namespace.const_defined?(sym)
39
+
40
+ client.parse(heredoc).tap do |fragment|
41
+ without_warnings do
42
+ namespace.const_set(sym, fragment)
43
+ end
44
+ end
45
+ rescue ::GraphQL::Client::ValidationError, ::Graphlient::Errors::ClientError => err
46
+ raise err.class, "On fragment #{sym} -- #{err.message}", cause: nil
47
+ end
48
+
49
+ private
50
+
51
+ def without_warnings
52
+ original_verbose = $VERBOSE
53
+ $VERBOSE = nil
54
+
55
+ yield if block_given?
56
+ ensure
57
+ $VERBOSE = original_verbose
58
+ end
59
+
60
+ def parse
61
+ @fragments = self.class.fragments.
62
+ each_with_object({}) do |(sym, heredoc), out|
63
+ out[sym] = define(
64
+ sym,
65
+ heredoc,
66
+ namespace: self.class
67
+ )
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,10 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Concerns
5
+ end
6
+ end
7
+ end
8
+ end
9
+
10
+ require_relative 'concerns/fragment_definitions'
@@ -7,7 +7,7 @@ module Ecoportal
7
7
  end
8
8
  end
9
9
 
10
- require 'ecoportal/api/graphql/connection/person_member'
11
- require 'ecoportal/api/graphql/connection/contractor_entity'
12
- require 'ecoportal/api/graphql/connection/action_category'
13
- require 'ecoportal/api/graphql/connection/action'
10
+ require_relative 'connection/person_member'
11
+ require_relative 'connection/contractor_entity'
12
+ require_relative 'connection/action_category'
13
+ require_relative 'connection/action'
@@ -7,6 +7,6 @@ module Ecoportal
7
7
  end
8
8
  end
9
9
 
10
- require 'ecoportal/api/graphql/error/locations_validation_error'
11
- require 'ecoportal/api/graphql/error/validation_errors'
12
- require 'ecoportal/api/graphql/error/locations_error'
10
+ require_relative 'error/locations_validation_error'
11
+ require_relative 'error/validation_errors'
12
+ require_relative 'error/locations_error'
@@ -8,64 +8,20 @@ module Ecoportal
8
8
  module API
9
9
  class GraphQL
10
10
  class Fragment
11
- include Ecoportal::API::Common::GraphQL::ClassHelpers
11
+ include Ecoportal::API::GraphQL::Concerns::FragmentDefinitions
12
12
 
13
- class << self
14
- def fragment(sym, heredoc)
15
- fragments[sym] = heredoc
16
- end
17
-
18
- def fragments
19
- @fragments ||= {}
20
- end
21
- end
22
-
23
- attr_reader :client, :fragments
24
-
25
- def initialize(client)
26
- @client = client
27
- parse
28
- end
29
-
30
- def define(sym, heredoc, namespace: ::Fragment)
31
- namespace.send(:remove_const, sym) if namespace.const_defined?(sym)
32
-
33
- client.parse(heredoc).tap do |fragment|
34
- without_warnings do
35
- namespace.const_set(sym, fragment)
36
- ::Fragment.const_set(sym, fragment) unless namespace == ::Fragment
37
- end
38
- end
39
- rescue ::GraphQL::Client::ValidationError, ::Graphlient::Errors::ClientError => err
40
- raise err.class, "On fragment #{sym} -- #{err.message}", cause: nil
41
- end
42
-
43
- private
44
-
45
- def without_warnings
46
- original_verbose = $VERBOSE
47
- $VERBOSE = nil
48
-
49
- yield if block_given?
50
- ensure
51
- $VERBOSE = original_verbose
52
- end
53
-
54
- def parse
55
- @fragments = self.class.fragments.
56
- each_with_object({}) do |(sym, heredoc), out|
57
- out[sym] = define(sym, heredoc, namespace: self.class)
58
- end
13
+ def initialize(...)
14
+ super(...)
59
15
  end
60
16
  end
61
17
  end
62
18
  end
63
19
  end
64
20
 
65
- require 'ecoportal/api/graphql/fragment/pagination'
66
- require 'ecoportal/api/graphql/fragment/locations_error'
67
- require 'ecoportal/api/graphql/fragment/location_node'
68
- require 'ecoportal/api/graphql/fragment/location_draft'
69
- require 'ecoportal/api/graphql/fragment/action_category'
70
- require 'ecoportal/api/graphql/fragment/action'
71
- require 'ecoportal/api/graphql/fragment/contractor_entity'
21
+ require_relative 'fragment/pagination'
22
+ require_relative 'fragment/locations_error'
23
+ require_relative 'fragment/location_node'
24
+ require_relative 'fragment/location_draft'
25
+ require_relative 'fragment/action_category'
26
+ require_relative 'fragment/action'
27
+ require_relative 'fragment/contractor_entity'
@@ -9,6 +9,7 @@ module Ecoportal
9
9
  parents = nodes.each_with_object({}) do |node, out|
10
10
  (out[node.parent_id_upcase] ||= []).push(node)
11
11
  end
12
+
12
13
  get_children(nil, parents)
13
14
  end
14
15
 
@@ -7,4 +7,4 @@ module Ecoportal
7
7
  end
8
8
  end
9
9
 
10
- require 'ecoportal/api/graphql/helpers/locations_tree'
10
+ require_relative 'helpers/locations_tree'
@@ -7,10 +7,10 @@ module Ecoportal
7
7
  end
8
8
  end
9
9
 
10
- require 'ecoportal/api/graphql/input/id_diff'
11
- require 'ecoportal/api/graphql/input/search_filter'
12
- require 'ecoportal/api/graphql/input/search_sorter'
13
- require 'ecoportal/api/graphql/input/search'
14
- require 'ecoportal/api/graphql/input/location_structure'
15
- require 'ecoportal/api/graphql/input/contractor_entity'
16
- require 'ecoportal/api/graphql/input/action'
10
+ require_relative 'input/id_diff'
11
+ require_relative 'input/search_filter'
12
+ require_relative 'input/search_sorter'
13
+ require_relative 'input/search'
14
+ require_relative 'input/location_structure'
15
+ require_relative 'input/contractor_entity'
16
+ require_relative 'input/action'
@@ -23,7 +23,12 @@ module Ecoportal
23
23
  # Query rely that manages the different blocks.
24
24
  # @return [Class] an object of `response_class` with the results hanving from `path`.
25
25
  def query(input:, path: self.path, **kargs, &block)
26
- super(input: as_input(input), path: path, **kargs, &block)
26
+ super(
27
+ input: as_input(input),
28
+ path: path,
29
+ **kargs,
30
+ &block
31
+ )
27
32
  end
28
33
 
29
34
  def response_class
@@ -7,6 +7,7 @@ module Ecoportal
7
7
 
8
8
  def each(item_block: nil, **kargs, &block)
9
9
  return to_enum(:each, item_block: connection_block, **kargs) unless block
10
+
10
11
  query(**kargs, &item_block).each do |item|
11
12
  yield(item) if block_given?
12
13
  end
@@ -18,7 +18,9 @@ module Ecoportal
18
18
  #total = connection.totalCount
19
19
  page_info = connection.pageInfo
20
20
  connection.nodes.each(&block)
21
+
21
22
  break unless (cursor = page_info.endCursor)
23
+ # break unless page_info.hasNextPage
22
24
  end
23
25
  end
24
26
 
@@ -7,12 +7,12 @@ module Ecoportal
7
7
  end
8
8
  end
9
9
 
10
- require 'ecoportal/api/graphql/logic/base_model'
11
- require 'ecoportal/api/graphql/logic/base_query'
12
- require 'ecoportal/api/graphql/logic/query'
13
- require 'ecoportal/api/graphql/logic/mutation'
14
- require 'ecoportal/api/graphql/logic/connection'
15
- require 'ecoportal/api/graphql/logic/query_array'
16
- require 'ecoportal/api/graphql/logic/query_connection'
17
- require 'ecoportal/api/graphql/logic/payload'
18
- require 'ecoportal/api/graphql/logic/input'
10
+ require_relative 'logic/base_model'
11
+ require_relative 'logic/base_query'
12
+ require_relative 'logic/query'
13
+ require_relative 'logic/mutation'
14
+ require_relative 'logic/connection'
15
+ require_relative 'logic/query_array'
16
+ require_relative 'logic/query_connection'
17
+ require_relative 'logic/payload'
18
+ require_relative 'logic/input'
@@ -11,7 +11,10 @@ module Ecoportal
11
11
  extend Ecoportal::API::Common::GraphQL::QueryIntegration
12
12
 
13
13
  def path(*add)
14
- DEFAULT_PATH.dup.push(*add)
14
+ return @path if add.empty? && instance_variable_defined?(:@path)
15
+
16
+ @path ||= self::DEFAULT_PATH.dup
17
+ @path = @path.push(*add)
15
18
  end
16
19
 
17
20
  query :locationStructure,
@@ -35,13 +38,13 @@ module Ecoportal
35
38
  query_klass: 'Ecoportal::API::GraphQL::Query::Actions'
36
39
  query :archiveAction,
37
40
  query_klass: 'Ecoportal::API::GraphQL::Mutation::Action::Archive'
38
- #action, actionsByPage, actionsCounter
39
- #actionCategories
41
+ # actionsByPage, actionsCounter
40
42
 
41
- #userGroup, userGroups
43
+ # userGroup, userGroups
44
+ # personMembers, attachablePersonMembers
42
45
 
43
- #register, registers
44
- #personMembers, attachablePersonMembers
46
+ # register, registers
47
+ # page, pages
45
48
  end
46
49
  end
47
50
  end
@@ -0,0 +1,12 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Model
5
+ module Page
6
+ class DataField < Base::Page::DataField
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,14 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Model
5
+ module Page
6
+ class Phased
7
+ class Stage < Base::Page::Phased::Stage
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,20 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Model
5
+ module Page
6
+ class Phased < Base::Page::Phased
7
+ require_relative 'phased/stage'
8
+
9
+ class_resolver :user_class, 'Ecoportal::API::GraphQL::Model::User'
10
+ # class_resolver :force_class, 'Ecoportal::API::GraphQL::Model::Force'
11
+ # class_resolver :theme_class, 'Ecoportal::API::GraphQL::Model::Theme'
12
+ # class_resolver :template_class, 'Ecoportal::API::GraphQL::Model::Template'
13
+ # class_resolver :register_class, 'Ecoportal::API::GraphQL::Model::Register'
14
+ class_resolver :organization_class, 'Ecoportal::API::GraphQL::Model::Organization'
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,12 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Model
5
+ module Page
6
+ class Section < Base::Page::Section
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -2,15 +2,13 @@ module Ecoportal
2
2
  module API
3
3
  class GraphQL
4
4
  module Model
5
- class Page < Base::Page
6
- class_resolver :user_class, 'Ecoportal::API::GraphQL::Model::User'
7
- # class_resolver :force_class, 'Ecoportal::API::GraphQL::Model::Force'
8
- # class_resolver :theme_class, 'Ecoportal::API::GraphQL::Model::Theme'
9
- # class_resolver :template_class, 'Ecoportal::API::GraphQL::Model::Template'
10
- # class_resolver :register_class, 'Ecoportal::API::GraphQL::Model::Register'
11
- class_resolver :organization_class, 'Ecoportal::API::GraphQL::Model::Organization'
5
+ module Page
12
6
  end
13
7
  end
14
8
  end
15
9
  end
16
10
  end
11
+
12
+ require_relative 'page/data_field'
13
+ require_relative 'page/section'
14
+ require_relative 'page/phased'
@@ -3,7 +3,7 @@ module Ecoportal
3
3
  class GraphQL
4
4
  module Model
5
5
  class Resource < Base::Resource
6
- embeds_one :page, klass: 'Ecoportal::API::GraphQL::Model::Page', read_only: true # PageUnion
6
+ embeds_one :page, klass: 'Ecoportal::API::GraphQL::Model::Page::Phased', read_only: true # PageUnion
7
7
  embeds_one :field, klass: 'Ecoportal::API::GraphQL::Model::Field', read_only: true
8
8
  # embeds_many :stages, klass: 'Ecoportal::API::GraphQL::Model::SimpleStage'
9
9
  end
@@ -7,16 +7,16 @@ module Ecoportal
7
7
  end
8
8
  end
9
9
 
10
- require 'ecoportal/api/graphql/model/location_node'
11
- require 'ecoportal/api/graphql/model/location_structure'
12
- require 'ecoportal/api/graphql/model/account'
13
- require 'ecoportal/api/graphql/model/user'
14
- require 'ecoportal/api/graphql/model/person_member'
15
- require 'ecoportal/api/graphql/model/file_attachment'
16
- require 'ecoportal/api/graphql/model/file_container'
17
- require 'ecoportal/api/graphql/model/field'
18
- require 'ecoportal/api/graphql/model/page'
19
- require 'ecoportal/api/graphql/model/resource'
20
- require 'ecoportal/api/graphql/model/action'
21
- require 'ecoportal/api/graphql/model/contractor_entity'
22
- require 'ecoportal/api/graphql/model/organization'
10
+ require_relative 'model/location_node'
11
+ require_relative 'model/location_structure'
12
+ require_relative 'model/account'
13
+ require_relative 'model/user'
14
+ require_relative 'model/person_member'
15
+ require_relative 'model/file_attachment'
16
+ require_relative 'model/file_container'
17
+ require_relative 'model/field'
18
+ require_relative 'model/page'
19
+ require_relative 'model/resource'
20
+ require_relative 'model/action'
21
+ require_relative 'model/contractor_entity'
22
+ require_relative 'model/organization'
@@ -7,6 +7,6 @@ module Ecoportal
7
7
  end
8
8
  end
9
9
 
10
- require 'ecoportal/api/graphql/mutation/location_structure'
11
- require 'ecoportal/api/graphql/mutation/contractor_entity'
12
- require 'ecoportal/api/graphql/mutation/action'
10
+ require_relative 'mutation/location_structure'
11
+ require_relative 'mutation/contractor_entity'
12
+ require_relative 'mutation/action'
@@ -7,6 +7,6 @@ module Ecoportal
7
7
  end
8
8
  end
9
9
 
10
- require 'ecoportal/api/graphql/payload/location_structure'
11
- require 'ecoportal/api/graphql/payload/contractor_entity'
12
- require 'ecoportal/api/graphql/payload/action'
10
+ require_relative 'payload/location_structure'
11
+ require_relative 'payload/contractor_entity'
12
+ require_relative 'payload/action'
@@ -39,6 +39,7 @@ module Ecoportal
39
39
  totalCount
40
40
  pageInfo {
41
41
  endCursor
42
+ hasNextPage
42
43
  }
43
44
  nodes {
44
45
  ___Ecoportal__API__GraphQL__Fragment__ActionCategory
@@ -39,6 +39,7 @@ module Ecoportal
39
39
  totalCount
40
40
  pageInfo {
41
41
  endCursor
42
+ hasNextPage
42
43
  }
43
44
  nodes {
44
45
  ___Ecoportal__API__GraphQL__Fragment__ContractorEntity
@@ -7,10 +7,10 @@ module Ecoportal
7
7
  end
8
8
  end
9
9
 
10
- require 'ecoportal/api/graphql/query/location_classifications'
11
- require 'ecoportal/api/graphql/query/location_structure'
12
- require 'ecoportal/api/graphql/query/location_structures'
13
- require 'ecoportal/api/graphql/query/action_categories'
14
- require 'ecoportal/api/graphql/query/action'
15
- require 'ecoportal/api/graphql/query/actions'
16
- require 'ecoportal/api/graphql/query/contractor_entities'
10
+ require_relative 'query/location_classifications'
11
+ require_relative 'query/location_structure'
12
+ require_relative 'query/location_structures'
13
+ require_relative 'query/action_categories'
14
+ require_relative 'query/action'
15
+ require_relative 'query/actions'
16
+ require_relative 'query/contractor_entities'
@@ -5,6 +5,8 @@ module Ecoportal
5
5
  class GraphQL
6
6
  include Ecoportal::API::Common::GraphQL::ClassHelpers
7
7
 
8
+ class_resolver :client_class, Ecoportal::API::Common::GraphQL::Client
9
+
8
10
  attr_reader :client, :fragments
9
11
 
10
12
  # Creates a `GraphQL` object to interact with the ecoPortal `GraphQL API`.
@@ -12,8 +14,15 @@ module Ecoportal
12
14
  # It defaults to the environmental variable `ORGANIZATION_ID`, if defined
13
15
  # @param logger [Logger] an object with `Logger` interface to generate logs.
14
16
  def initialize(email: nil, pass: nil, org_id: nil, host: "live.ecoportal.com")
15
- kargs = {email: email, pass: pass, host: host, org_id: org_id, no_schema: true}
16
- @client = Ecoportal::API::Common::GraphQL::Client.new(**kargs)
17
+ kargs = {
18
+ email: email,
19
+ pass: pass,
20
+ host: host,
21
+ org_id: org_id,
22
+ no_schema: true
23
+ }
24
+
25
+ @client = client_class.new(**kargs)
17
26
  @fragments = Ecoportal::API::GraphQL::Fragment.new(client)
18
27
  end
19
28
 
@@ -55,6 +64,7 @@ module Ecoportal
55
64
  end
56
65
 
57
66
  require_relative 'graphql/helpers'
67
+ require_relative 'graphql/concerns'
58
68
  require_relative 'graphql/logic/base_model'
59
69
  require_relative 'graphql/error'
60
70
  require_relative 'graphql/interface'
@@ -1,5 +1,5 @@
1
1
  module Ecoportal
2
2
  module API
3
- GRAPQL_VERSION = '1.3.4'.freeze
3
+ GRAPQL_VERSION = '1.3.5'.freeze
4
4
  end
5
5
  end
data/tests/local_libs.rb CHANGED
@@ -1,20 +1,20 @@
1
1
  require 'byebug'
2
2
  base_dir = 'C:/ruby_scripts/git'
3
3
 
4
- api_path = File.join(base_dir,'/ecoportal-api/lib')
4
+ api_path = File.join(base_dir, '/ecoportal-api/lib')
5
5
  $LOAD_PATH.unshift File.expand_path(api_path)
6
6
  #require 'ecoportal/api'
7
- api_req = File.join(base_dir,'/ecoportal-api/lib/ecoportal/api')
7
+ api_req = File.join(base_dir, '/ecoportal-api/lib/ecoportal/api')
8
8
  require api_req
9
9
 
10
- api_v2_path = File.join(base_dir,'/ecoportal-api-v2/lib')
10
+ api_v2_path = File.join(base_dir, '/ecoportal-api-v2/lib')
11
11
  $LOAD_PATH.unshift File.expand_path(api_v2_path)
12
12
  #require 'ecoportal/api-v2'
13
- require File.join(base_dir,'/ecoportal-api-v2/lib/ecoportal/api-v2')
13
+ require File.join(base_dir, '/ecoportal-api-v2/lib/ecoportal/api-v2')
14
14
 
15
- $LOAD_PATH.unshift File.join(base_dir,'/graphlient/lib')
16
- require File.join(base_dir,'/graphlient/lib/graphlient')
15
+ $LOAD_PATH.unshift File.join(base_dir, '/graphlient/lib')
16
+ require File.join(base_dir, '/graphlient/lib/graphlient')
17
17
 
18
- graphql = File.join(base_dir,'/ecoportal-api-graphql/lib')
18
+ graphql = File.join(base_dir, '/ecoportal-api-graphql/lib')
19
19
  $LOAD_PATH.unshift File.expand_path(graphql)
20
20
  require_relative File.expand_path(File.join(graphql, 'ecoportal/api-graphql'))
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecoportal-api-graphql
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
4
+ version: 1.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2025-09-04 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: pry
@@ -141,7 +140,7 @@ dependencies:
141
140
  version: '0.10'
142
141
  - - ">="
143
142
  - !ruby/object:Gem::Version
144
- version: 0.10.14
143
+ version: 0.10.15
145
144
  type: :runtime
146
145
  prerelease: false
147
146
  version_requirements: !ruby/object:Gem::Requirement
@@ -151,7 +150,7 @@ dependencies:
151
150
  version: '0.10'
152
151
  - - ">="
153
152
  - !ruby/object:Gem::Version
154
- version: 0.10.14
153
+ version: 0.10.15
155
154
  - !ruby/object:Gem::Dependency
156
155
  name: ecoportal-api-v2
157
156
  requirement: !ruby/object:Gem::Requirement
@@ -192,7 +191,6 @@ dependencies:
192
191
  - - "<"
193
192
  - !ruby/object:Gem::Version
194
193
  version: '0.9'
195
- description:
196
194
  email:
197
195
  - oscar@ecoportal.co.nz
198
196
  executables: []
@@ -248,6 +246,10 @@ files:
248
246
  - lib/ecoportal/api/graphql/base/location_structure/draft/structure.rb
249
247
  - lib/ecoportal/api/graphql/base/organization.rb
250
248
  - lib/ecoportal/api/graphql/base/page.rb
249
+ - lib/ecoportal/api/graphql/base/page/data_field.rb
250
+ - lib/ecoportal/api/graphql/base/page/phased.rb
251
+ - lib/ecoportal/api/graphql/base/page/phased/stage.rb
252
+ - lib/ecoportal/api/graphql/base/page/section.rb
251
253
  - lib/ecoportal/api/graphql/base/page_info.rb
252
254
  - lib/ecoportal/api/graphql/base/person_member.rb
253
255
  - lib/ecoportal/api/graphql/base/resource.rb
@@ -256,6 +258,10 @@ files:
256
258
  - lib/ecoportal/api/graphql/builder/contractor_entity.rb
257
259
  - lib/ecoportal/api/graphql/builder/location_structure.rb
258
260
  - lib/ecoportal/api/graphql/builder/location_structure/draft.rb
261
+ - lib/ecoportal/api/graphql/builder/page.rb
262
+ - lib/ecoportal/api/graphql/builder/register.rb
263
+ - lib/ecoportal/api/graphql/concerns.rb
264
+ - lib/ecoportal/api/graphql/concerns/fragment_definitions.rb
259
265
  - lib/ecoportal/api/graphql/connection.rb
260
266
  - lib/ecoportal/api/graphql/connection/action.rb
261
267
  - lib/ecoportal/api/graphql/connection/action_category.rb
@@ -333,6 +339,10 @@ files:
333
339
  - lib/ecoportal/api/graphql/model/location_structure/draft/structure.rb
334
340
  - lib/ecoportal/api/graphql/model/organization.rb
335
341
  - lib/ecoportal/api/graphql/model/page.rb
342
+ - lib/ecoportal/api/graphql/model/page/data_field.rb
343
+ - lib/ecoportal/api/graphql/model/page/phased.rb
344
+ - lib/ecoportal/api/graphql/model/page/phased/stage.rb
345
+ - lib/ecoportal/api/graphql/model/page/section.rb
336
346
  - lib/ecoportal/api/graphql/model/person_member.rb
337
347
  - lib/ecoportal/api/graphql/model/resource.rb
338
348
  - lib/ecoportal/api/graphql/model/user.rb
@@ -394,7 +404,6 @@ licenses:
394
404
  - MIT
395
405
  metadata:
396
406
  rubygems_mfa_required: 'true'
397
- post_install_message:
398
407
  rdoc_options: []
399
408
  require_paths:
400
409
  - lib
@@ -409,8 +418,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
409
418
  - !ruby/object:Gem::Version
410
419
  version: '0'
411
420
  requirements: []
412
- rubygems_version: 3.5.23
413
- signing_key:
421
+ rubygems_version: 4.0.8
414
422
  specification_version: 4
415
423
  summary: A collection of helpers for interacting with the ecoPortal GraphQL API
416
424
  test_files: []