ecoportal-api-graphql 0.4.3 → 0.4.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 (59) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +34 -4
  3. data/Rakefile +10 -10
  4. data/ecoportal-api-graphql.gemspec +22 -19
  5. data/lib/ecoportal/api/common/graphql/class_helpers.rb +6 -3
  6. data/lib/ecoportal/api/common/graphql/hash_helpers.rb +60 -30
  7. data/lib/ecoportal/api/common/graphql/http_client.rb +6 -12
  8. data/lib/ecoportal/api/common/graphql/model/as_input.rb +40 -0
  9. data/lib/ecoportal/api/common/graphql/model/diffable/hash_diff.rb +60 -0
  10. data/lib/ecoportal/api/common/graphql/model/diffable.rb +32 -0
  11. data/lib/ecoportal/api/common/graphql/model.rb +17 -0
  12. data/lib/ecoportal/api/common/graphql/query_integration.rb +5 -2
  13. data/lib/ecoportal/api/common/graphql.rb +1 -2
  14. data/lib/ecoportal/api/graphql/base/action.rb +3 -1
  15. data/lib/ecoportal/api/graphql/base/action_category.rb +3 -1
  16. data/lib/ecoportal/api/graphql/base/contractor_entity.rb +2 -0
  17. data/lib/ecoportal/api/graphql/base/location_classification_type.rb +1 -1
  18. data/lib/ecoportal/api/graphql/base/location_node.rb +2 -0
  19. data/lib/ecoportal/api/graphql/base/location_structure.rb +1 -0
  20. data/lib/ecoportal/api/graphql/base/model.rb +1 -21
  21. data/lib/ecoportal/api/graphql/base/organization.rb +2 -0
  22. data/lib/ecoportal/api/graphql/base/page.rb +2 -0
  23. data/lib/ecoportal/api/graphql/base/person_member.rb +2 -0
  24. data/lib/ecoportal/api/graphql/builder/action.rb +8 -0
  25. data/lib/ecoportal/api/graphql/connection/action_category.rb +11 -0
  26. data/lib/ecoportal/api/graphql/connection.rb +1 -0
  27. data/lib/ecoportal/api/graphql/error/locations_error.rb +2 -0
  28. data/lib/ecoportal/api/graphql/error/locations_validation_error.rb +2 -0
  29. data/lib/ecoportal/api/graphql/error/validation_errors.rb +1 -0
  30. data/lib/ecoportal/api/graphql/fragment/action.rb +5 -1
  31. data/lib/ecoportal/api/graphql/fragment/action_category.rb +17 -0
  32. data/lib/ecoportal/api/graphql/fragment.rb +3 -0
  33. data/lib/ecoportal/api/graphql/helpers/locations_tree.rb +10 -10
  34. data/lib/ecoportal/api/graphql/input/action/create.rb +13 -0
  35. data/lib/ecoportal/api/graphql/input/action.rb +2 -1
  36. data/lib/ecoportal/api/graphql/logic/base_query.rb +5 -2
  37. data/lib/ecoportal/api/graphql/logic/mutation.rb +3 -5
  38. data/lib/ecoportal/api/graphql/logic/payload.rb +2 -0
  39. data/lib/ecoportal/api/graphql/logic/query.rb +4 -1
  40. data/lib/ecoportal/api/graphql/logic/query_array.rb +1 -0
  41. data/lib/ecoportal/api/graphql/logic/query_connection.rb +2 -0
  42. data/lib/ecoportal/api/graphql/model/account.rb +2 -0
  43. data/lib/ecoportal/api/graphql/model/action.rb +1 -0
  44. data/lib/ecoportal/api/graphql/model/contractor_entity.rb +2 -2
  45. data/lib/ecoportal/api/graphql/model/location_node.rb +1 -1
  46. data/lib/ecoportal/api/graphql/model/organization.rb +1 -0
  47. data/lib/ecoportal/api/graphql/model/user.rb +2 -0
  48. data/lib/ecoportal/api/graphql/mutation/action/create.rb +40 -0
  49. data/lib/ecoportal/api/graphql/mutation/action.rb +2 -1
  50. data/lib/ecoportal/api/graphql/payload/action/create.rb +13 -0
  51. data/lib/ecoportal/api/graphql/payload/action.rb +2 -1
  52. data/lib/ecoportal/api/graphql/payload/location_structure/apply_commands.rb +2 -0
  53. data/lib/ecoportal/api/graphql/payload/location_structure/command_execution_result.rb +2 -0
  54. data/lib/ecoportal/api/graphql/query/action_categories.rb +52 -0
  55. data/lib/ecoportal/api/graphql/query/location_structures.rb +5 -4
  56. data/lib/ecoportal/api/graphql/query.rb +1 -0
  57. data/lib/ecoportal/api/graphql_version.rb +1 -1
  58. metadata +36 -27
  59. data/lib/ecoportal/api/common/graphql/doc_helpers.rb +0 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9179222ef94ebb52697888787734813f4aacf5e8267dea6b54c82862087779e0
4
- data.tar.gz: 495f596b1aef1e11c1fb2bd102bfbdd073325c64f81b608d4d53230ac5037d82
3
+ metadata.gz: a3e3519f253819b10dad7bd065d244dd90a3d7cd3e2ebe224f20bc4ccb83185d
4
+ data.tar.gz: 2045d67da3b50b55feaab8bce0fbd67935c79e9947878e4d9483df1fd2cad596
5
5
  SHA512:
6
- metadata.gz: 92e8cbd28c4b3d38fcbecf2284c6a6ff268641417009515cd62964eb7a539b2bbdf75fbcd9423e1616c943f49c1ba722c69bb845a0b8870dfa091f25b429a8e3
7
- data.tar.gz: d5812a7922aa767e912ae4385b3b6117d63e9fbafbf2a4cc404ae274982b2fa0ca95ec6e632544a1d16decde89adb4a8503c253ae0a74a8fb599a7f53d0e6b1d
6
+ metadata.gz: 0f64880b73ca0cc855d1d8cbe179e1dda7f79f73b88b9f9d4e41883ef631ee7fac41ced10dc3c1a56f821afe7d9bb4faa239aae86703ffcf4a55a564145c3788
7
+ data.tar.gz: 1cb72054839f0aa37d35f86c6ba1a55914c65c721bddc03ea6100d0126a4a42c176fecfb917c35e8b0302db85a726ffa59f12d7dbf0a8e07b3a57f28612fdd3f
data/CHANGELOG.md CHANGED
@@ -9,24 +9,54 @@ All notable changes to this project will be documented in this file.
9
9
  - Analyse how to "DSL" currentOrganization.action.activities
10
10
  - review `path` tracking
11
11
 
12
- ## [0.4.3] - 2024-10-xx
12
+ ## [0.4.6] - 2025-03-xx
13
13
 
14
14
  ### Added
15
15
 
16
16
  ### Changed
17
17
 
18
- - upgrade core gem
19
- - `Ecoportal::API::Common::GraphQL::HttpClient.new` ceased to default `version` to `v1` (now it defaults to `nil`)
18
+ ### Fixed
19
+
20
+ ## [0.4.5] - 2025-03-14
21
+
22
+ ### Added
23
+
24
+ - Query `actionCategories`
25
+ - Mutation **create** `Action`
26
+
27
+ ### Changed
28
+
29
+ - `Action` model to have `locations` (**RS** upgrade)
30
+
31
+ ## [0.4.4] - 2025-02-23
32
+
33
+ ### Changed
34
+
35
+ - Upgraded `ecoportal-api` gem (maintanance)
36
+ - Upgraded `ecoportal-api-v2` gem (to provision `root!` class method)
37
+ - Defined some models that hand on their own as `root!`
38
+ - Refactored `Base::Model` by moving its loggic to `Common::GraphQL`
20
39
 
21
40
  ### Fixed
22
41
 
23
- ## [0.4.2] - 2024-10-01
42
+ - `Ecoportal::API::Common::GraphQL::HashHelpers`
43
+ - Truly make the iterator generic
44
+
45
+ ## [0.4.3] - 2024-11-21
24
46
 
25
47
  ### Changed
26
48
 
27
49
  - upgrade gems
28
50
  - `ecoportal-api`
29
51
  - `ecoportal-api-v2`
52
+ - `Ecoportal::API::Common::GraphQL::HttpClient.new` ceased to default `version` to `v1` (now it defaults to `nil`)
53
+
54
+ ## [0.4.2] - 2024-10-01
55
+
56
+ ### Changed
57
+
58
+ - upgrade gems
59
+ - `ecoportal-api-v2`
30
60
  - add explicit dependency onto `ecoportal-api` gem (client)
31
61
 
32
62
  ## [0.4.1] - 2024-08-09
data/Rakefile CHANGED
@@ -1,36 +1,36 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
  require 'rubocop/rake_task'
4
- require "yard"
5
- require "redcarpet"
4
+ require 'yard'
5
+ require 'redcarpet'
6
6
 
7
- desc "run the specs"
7
+ desc 'run the specs'
8
8
  RSpec::Core::RakeTask.new(:spec)
9
9
 
10
- desc "run rspec showing backtrace"
10
+ desc 'run rspec showing backtrace'
11
11
  RSpec::Core::RakeTask.new(:spec_trace) do |task|
12
12
  task.rspec_opts = ['--backtrace']
13
13
  end
14
14
  task :rspec_trace => :spec_trace
15
15
 
16
- desc "run rspec stopping on first fail, and show backtrace"
16
+ desc 'run rspec stopping on first fail, and show backtrace'
17
17
  RSpec::Core::RakeTask.new(:spec_fast) do |task|
18
18
  task.rspec_opts = ['--fail-fast', '--backtrace']
19
19
  end
20
20
  task :rspec_fast => :spec_fast
21
21
 
22
- desc "run rubocop diaplying cop names"
22
+ desc 'run rubocop diaplying cop names'
23
23
  RuboCop::RakeTask.new(:rubocop) do |t|
24
24
  t.options = ['--display-cop-names']
25
25
  end
26
26
 
27
27
  # default task name is yard
28
- desc "Yard: generate all the documentation"
28
+ desc 'Yard: generate all the documentation'
29
29
  YARD::Rake::YardocTask.new(:doc) do |t|
30
30
  #t.files = ['lib/**/*.rb']
31
31
  end
32
32
 
33
- desc "default task: runs rubocop and rspec"
33
+ desc 'default task: runs rubocop and rspec'
34
34
  task :default do
35
35
  Rake::Task[:rubocop].invoke
36
36
  ensure
@@ -1,15 +1,16 @@
1
+ # rubocop:disable Gemspec/DevelopmentDependencies
1
2
  lib = File.expand_path('lib', __dir__)
2
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require "ecoportal/api/graphql_version"
4
+ require 'ecoportal/api/graphql_version'
4
5
 
5
6
  Gem::Specification.new do |spec|
6
- spec.name = "ecoportal-api-graphql"
7
+ spec.name = 'ecoportal-api-graphql'
7
8
  spec.version = Ecoportal::API::GRAPQL_VERSION
8
- spec.authors = ["Oscar Segura"]
9
- spec.email = ["oscar@ecoportal.co.nz"]
9
+ spec.authors = ['Oscar Segura']
10
+ spec.email = ['oscar@ecoportal.co.nz']
10
11
 
11
- spec.summary = "A collection of helpers for interacting with the ecoPortal GraphQL API"
12
- spec.homepage = "https://www.ecoportal.com"
12
+ spec.summary = 'A collection of helpers for interacting with the ecoPortal GraphQL API'
13
+ spec.homepage = 'https://www.ecoportal.com'
13
14
  spec.licenses = %w[MIT]
14
15
 
15
16
  spec.metadata['rubygems_mfa_required'] = 'true'
@@ -19,19 +20,21 @@ Gem::Specification.new do |spec|
19
20
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
20
21
  f.match(%r{^(test|spec|features)/})
21
22
  end
22
- spec.bindir = "exe"
23
+ spec.bindir = 'exe'
23
24
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
- spec.require_paths = ["lib"]
25
-
26
- spec.add_development_dependency "rspec", ">= 3.12.0", "< 4"
27
- spec.add_development_dependency "rake", ">= 13.0.3", "< 14"
28
- spec.add_development_dependency "yard", ">= 0.9.34", "< 1"
29
- spec.add_development_dependency "redcarpet", ">= 3.6.0", "< 4"
30
- spec.add_development_dependency "rubocop", "~> 1"
31
- spec.add_development_dependency "rubocop-rake", "~> 0"
32
- spec.add_development_dependency "pry" , ">= 0.14"
33
-
34
- spec.add_dependency 'ecoportal-api', '~> 0.10', '>= 0.10.7'
35
- spec.add_dependency 'ecoportal-api-v2', '~> 2.0', '>= 2.0.12'
25
+ spec.require_paths = ['lib']
26
+
27
+ spec.add_development_dependency 'pry', '>= 0.14'
28
+ spec.add_development_dependency 'rake', '>= 13.0.3', '< 14'
29
+ spec.add_development_dependency 'redcarpet', '>= 3.6.0', '< 4'
30
+ spec.add_development_dependency 'rspec', '>= 3.12.0', '< 4'
31
+ spec.add_development_dependency 'rubocop', '~> 1'
32
+ spec.add_development_dependency 'rubocop-rake', '~> 0'
33
+ spec.add_development_dependency 'yard', '>= 0.9.34', '< 1'
34
+
35
+ spec.add_dependency 'ecoportal-api', '~> 0.10', '>= 0.10.8'
36
+ spec.add_dependency 'ecoportal-api-v2', '~> 2.0', '>= 2.0.15'
36
37
  spec.add_dependency 'graphlient', '>= 0.8.0', '< 0.9'
37
38
  end
39
+
40
+ # rubocop:enable Gemspec/DevelopmentDependencies
@@ -7,7 +7,10 @@ module Ecoportal
7
7
  def becomes(klass)
8
8
  klass.new.tap do |becoming|
9
9
  instance_variables.each do |var|
10
- becoming.instance_variable_set(var, instance_variable_get(var))
10
+ becoming.instance_variable_set(
11
+ var,
12
+ instance_variable_get(var)
13
+ )
11
14
  end
12
15
  end
13
16
  end
@@ -23,11 +26,11 @@ module Ecoportal
23
26
  def const?(value)
24
27
  begin
25
28
  const_get(value)
26
- rescue NameError => e
29
+ rescue NameError
27
30
  return false
28
31
  end
29
32
  true
30
- end
33
+ end
31
34
  end
32
35
 
33
36
  class << self
@@ -4,48 +4,32 @@ module Ecoportal
4
4
  module GraphQL
5
5
  module HashHelpers
6
6
  module InstanceMethods
7
- def transform_keys_deep(value, &block)
8
- case value
9
- when Hash
10
- value.dup.each_with_object({}) do |(k, v), out|
11
- k_val = block_given?? yield(k) : k
12
- out[k_val] = keys_to_sym_deep(v)
13
- end
14
- when Enumerable
15
- value.map {|v| keys_to_sym_deep(v)}
16
- else
17
- value
18
- end
19
- end
20
-
21
7
  def keys_to_sym_deep(value)
22
- transform_keys_deep(value) {|k| k.to_sym}
8
+ transform_keys_deep(value, &:to_sym)
23
9
  end
24
10
 
25
11
  def keys_to_s_deep(value)
26
- transform_keys_deep(value) {|k| k.to_s}
12
+ transform_keys_deep(value, &:to_s)
27
13
  end
28
14
 
29
- def remove_nil_keys_deep(value, target: [])
30
- target = [target].flatten.compact unless target.is_a?(Array)
31
- return value if target.empty?
32
- case value
33
- when Hash
34
- value.dup.each_with_object({}) do |(k, v), out|
35
- next unless v || !target.include?(k)
36
- out[k] = remove_nil_keys_deep(v, target: target)
37
- end
38
- when Enumerable
39
- value.map {|v| remove_nil_keys_deep(v, target: target)}
40
- else
41
- value
15
+ def except_keys(value, *keys)
16
+ return value unless value.is_a?(Hash)
17
+
18
+ deep_dup(value).tap do |out|
19
+ keys.each {|key| out.delete(key)}
42
20
  end
43
21
  end
44
22
 
23
+ # Targetted removal of keys in `target` that are `nil`
24
+ def remove_nil_keys_deep(value, target: [])
25
+ remove_keys_deep_if(value, target: target, &:nil?)
26
+ end
27
+
28
+ # Based on Rails support.
45
29
  def deep_dup(data)
46
30
  case data
47
31
  when Hash
48
- data.each_with_object({}) do |(k,v), copy|
32
+ data.each_with_object({}) do |(k, v), copy|
49
33
  if k.is_a?(::String) || k.is_a?(::Symbol)
50
34
  copy[k] = deep_dup(v)
51
35
  else
@@ -59,6 +43,52 @@ module Ecoportal
59
43
  data.dup
60
44
  end
61
45
  end
46
+
47
+ private
48
+
49
+ # Iterator
50
+ # @param value [Variadic]
51
+ # @return [value.class]
52
+ def transform_keys_deep(value, &block)
53
+ case value
54
+ when Hash
55
+ value.dup.each_with_object({}) do |(k, v), out|
56
+ k_val = block_given?? yield(k) : k
57
+ out[k_val] = transform_keys_deep(v, &block)
58
+ end
59
+ when Enumerable
60
+ value.map {|v| transform_keys_deep(v, &block)}
61
+ else
62
+ value
63
+ end
64
+ end
65
+
66
+ # Targetted removal of keys in `target` that meet
67
+ # the `block` condition.
68
+ # @param value [Variadic]
69
+ # @param target [Array<String>, Array<Symbol>] the target
70
+ # `keys` to yield `block` onto.
71
+ # @return [value.class]
72
+ def remove_keys_deep_if(value, target: [], &block)
73
+ msg = 'Expected block. None given.'
74
+ raise ArgumentError, msg unless block_given?
75
+
76
+ target = [target].flatten.compact
77
+ return value if target.empty?
78
+
79
+ case value
80
+ when Hash
81
+ value.dup.each_with_object({}) do |(k, v), out|
82
+ next if yield(v) && target.include?(k) # skip
83
+
84
+ out[k] = remove_nil_keys_deep(v, target: target, &block)
85
+ end
86
+ when Enumerable
87
+ value.map {|v| remove_nil_keys_deep(v, target: target, &block)}
88
+ else
89
+ value
90
+ end
91
+ end
62
92
  end
63
93
 
64
94
  module ClassMethods
@@ -16,19 +16,13 @@ module Ecoportal
16
16
  attr_reader :host, :version
17
17
 
18
18
  def initialize(
19
- api_key: nil,
20
- version: nil,
21
- host: 'live.ecoportal.com',
22
- logger: ::Logger.new(IO::NULL),
23
- deep_logging: false
19
+ api_key: nil,
20
+ version: nil,
21
+ host: 'live.ecoportal.com',
22
+ logger: ::Logger.new(IO::NULL),
23
+ deep_logging: false
24
24
  )
25
- super(
26
- api_key: api_key,
27
- version: version,
28
- host: host,
29
- logger: logger,
30
- deep_logging: deep_logging
31
- )
25
+ super
32
26
  end
33
27
 
34
28
  def refresh_key(value)
@@ -0,0 +1,40 @@
1
+ module Ecoportal
2
+ module API
3
+ module Common
4
+ module GraphQL
5
+ class Model
6
+ module AsInput
7
+ class << self
8
+ def included(base)
9
+ super
10
+ base.send(:include, Model::Diffable)
11
+ base.extend ClassMethods
12
+ end
13
+ end
14
+
15
+ module ClassMethods
16
+ def as_input(hash, clientMutationId: '')
17
+ hash_input = Ecoportal::API::Common::GraphQL::HashHelpers.
18
+ keys_to_sym_deep(hash)
19
+
20
+ hash_input.merge!(clientMutationId: clientMutationId)
21
+
22
+ Ecoportal::API::Common::GraphQL::HashHelpers.
23
+ remove_nil_keys_deep(hash_input, target: :id)
24
+ end
25
+ end
26
+
27
+ # INSTANCE METHODS
28
+
29
+ def as_input(clientMutationId: '')
30
+ self.class.as_input(
31
+ as_update,
32
+ clientMutationId: clientMutationId
33
+ )
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,60 @@
1
+ # rubocop:disable Naming/MethodParameterName
2
+
3
+ module Ecoportal
4
+ module API
5
+ module Common
6
+ module GraphQL
7
+ class Model
8
+ module Diffable
9
+ module HashDiff
10
+ class << self
11
+ def included(base)
12
+ super
13
+ base.extend ClassMethods
14
+ end
15
+ end
16
+
17
+ module ClassMethods
18
+ # @todo: refactor to only reach the current level
19
+ # @note the aim is to delegate `hash_diff` to the specific classes
20
+ # of the model... bulding the payload/input_base in a cascaded
21
+ # way (rather than in a one-off way from the top alone).
22
+ def hash_diff(a, b, ignore: [])
23
+ case a
24
+ when Hash
25
+ {}.tap do |diffed|
26
+ a.each do |key, a_value|
27
+ b_value = b && b[key]
28
+ no_changes = (a_value == b_value) || ignore.include?(key)
29
+ next if !ID_KEYS.include?(key) && no_changes
30
+
31
+ diffed[key] = diff(a_value, b_value, ignore: ignore)
32
+ diffed.delete(key) if diffed[key] == {}
33
+ end
34
+
35
+ # All keys are IDs, so it's actually blank
36
+ return {} if (diffed.keys - ID_KEYS).empty?
37
+ end
38
+ when Array
39
+ return a unless b.is_a?(Array) && a.length == b.length
40
+
41
+ a.map.with_index do |a_value, idx|
42
+ b_value = b[idx]
43
+ diff(a_value, b_value, ignore: ignore)
44
+ end.reject do |el|
45
+ el == {}
46
+ end
47
+ else
48
+ a
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+
60
+ # rubocop:enable Naming/MethodParameterName
@@ -0,0 +1,32 @@
1
+ require 'ecoportal/api/common/graphql/model/diffable/hash_diff'
2
+ module Ecoportal
3
+ module API
4
+ module Common
5
+ module GraphQL
6
+ class Model
7
+ module Diffable
8
+ class << self
9
+ def included(base)
10
+ super
11
+ base.send(:include, HashDiff)
12
+ end
13
+ end
14
+
15
+ # INSTANCE METHODS
16
+
17
+ def as_update(ref = :last, ignore: [])
18
+ new_doc = as_json
19
+ ref_doc = ref == :total ? initial_doc : original_doc
20
+
21
+ self.class.hash_diff(
22
+ new_doc,
23
+ ref_doc,
24
+ ignore: ignore
25
+ )
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,17 @@
1
+ module Ecoportal
2
+ module API
3
+ module Common
4
+ module GraphQL
5
+ class Model < Ecoportal::API::Common::Content::DoubleModel
6
+ require 'ecoportal/api/common/graphql/model/diffable'
7
+ require 'ecoportal/api/common/graphql/model/as_input'
8
+
9
+ include Ecoportal::API::Common::GraphQL::ClassHelpers
10
+
11
+ include Diffable
12
+ include AsInput
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -15,7 +15,7 @@ module Ecoportal
15
15
  # @return [Connection::$1, $1]
16
16
  def query(method, query_klass:, subpath: [])
17
17
  method = method.to_sym
18
- class_method = "#{method}_query_class".to_sym
18
+ class_method = :"#{method}_query_class"
19
19
 
20
20
  define_method(method) do |**kargs, &block|
21
21
  if kargs.empty? && !block_given?
@@ -27,9 +27,12 @@ module Ecoportal
27
27
 
28
28
  define_method(class_method) do
29
29
  final_path = path + [subpath].flatten.compact
30
+
30
31
  resolve_class(query_klass).tap do |klass|
31
32
  unless klass <= Ecoportal::API::GraphQL::Logic::BaseQuery
32
- raise "Expected query_klass to be of type Ecoportal::API::GraphQL::Logic::BaseQuery. Given: #{klass}"
33
+ msg = "Expected query_klass to be of type Ecoportal::API::GraphQL::Logic::BaseQuery. "
34
+ msg << "Given: #{klass}"
35
+ raise msg
33
36
  end
34
37
  end.new(client, base_path: final_path)
35
38
  end
@@ -11,7 +11,6 @@ require 'ecoportal/api/common/graphql/http_client'
11
11
  require 'ecoportal/api/common/graphql/auth_service'
12
12
  require 'ecoportal/api/common/graphql/client'
13
13
  require 'ecoportal/api/common/graphql/class_helpers'
14
- require 'ecoportal/api/common/graphql/doc_helpers'
15
14
  require 'ecoportal/api/common/graphql/hash_helpers'
16
- require 'ecoportal/api/common/graphql/patches'
15
+ require 'ecoportal/api/common/graphql/model'
17
16
  require 'ecoportal/api/common/graphql/query_integration'
@@ -3,12 +3,14 @@ module Ecoportal
3
3
  class GraphQL
4
4
  module Base
5
5
  class Action < Ecoportal::API::GraphQL::Base::Model
6
+ root!
7
+
6
8
  passkey :id
7
9
  passthrough :altId
8
10
  passthrough :name, :description
9
11
  passthrough :age
10
12
 
11
- passarray :tags, :location
13
+ passarray :locationIds
12
14
 
13
15
  passthrough :status, :relativeStatus
14
16
  passboolean :archived, :attached, :standaloneAction
@@ -3,8 +3,10 @@ module Ecoportal
3
3
  class GraphQL
4
4
  module Base
5
5
  class ActionCategory < Ecoportal::API::GraphQL::Base::Model
6
+ root!
7
+
6
8
  passkey :id
7
- passthrough :name, :value
9
+ passthrough :name, :value, :weight
8
10
  passboolean :archived
9
11
  end
10
12
  end
@@ -3,6 +3,8 @@ module Ecoportal
3
3
  class GraphQL
4
4
  module Base
5
5
  class ContractorEntity < Ecoportal::API::GraphQL::Base::Model
6
+ root!
7
+
6
8
  passkey :id
7
9
  passthrough :externalId
8
10
  passthrough :name
@@ -3,7 +3,7 @@ module Ecoportal
3
3
  class GraphQL
4
4
  module Base
5
5
  class LocationClassificationType < Ecoportal::API::GraphQL::Base::Model
6
- read_only!
6
+ root!
7
7
 
8
8
  passkey :id
9
9
  passthrough :name
@@ -3,6 +3,8 @@ module Ecoportal
3
3
  class GraphQL
4
4
  module Base
5
5
  class LocationNode < Ecoportal::API::GraphQL::Base::Model
6
+ root!
7
+
6
8
  passkey :id
7
9
  passthrough :name
8
10
  passthrough :weight
@@ -4,6 +4,7 @@ module Ecoportal
4
4
  module Base
5
5
  class LocationStructure < Ecoportal::API::GraphQL::Base::Model
6
6
  read_only!
7
+
7
8
  extend Ecoportal::API::GraphQL::Helpers::LocationsTree
8
9
 
9
10
  passkey :id
@@ -2,29 +2,9 @@ module Ecoportal
2
2
  module API
3
3
  class GraphQL
4
4
  module Base
5
- class Model < Ecoportal::API::Common::Content::DoubleModel
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 Base
5
5
  class Organization < Ecoportal::API::GraphQL::Base::Model
6
+ root!
7
+
6
8
  passkey :id
7
9
  passthrough :name, :companyName
8
10
  passthrough :logoUrl, read_only: true
@@ -3,6 +3,8 @@ module Ecoportal
3
3
  class GraphQL
4
4
  module Base
5
5
  class Page < Ecoportal::API::GraphQL::Base::Model
6
+ root!
7
+
6
8
  passkey :id
7
9
  passthrough :mouldCounter, :name
8
10
  end
@@ -3,6 +3,8 @@ module Ecoportal
3
3
  class GraphQL
4
4
  module Base
5
5
  class PersonMember < Ecoportal::API::GraphQL::Base::Model
6
+ root!
7
+
6
8
  passkey :id
7
9
  passthrough :name, :email
8
10
  passarray :tagRestrict, :userGroupIds