ecoportal-api-graphql 0.3.13 → 0.3.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +43 -10
  3. data/CHANGELOG.md +18 -1
  4. data/README.md +4 -0
  5. data/Rakefile +14 -3
  6. data/ecoportal-api-graphql.gemspec +2 -2
  7. data/lib/ecoportal/api/graphql/base/location_classification_type.rb +2 -0
  8. data/lib/ecoportal/api/graphql/base/location_node.rb +1 -1
  9. data/lib/ecoportal/api/graphql/base/location_structure.rb +1 -0
  10. data/lib/ecoportal/api/graphql/builder/location_structure.rb +5 -0
  11. data/lib/ecoportal/api/graphql/fragment/action.rb +1 -1
  12. data/lib/ecoportal/api/graphql/fragment/contractor_entity.rb +1 -1
  13. data/lib/ecoportal/api/graphql/fragment/location_node.rb +1 -1
  14. data/lib/ecoportal/api/graphql/fragment/pagination.rb +1 -1
  15. data/lib/ecoportal/api/graphql/helpers/locations_tree.rb +10 -10
  16. data/lib/ecoportal/api/graphql/input/location_structure/apply_commands.rb +1 -1
  17. data/lib/ecoportal/api/graphql/input/location_structure/command_interface.rb +1 -1
  18. data/lib/ecoportal/api/graphql/logic/base_query.rb +21 -6
  19. data/lib/ecoportal/api/graphql/logic/connection.rb +1 -1
  20. data/lib/ecoportal/api/graphql/logic/mutation.rb +8 -7
  21. data/lib/ecoportal/api/graphql/logic/payload.rb +1 -1
  22. data/lib/ecoportal/api/graphql/logic/query.rb +1 -1
  23. data/lib/ecoportal/api/graphql/logic/query_array.rb +1 -1
  24. data/lib/ecoportal/api/graphql/logic/query_connection.rb +5 -7
  25. data/lib/ecoportal/api/graphql/model/location_node.rb +9 -0
  26. data/lib/ecoportal/api/graphql/model/organization.rb +1 -1
  27. data/lib/ecoportal/api/graphql/mutation/location_structure/apply_commands.rb +24 -24
  28. data/lib/ecoportal/api/graphql/query/location_classifications.rb +39 -0
  29. data/lib/ecoportal/api/graphql/query/location_structure.rb +2 -2
  30. data/lib/ecoportal/api/graphql/query/location_structures.rb +3 -3
  31. data/lib/ecoportal/api/graphql/query.rb +1 -0
  32. data/lib/ecoportal/api/graphql_version.rb +1 -1
  33. metadata +6 -6
  34. data/.travis.yml +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 84a9f39a8061d4b353f10cfb5e9fd5b2dded406387e60226b6e5bf2bb0d8ed48
4
- data.tar.gz: bb50d826e6337eff2003df61040028ebf4e894c6926f99b5a62c77b69250359a
3
+ metadata.gz: 2c155d6c7fa282ad8cf9ccae9682cec2ce1560b1716802cf6dabfbdd20d84587
4
+ data.tar.gz: 39d410c6e6082e3cb36e86739bcd3c04e45c3d8e56b0905a97ecb6839160cde7
5
5
  SHA512:
6
- metadata.gz: c104b66bc6d0d131d0a7af1db10773517562423db29c79e755358618b135cefc308d603bbefaa3046a132ab99dcd19a077d2e84d5ea5e661099e31b4652a8057
7
- data.tar.gz: aca1f93af54014e401bf854afbdcd1692682002ca01b5191c99776cffc2ef1525ce34def3d3da0d154d01b0555410cd15b369b8d37b7d0db3fecc243a85ac0a9
6
+ metadata.gz: 9c48ec8bbe4f40597e59fa6463a9244e350e6bbe4a7558dcb8cad79e35c8fab0bcde02c0e09a8a4e66ac7bc7f504a0bad0ac1a260edda8775565014cfa080cf6
7
+ data.tar.gz: 40f80dd98b63c3a8c83073d30037bf080e3fa282096c9f435b84dabe663ad578d0dd92acafeaed4856531dc64abbd75fc9b4cb434b7adad9536bd5f5ef632024
data/.rubocop.yml CHANGED
@@ -1,12 +1,11 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.5.1
2
+ TargetRubyVersion: 2.7.8
3
3
  Exclude:
4
4
  - 'config/routes.rb'
5
+ NewCops: enable
5
6
 
6
- Metrics/LineLength:
7
- Enabled: false
8
7
  Metrics/BlockLength:
9
- ExcludedMethods: [context, describe]
8
+ CountAsOne: ['array', 'heredoc', 'method_call']
10
9
  Max: 50
11
10
  Metrics/MethodLength:
12
11
  Max: 50
@@ -14,26 +13,51 @@ Metrics/ClassLength:
14
13
  Max: 200
15
14
  Metrics/AbcSize:
16
15
  Max: 30
17
-
18
- ParameterLists:
16
+ Metrics/ParameterLists:
19
17
  Max: 5
20
18
  CountKeywordArgs: false
19
+ Metrics/CyclomaticComplexity:
20
+ Max: 30
21
+ Metrics/PerceivedComplexity:
22
+ Max: 30
21
23
 
22
- Style/StringLiterals:
24
+ Layout/HashAlignment:
25
+ EnforcedColonStyle: table
26
+ EnforcedHashRocketStyle: table
27
+
28
+ Style/BlockDelimiters:
29
+ BracesRequiredMethods: ['log']
30
+ AllowedMethods: ['proc', 'new']
31
+ Enabled: false
32
+ Style/ClassAndModuleChildren:
23
33
  Enabled: false
24
34
  Style/FrozenStringLiteralComment:
25
35
  Enabled: false
36
+ Style/StringLiterals:
37
+ Enabled: false
38
+ Style/Documentation:
39
+ Enabled: false
26
40
  Style/CommentedKeyword:
27
41
  Enabled: false
28
- Style/MultilineBlockChain:
42
+ Layout/LeadingCommentSpace:
29
43
  Enabled: false
30
- Style/Documentation:
44
+ AllowGemfileRubyComment: true
45
+ Style/MultilineBlockChain:
31
46
  Enabled: false
32
47
  Style/StringLiteralsInInterpolation:
33
48
  Enabled: false
34
49
  Style/AndOr:
35
50
  Enabled: false
51
+ Style/Alias:
52
+ EnforcedStyle: prefer_alias_method
53
+ Style/FetchEnvVar:
54
+ Enabled: false
55
+ Style/RegexpLiteral:
56
+ EnforcedStyle: mixed
57
+ AllowInnerSlashes: true
36
58
 
59
+ Layout/LineLength:
60
+ Enabled: false
37
61
  Layout/SpaceInsideHashLiteralBraces:
38
62
  Enabled: false
39
63
  Layout/SpaceInsideBlockBraces:
@@ -48,8 +72,17 @@ Layout/DotPosition:
48
72
  EnforcedStyle: trailing
49
73
  Layout/MultilineMethodCallIndentation:
50
74
  EnforcedStyle: indented
51
- Layout/IndentHash:
75
+ Layout/FirstHashElementIndentation:
76
+ Enabled: false
77
+ Layout/EmptyLineAfterGuardClause:
52
78
  Enabled: false
53
79
 
54
80
  Naming/VariableNumber:
55
81
  EnforcedStyle: snake_case
82
+ CheckSymbols: false
83
+ Naming/MethodParameterName:
84
+ AllowedNames: ['x', 'y', 'i', 'j']
85
+ Naming/RescuedExceptionsVariableName:
86
+ Enabled: false
87
+ Naming/MethodName:
88
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -8,12 +8,29 @@ All notable changes to this project will be documented in this file.
8
8
  - Analyse how to "DSL" currentOrganization.action.activities
9
9
  - review `path` tracking
10
10
 
11
+ ## [0.3.15] - 2024-04-xx
11
12
 
12
- ## [0.3.14] - 2024-02-xx
13
+ ### Added
14
+ - `Ecoportal::API::GraphQL::Logic::BaseQuery`
15
+ - `::base_path` class instance var.
16
+ - query to retrieve `currentOrganization.classifications`
17
+
18
+ ### Changed
19
+ ### Fixed
20
+ - upgraded `ecoportal-api-v2` gem
21
+
22
+ ## [0.3.14] - 2024-03-13
13
23
 
14
24
  ### Added
25
+ - some benchmarking on
26
+ 1. core graphql base `query`
27
+ - `#parent_id` to location node model
28
+
15
29
  ### Changed
30
+ - upgraded `ecoportal-v2-api` gem
31
+
16
32
  ### Fixed
33
+ - Optimized `treeify` and locations structure class
17
34
 
18
35
  ## [0.3.13] - 2024-02-03
19
36
 
data/README.md CHANGED
@@ -18,3 +18,7 @@ And then execute:
18
18
  Or install it yourself as:
19
19
 
20
20
  $ gem install ecoportal-api-graphql
21
+
22
+ ## Changelog
23
+
24
+ See {file:CHANGELOG.md} for a list of changes.
data/Rakefile CHANGED
@@ -1,5 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
+ require 'rubocop/rake_task'
3
4
  require "yard"
4
5
  require "redcarpet"
5
6
 
@@ -10,11 +11,18 @@ desc "run rspec showing backtrace"
10
11
  RSpec::Core::RakeTask.new(:spec_trace) do |task|
11
12
  task.rspec_opts = ['--backtrace']
12
13
  end
14
+ task :rspec_trace => :spec_trace
13
15
 
14
16
  desc "run rspec stopping on first fail, and show backtrace"
15
17
  RSpec::Core::RakeTask.new(:spec_fast) do |task|
16
18
  task.rspec_opts = ['--fail-fast', '--backtrace']
17
19
  end
20
+ task :rspec_fast => :spec_fast
21
+
22
+ desc "run rubocop diaplying cop names"
23
+ RuboCop::RakeTask.new(:rubocop) do |t|
24
+ t.options = ['--display-cop-names']
25
+ end
18
26
 
19
27
  # default task name is yard
20
28
  desc "Yard: generate all the documentation"
@@ -22,6 +30,9 @@ YARD::Rake::YardocTask.new(:doc) do |t|
22
30
  #t.files = ['lib/**/*.rb']
23
31
  end
24
32
 
25
- task :default => [:spec]
26
- task :rspec_trace => :spec_trace
27
- task :rspec_fast => :spec_fast
33
+ desc "default task: runs rubocop and rspec"
34
+ task :default do
35
+ Rake::Task[:rubocop].invoke
36
+ ensure
37
+ Rake::Task[:spec].invoke
38
+ end
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
13
13
  spec.homepage = "https://www.ecoportal.com"
14
14
  spec.licenses = %w[MIT]
15
15
 
16
- spec.required_ruby_version = '>= 2.6.0'
16
+ spec.required_ruby_version = '>= 2.7.0'
17
17
 
18
18
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
19
  f.match(%r{^(test|spec|features)/})
@@ -29,6 +29,6 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency "redcarpet", ">= 3.6.0", "< 4"
30
30
  spec.add_development_dependency "pry" , ">= 0.14"
31
31
 
32
- spec.add_dependency 'ecoportal-api-v2', '>= 1.1.5', '< 1.2'
32
+ spec.add_dependency 'ecoportal-api-v2', '>= 1.1.8', '< 1.2'
33
33
  spec.add_dependency 'graphlient', '>= 0.8.0', '< 0.9'
34
34
  end
@@ -3,6 +3,8 @@ module Ecoportal
3
3
  class GraphQL
4
4
  module Base
5
5
  class LocationClassificationType < Ecoportal::API::GraphQL::Base::Model
6
+ read_only!
7
+
6
8
  passkey :id
7
9
  passthrough :name
8
10
  passboolean :active
@@ -9,7 +9,7 @@ module Ecoportal
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
12
+ embeds_many :classifications, klass: Base::LocationClassificationType
13
13
 
14
14
  def parentId
15
15
  parent&.id
@@ -3,6 +3,7 @@ module Ecoportal
3
3
  class GraphQL
4
4
  module Base
5
5
  class LocationStructure < Ecoportal::API::GraphQL::Base::Model
6
+ read_only!
6
7
  extend Ecoportal::API::GraphQL::Helpers::LocationsTree
7
8
 
8
9
  passkey :id
@@ -9,6 +9,11 @@ module Ecoportal
9
9
  @client = client
10
10
  end
11
11
 
12
+ def nodeClassifications(**kargs, &block)
13
+ query_model = Ecoportal::API::GraphQL::Query::LocationClassifications.new(client)
14
+ query_model.query(**kargs, &block)
15
+ end
16
+
12
17
  def applyCommandsInput
13
18
  Ecoportal::API::GraphQL::Input::LocationStructure::ApplyCommands.new
14
19
  end
@@ -2,7 +2,7 @@ module Ecoportal
2
2
  module API
3
3
  class GraphQL
4
4
  class Fragment
5
- fragment :Action, <<~'GRAPHQL'
5
+ fragment :Action, <<~GRAPHQL
6
6
  fragment on Action {
7
7
  id
8
8
  altId
@@ -2,7 +2,7 @@ module Ecoportal
2
2
  module API
3
3
  class GraphQL
4
4
  class Fragment
5
- fragment :ContractorEntity, <<~'GRAPHQL'
5
+ fragment :ContractorEntity, <<~GRAPHQL
6
6
  fragment on ContractorEntity {
7
7
  id
8
8
  name
@@ -2,7 +2,7 @@ module Ecoportal
2
2
  module API
3
3
  class GraphQL
4
4
  class Fragment
5
- fragment :LocationNode, <<~'GRAPHQL'
5
+ fragment :LocationNode, <<~GRAPHQL
6
6
  fragment on LocationNodeInterface {
7
7
  id
8
8
  name
@@ -2,7 +2,7 @@ module Ecoportal
2
2
  module API
3
3
  class GraphQL
4
4
  class Fragment
5
- fragment :Pagination, <<~'GRAPHQL'
5
+ fragment :Pagination, <<~GRAPHQL
6
6
  fragment on ActionConnection {
7
7
  totalCount
8
8
  pageInfo {
@@ -3,11 +3,11 @@ module Ecoportal
3
3
  class GraphQL
4
4
  module Helpers
5
5
  module LocationsTree
6
+ RELEVANT_NODES_COUNT = 1000
7
+
6
8
  def treeify(nodes)
7
- parents = nodes.each_with_object({}) do |node, parents|
8
- parent = node.parent
9
- parentId = parent && parent.id.upcase
10
- (parents[parentId] ||= []).push(node)
9
+ parents = nodes.each_with_object({}) do |node, out|
10
+ (out[node.parent_id_upcase] ||= []).push(node)
11
11
  end
12
12
  get_children(nil, parents)
13
13
  end
@@ -21,15 +21,15 @@ module Ecoportal
21
21
  class_names = class_types.map(&:name)
22
22
 
23
23
  results << {
24
- "id" => child.id,
25
- "name" => child.name,
26
- "weight" => child.weight,
27
- "parent_id" => node_id,
28
- "archived" => child.archived,
24
+ "id" => child.id,
25
+ "name" => child.name,
26
+ "weight" => child.weight,
27
+ "parent_id" => node_id,
28
+ "archived" => child.archived,
29
29
  "archived_token" => child.archivedToken,
30
30
  "classifications" => class_ids,
31
31
  "classification_names" => class_names,
32
- "nodes" => get_children(child.id, parents).compact
32
+ "nodes" => get_children(child.id, parents).compact
33
33
  }
34
34
  end
35
35
  end
@@ -11,7 +11,7 @@ module Ecoportal
11
11
  passboolean :preview
12
12
 
13
13
  def add(type, **kargs)
14
- if command = new_command(type)
14
+ if (command = new_command(type))
15
15
  command.set_values(**kargs) unless kargs.empty?
16
16
  yield(command) if block_given?
17
17
  end
@@ -14,7 +14,7 @@ module Ecoportal
14
14
 
15
15
  def set_values(**kargs)
16
16
  kargs.each do |key, value|
17
- self.send(key, value) if self.respond_to?(key, true)
17
+ send(key, value) if respond_to?(key, true)
18
18
  end
19
19
  self
20
20
  end
@@ -19,7 +19,7 @@ module Ecoportal
19
19
  param_defaults[key] = default unless default == :unused
20
20
  end
21
21
 
22
- @accepted_params.push(*keys).tap {|ks| ks.uniq!}
22
+ @accepted_params.push(*keys).tap(&:uniq!)
23
23
  @accepted_params
24
24
  end
25
25
 
@@ -39,12 +39,22 @@ module Ecoportal
39
39
  @field_name = nil
40
40
  @field_name = str.to_s if str
41
41
  end
42
+
43
+ def base_path(path = :unused)
44
+ return @base_path if path == :unused
45
+ path ||= []
46
+ path = path.to_s.split('.') if path.is_a?(String)
47
+ path = path.map(&:to_s).compact
48
+ @base_path = path
49
+ end
42
50
  end
43
51
 
52
+ include Ecoportal::API::Common::Concerns::Benchmarkable
53
+
44
54
  attr_reader :client
45
55
  attr_reader :base_path
46
56
 
47
- def initialize(client, path: nil, base_path: [])
57
+ def initialize(client, path: nil, base_path: self.class.base_path)
48
58
  @path = path
49
59
  @base_path = base_path
50
60
  @client = client
@@ -53,7 +63,7 @@ module Ecoportal
53
63
  # Resolves the `path` by using `path` or `base_path` + `class.field_name`.
54
64
  def path(field_name = self.class.field_name)
55
65
  result = @path
56
- result ||= default_path if self.respond_to?(:default_path, true)
66
+ result ||= default_path if respond_to?(:default_path, true)
57
67
  result ||= (base_path + [field_name]) if base_path && field_name
58
68
  result
59
69
  end
@@ -61,7 +71,9 @@ module Ecoportal
61
71
  # Query rely that manages the different blocks.
62
72
  # @return [Class] an object of `response_class` with the results hanging from `path`.
63
73
  def query(path: self.path, **kargs, &block)
64
- graphql_query(path: path, **kargs, &basic_block(&block))
74
+ benchmarking("#{self.class}##{__method__}", print: true) do
75
+ graphql_query(path: path, **kargs, &basic_block(&block))
76
+ end
65
77
  end
66
78
 
67
79
  def response_class
@@ -84,7 +96,7 @@ module Ecoportal
84
96
  request(*path) do
85
97
  raw_response[:data] = client.query(query_params, &block)
86
98
  end
87
- rescue Faraday::ParsingError, Graphlient::Errors::GraphQLError => e
99
+ rescue Faraday::ParsingError, Graphlient::Errors::GraphQLError => _err
88
100
  puts "Internal Error with these params:"
89
101
  pp kargs
90
102
  pp block
@@ -97,7 +109,10 @@ module Ecoportal
97
109
  end
98
110
 
99
111
  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"))
112
+ unless (res = response.to_h.dig(*path.dup.unshift("data")))
113
+ msg = "Complete failure on request. Path: #{path}\n#{response.to_h.pretty_inspect}"
114
+ raise msg
115
+ end
101
116
  data = Ecoportal::API::Common::GraphQL::HashHelpers.deep_dup(res)
102
117
  response_class.new(data)
103
118
  end
@@ -4,7 +4,7 @@ module Ecoportal
4
4
  module Logic
5
5
  class Connection < Ecoportal::API::GraphQL::Base::Model
6
6
  class GenericNode
7
- def initialize(*args, **kargs)
7
+ def initialize(*_args, **_kargs)
8
8
  raise "Missuse error. You should define a node_class for a class that inherits from GraphqlConnection class."
9
9
  end
10
10
  end
@@ -4,12 +4,13 @@ module Ecoportal
4
4
  module Logic
5
5
  class Mutation < Ecoportal::API::GraphQL::Logic::BaseQuery
6
6
  class GenericPayload
7
- def initialize(*args, **kargs)
7
+ def initialize(*_args, **_kargs)
8
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
  class GenericInput
12
- def initialize(*args, **kargs)
13
+ def initialize(*_args, **_kargs)
13
14
  raise "Missuse error. You should define a input_class for a class that inherits from Mutation class."
14
15
  end
15
16
  end
@@ -23,7 +24,7 @@ module Ecoportal
23
24
  request(*path) do
24
25
  client.query(input: as_input(input), &basic_block(&block))
25
26
  end
26
- rescue Faraday::ParsingError, Graphlient::Errors::FaradayServerError => e
27
+ rescue Faraday::ParsingError, Graphlient::Errors::FaradayServerError => _err
27
28
  puts "Internal Error with these input ('#{input.class}'):"
28
29
  pp input
29
30
  raise
@@ -43,13 +44,13 @@ module Ecoportal
43
44
  value
44
45
  when Ecoportal::API::GraphQL::Base::Model
45
46
  value.as_input
46
- when Hash
47
- value = Helpers::Model::HashKeys.keys_to_sym_deep(value)
48
- Ecoportal::API::Base::Model.as_input(value)
47
+ # when Hash
48
+ # value = Helpers::Model::HashKeys.keys_to_sym_deep(value)
49
+ # Ecoportal::API::Base::Model.as_input(value)
49
50
  when Enumerable
50
51
  value.map {|v| as_input(v)}
51
52
  else
52
- raise ArgumentError.new("Expecting Hash, GraphQL::Base::Model or Enumerable. Unsupported type '#{value.class}'.")
53
+ raise ArgumentError, "Expecting Hash, GraphQL::Base::Model or Enumerable. Unsupported type '#{value.class}'."
53
54
  end
54
55
  end
55
56
  end
@@ -4,7 +4,7 @@ module Ecoportal
4
4
  module Logic
5
5
  class Payload < Ecoportal::API::GraphQL::Base::Model
6
6
  class GenericItem
7
- def initialize(*args, **kargs)
7
+ def initialize(*_args, **_kargs)
8
8
  raise "Missuse error. You should define a item_class for a class that inherits from GraphqlPayload class."
9
9
  end
10
10
  end
@@ -4,7 +4,7 @@ module Ecoportal
4
4
  module Logic
5
5
  class Query < Ecoportal::API::GraphQL::Logic::BaseQuery
6
6
  class GenericItem
7
- def initialize(*args, **kargs)
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
@@ -6,7 +6,7 @@ module Ecoportal
6
6
  include Enumerable
7
7
 
8
8
  def each(item_block: nil, **kargs, &block)
9
- return to_enum(:each, **kargs, item_block: connection_block) unless block
9
+ return to_enum(:each, item_block: connection_block, **kargs) unless block
10
10
  query(**kargs, &item_block).each do |item|
11
11
  yield(item) if block_given?
12
12
  end
@@ -8,16 +8,14 @@ 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
- cursor = nil; results = 0
11
+ cursor = nil
12
12
  loop do
13
13
  kargs.update(after: cursor) if cursor
14
14
  connection = query(**kargs, &connection_block)
15
15
  #total = connection.totalCount
16
- pageInfo = connection.pageInfo
17
- connection.nodes.each do |item|
18
- yield item
19
- end
20
- break unless cursor = pageInfo.endCursor
16
+ page_info = connection.pageInfo
17
+ connection.nodes.each(&block)
18
+ break unless (cursor = page_info.endCursor)
21
19
  end
22
20
  end
23
21
 
@@ -25,7 +23,7 @@ module Ecoportal
25
23
  return connection_class if respond_to?(:connection_class)
26
24
  @response_class ||= self.class.new_class(
27
25
  item_class,
28
- inherits: Ecoportal::API::GraphQL::Logic::Connection,
26
+ inherits: Ecoportal::API::GraphQL::Logic::Connection,
29
27
  namespace: "Ecoportal::API::GraphQL::Connection"
30
28
  ) do |klass|
31
29
  klass.item_class = item_class
@@ -5,6 +5,15 @@ module Ecoportal
5
5
  class LocationNode < Ecoportal::API::GraphQL::Base::LocationNode
6
6
  embeds_one :parent, klass: Model::LocationNode, nullable: true
7
7
  embeds_many :ancestors, klass: Model::LocationNode
8
+
9
+ def parentId
10
+ parent&.id
11
+ end
12
+ alias_method :parent_id, :parentId
13
+
14
+ def parent_id_upcase
15
+ parent_id&.upcase
16
+ end
8
17
  end
9
18
  end
10
19
  end
@@ -3,7 +3,7 @@ module Ecoportal
3
3
  class GraphQL
4
4
  module Model
5
5
  class Organization < Ecoportal::API::GraphQL::Base::Organization
6
- DEFAULT_PATH = ["currentOrganization"]
6
+ DEFAULT_PATH = ["currentOrganization"].freeze
7
7
 
8
8
  class << self
9
9
  extend Ecoportal::API::Common::GraphQL::QueryIntegration
@@ -12,7 +12,7 @@ module Ecoportal
12
12
 
13
13
  def basic_block(&block)
14
14
  payload_block = block || default_payload_block
15
- Proc.new {
15
+ proc {
16
16
  mutation(input: :ApplyCommandsToLocationStructureInput!) {
17
17
  applyCommandsToLocationStructure(input: :input, &payload_block)
18
18
  }
@@ -20,32 +20,32 @@ module Ecoportal
20
20
  end
21
21
 
22
22
  def default_payload_block
23
- Proc.new {
23
+ proc {
24
24
  clientMutationId
25
25
  error {
26
- message
27
- conflictingIds
28
- validationErrors {
29
- error
30
- message
31
- }
32
- }
33
- results {
34
- command {
35
- id
36
- state
26
+ message
27
+ conflictingIds
28
+ validationErrors {
29
+ error
30
+ message
31
+ }
32
+ }
33
+ results {
34
+ command {
35
+ id
36
+ state
37
37
  __typename
38
- }
39
- ok
40
- error {
41
- conflictingIds
42
- message
43
- validationErrors {
44
- error
45
- message
46
- }
47
- }
48
- }
38
+ }
39
+ ok
40
+ error {
41
+ conflictingIds
42
+ message
43
+ validationErrors {
44
+ error
45
+ message
46
+ }
47
+ }
48
+ }
49
49
  structure {
50
50
  nodes(includeArchived: true) {
51
51
  ___Ecoportal__API__GraphQL__Fragment__LocationNode
@@ -0,0 +1,39 @@
1
+ module Ecoportal
2
+ module API
3
+ class GraphQL
4
+ module Query
5
+ class LocationClassifications < Ecoportal::API::GraphQL::Logic::QueryArray
6
+ accepted_params :active, default: true
7
+
8
+ base_path 'currentOrganization.locations'
9
+ field_name :classifications
10
+
11
+ class_resolver :item_class, Ecoportal::API::GraphQL::Base::LocationClassificationType
12
+
13
+ private
14
+
15
+ def basic_block(&block)
16
+ final_block = block || default_query_block
17
+ proc {
18
+ query(active: :boolean) {
19
+ currentOrganization {
20
+ locations {
21
+ classifications(active: :active, &final_block)
22
+ }
23
+ }
24
+ }
25
+ }
26
+ end
27
+
28
+ def default_query_block
29
+ proc {
30
+ id
31
+ name
32
+ active
33
+ }
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -14,7 +14,7 @@ module Ecoportal
14
14
 
15
15
  def basic_block(&block)
16
16
  final_block = block || default_query_block
17
- Proc.new {
17
+ proc {
18
18
  query(id: :id!, includeArchivedNodes: :boolean) {
19
19
  currentOrganization {
20
20
  locations {
@@ -29,7 +29,7 @@ module Ecoportal
29
29
  # @note this is on purpose, as via API
30
30
  # there isn't much sense in not including archived nodes.
31
31
  def default_query_block
32
- Proc.new {
32
+ proc {
33
33
  id
34
34
  name
35
35
  archived
@@ -5,7 +5,7 @@ module Ecoportal
5
5
  class LocationStructures < Ecoportal::API::GraphQL::Logic::QueryArray
6
6
  accepted_params :includeArchived, :includeUnpublished, default: false
7
7
  accepted_params :includeArchivedNodes, default: true
8
-
8
+
9
9
  field_name :structures
10
10
 
11
11
  class_resolver :item_class, Ecoportal::API::GraphQL::Model::LocationStructure
@@ -14,7 +14,7 @@ module Ecoportal
14
14
 
15
15
  def basic_block(&block)
16
16
  final_block = block || default_query_block
17
- Proc.new {
17
+ proc {
18
18
  query(includeArchived: :boolean,
19
19
  includeUnpublished: :boolean,
20
20
  includeArchivedNodes: :boolean
@@ -36,7 +36,7 @@ module Ecoportal
36
36
  # @note this is on purpose, as via API
37
37
  # there isn't much sense in not including archived nodes.
38
38
  def default_query_block
39
- Proc.new {
39
+ proc {
40
40
  id
41
41
  name
42
42
  archived
@@ -7,6 +7,7 @@ module Ecoportal
7
7
  end
8
8
  end
9
9
 
10
+ require 'ecoportal/api/graphql/query/location_classifications'
10
11
  require 'ecoportal/api/graphql/query/location_structure'
11
12
  require 'ecoportal/api/graphql/query/location_structures'
12
13
  require 'ecoportal/api/graphql/query/action'
@@ -1,5 +1,5 @@
1
1
  module Ecoportal
2
2
  module API
3
- GRAPQL_VERSION = "0.3.13"
3
+ GRAPQL_VERSION = "0.3.15"
4
4
  end
5
5
  end
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.13
4
+ version: 0.3.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-02-02 00:00:00.000000000 Z
11
+ date: 2024-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -130,7 +130,7 @@ dependencies:
130
130
  requirements:
131
131
  - - ">="
132
132
  - !ruby/object:Gem::Version
133
- version: 1.1.5
133
+ version: 1.1.8
134
134
  - - "<"
135
135
  - !ruby/object:Gem::Version
136
136
  version: '1.2'
@@ -140,7 +140,7 @@ dependencies:
140
140
  requirements:
141
141
  - - ">="
142
142
  - !ruby/object:Gem::Version
143
- version: 1.1.5
143
+ version: 1.1.8
144
144
  - - "<"
145
145
  - !ruby/object:Gem::Version
146
146
  version: '1.2'
@@ -174,7 +174,6 @@ files:
174
174
  - ".gitignore"
175
175
  - ".rspec"
176
176
  - ".rubocop.yml"
177
- - ".travis.yml"
178
177
  - ".yardopts"
179
178
  - CHANGELOG.md
180
179
  - Gemfile
@@ -302,6 +301,7 @@ files:
302
301
  - lib/ecoportal/api/graphql/query/action.rb
303
302
  - lib/ecoportal/api/graphql/query/actions.rb
304
303
  - lib/ecoportal/api/graphql/query/contractor_entities.rb
304
+ - lib/ecoportal/api/graphql/query/location_classifications.rb
305
305
  - lib/ecoportal/api/graphql/query/location_structure.rb
306
306
  - lib/ecoportal/api/graphql/query/location_structures.rb
307
307
  - lib/ecoportal/api/graphql_version.rb
@@ -325,7 +325,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
325
325
  requirements:
326
326
  - - ">="
327
327
  - !ruby/object:Gem::Version
328
- version: 2.6.0
328
+ version: 2.7.0
329
329
  required_rubygems_version: !ruby/object:Gem::Requirement
330
330
  requirements:
331
331
  - - ">="
data/.travis.yml DELETED
@@ -1,5 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.5.1
5
- before_install: gem install bundler -v 1.16.1