graphql_devise 0.10.1 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/Appraisals +8 -0
  4. data/CHANGELOG.md +17 -0
  5. data/graphql_devise.gemspec +3 -3
  6. data/lib/graphql_devise.rb +20 -4
  7. data/lib/graphql_devise/default_operations/mutations.rb +20 -0
  8. data/lib/graphql_devise/default_operations/resolvers.rb +12 -0
  9. data/lib/graphql_devise/mount_method/operation_preparer.rb +41 -0
  10. data/lib/graphql_devise/mount_method/operation_preparers/custom_operation_preparer.rb +24 -0
  11. data/lib/graphql_devise/mount_method/operation_preparers/default_operation_preparer.rb +32 -0
  12. data/lib/graphql_devise/mount_method/operation_preparers/gql_name_setter.rb +23 -0
  13. data/lib/graphql_devise/mount_method/operation_preparers/mutation_field_setter.rb +17 -0
  14. data/lib/graphql_devise/mount_method/operation_preparers/resolver_type_setter.rb +17 -0
  15. data/lib/graphql_devise/mount_method/operation_preparers/resource_name_setter.rb +17 -0
  16. data/lib/graphql_devise/mount_method/operation_sanitizer.rb +29 -0
  17. data/lib/graphql_devise/mount_method/option_sanitizer.rb +18 -0
  18. data/lib/graphql_devise/mount_method/option_sanitizers/array_checker.rb +26 -0
  19. data/lib/graphql_devise/mount_method/option_sanitizers/class_checker.rb +26 -0
  20. data/lib/graphql_devise/mount_method/option_sanitizers/hash_checker.rb +24 -0
  21. data/lib/graphql_devise/mount_method/option_sanitizers/string_checker.rb +21 -0
  22. data/lib/graphql_devise/mount_method/option_validators/provided_operations_validator.rb +24 -0
  23. data/lib/graphql_devise/mount_method/option_validators/skip_only_validator.rb +20 -0
  24. data/lib/graphql_devise/mount_method/option_validators/supported_operations_validator.rb +24 -0
  25. data/lib/graphql_devise/mount_method/options_validator.rb +16 -0
  26. data/lib/graphql_devise/mount_method/supported_options.rb +18 -0
  27. data/{app/graphql → lib}/graphql_devise/mutations/base.rb +0 -0
  28. data/{app/graphql → lib}/graphql_devise/mutations/login.rb +0 -0
  29. data/{app/graphql → lib}/graphql_devise/mutations/logout.rb +0 -0
  30. data/{app/graphql → lib}/graphql_devise/mutations/resend_confirmation.rb +0 -0
  31. data/{app/graphql → lib}/graphql_devise/mutations/send_password_reset.rb +0 -0
  32. data/{app/graphql → lib}/graphql_devise/mutations/sign_up.rb +0 -0
  33. data/{app/graphql → lib}/graphql_devise/mutations/update_password.rb +0 -0
  34. data/lib/graphql_devise/rails/routes.rb +57 -85
  35. data/{app/graphql → lib}/graphql_devise/resolvers/base.rb +0 -0
  36. data/{app/graphql → lib}/graphql_devise/resolvers/check_password_token.rb +0 -0
  37. data/{app/graphql → lib}/graphql_devise/resolvers/confirm_account.rb +0 -0
  38. data/{app/graphql → lib}/graphql_devise/resolvers/dummy.rb +0 -0
  39. data/{app/graphql → lib}/graphql_devise/types/authenticatable_type.rb +0 -0
  40. data/{app/graphql → lib}/graphql_devise/types/credential_type.rb +0 -0
  41. data/{app/graphql → lib}/graphql_devise/types/mutation_type.rb +0 -0
  42. data/{app/graphql → lib}/graphql_devise/types/query_type.rb +0 -0
  43. data/lib/graphql_devise/version.rb +1 -1
  44. data/spec/services/mount_method/operation_preparer_spec.rb +30 -0
  45. data/spec/services/mount_method/operation_preparers/custom_operation_preparer_spec.rb +43 -0
  46. data/spec/services/mount_method/operation_preparers/default_operation_preparer_spec.rb +60 -0
  47. data/spec/services/mount_method/operation_preparers/gql_name_setter_spec.rb +16 -0
  48. data/spec/services/mount_method/operation_preparers/mutation_field_setter_spec.rb +16 -0
  49. data/spec/services/mount_method/operation_preparers/resolver_type_setter_spec.rb +16 -0
  50. data/spec/services/mount_method/operation_preparers/resource_name_setter_spec.rb +14 -0
  51. data/spec/services/mount_method/operation_sanitizer_spec.rb +33 -0
  52. data/spec/services/mount_method/option_sanitizer_spec.rb +85 -0
  53. data/spec/services/mount_method/option_sanitizers/array_checker_spec.rb +38 -0
  54. data/spec/services/mount_method/option_sanitizers/class_checker_spec.rb +44 -0
  55. data/spec/services/mount_method/option_sanitizers/hash_checker_spec.rb +85 -0
  56. data/spec/services/mount_method/option_sanitizers/string_checker_spec.rb +30 -0
  57. data/spec/services/mount_method/option_validators/provided_operations_validator_spec.rb +57 -0
  58. data/spec/services/mount_method/option_validators/skip_only_validator_spec.rb +31 -0
  59. data/spec/services/mount_method/option_validators/supported_operations_validator_spec.rb +35 -0
  60. data/spec/services/mount_method/options_validator_spec.rb +36 -0
  61. metadata +79 -39
  62. data/gemfiles/.bundle/config +0 -2
  63. data/gemfiles/rails4.2_graphql1.8.gemfile +0 -10
  64. data/gemfiles/rails5.0_graphql1.8.gemfile +0 -11
  65. data/gemfiles/rails5.0_graphql1.9.gemfile +0 -9
  66. data/gemfiles/rails5.1_graphql1.8.gemfile +0 -11
  67. data/gemfiles/rails5.1_graphql1.9.gemfile +0 -9
  68. data/gemfiles/rails5.2_graphql1.10.gemfile +0 -9
  69. data/gemfiles/rails5.2_graphql1.8.gemfile +0 -11
  70. data/gemfiles/rails5.2_graphql1.9.gemfile +0 -9
  71. data/gemfiles/rails6.0_graphql1.10.gemfile +0 -10
  72. data/gemfiles/rails6.0_graphql1.8.gemfile +0 -10
  73. data/gemfiles/rails6.0_graphql1.9.gemfile +0 -10
  74. data/gemfiles/rails6.0_graphql_edge.gemfile +0 -11
  75. data/gemfiles/rails_edge_graphql_edge.gemfile +0 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b70b800d06fccce1a1622f391cb5584821983cfda8f333ec44fd457f90e7aeec
4
- data.tar.gz: e57b1ba49e7d70175933e27ce6926e2b9b8296c0400d3f182d6f5015b0675901
3
+ metadata.gz: 2b4803d3f6df2467fd64e37ae4e91e9be33f422600b9fc0a920827313c24c843
4
+ data.tar.gz: 152da5a17af638e55375f0e5af21246b26e49c107300d556dca7ba8992456666
5
5
  SHA512:
6
- metadata.gz: 145d52faa01bb66d6fb21de7fc37dfe5e9344e8b02b6c5c0929a54e4ed7e803564bcdabd80c57ec1aab6d5e957a22a7f7c31d1b061c10a321dacac60b3d83a3e
7
- data.tar.gz: 26daabadeb5995fe97a86e7f73d049e46e0d272955316695369b8ec078a5baf48b9f8e18fb31ce4cdebd377837b5aa8f84a06c43cbea55f46ba45ff4258e5df0
6
+ metadata.gz: 33831323626b88ecdcf4805fdc1b097bd66f18af3bebf5319d16dc27a8122672d0666d0d96c638fa4e30f85f1bc24503f2481287eed594bcfa307bce9693eb69
7
+ data.tar.gz: 50d5b6f84ac02367304dc81ad0609b3c5e013eb5c7eff41d5ac3feb4fa415c205810b27872e856a9b672ed621a66f361b2d61106246bf968134d08eee8524dc1
@@ -59,7 +59,7 @@ Style/MethodCalledOnDoEndBlock:
59
59
  Enabled: false
60
60
 
61
61
  Naming/VariableNumber:
62
- Enabled: false
62
+ EnforcedColonStyle: normalcase
63
63
 
64
64
  Style/StringLiterals:
65
65
  ConsistentQuotesInMultiline: true
data/Appraisals CHANGED
@@ -3,6 +3,7 @@ appraise 'rails4.2-graphql1.8' do
3
3
  gem 'bundler', '~> 1.17'
4
4
  gem 'rails', github: 'rails/rails', branch: '4-2-stable'
5
5
  gem 'graphql', '~> 1.8.0'
6
+ gem 'rspec-rails', '< 4.0'
6
7
  end
7
8
 
8
9
  appraise 'rails5.0-graphql1.8' do
@@ -11,12 +12,14 @@ appraise 'rails5.0-graphql1.8' do
11
12
  gem 'graphql', '~> 1.8.0'
12
13
  gem 'devise_token_auth', '0.1.43'
13
14
  gem 'devise', '>= 4.0'
15
+ gem 'rspec-rails', '< 4.0'
14
16
  end
15
17
 
16
18
  appraise 'rails5.0-graphql1.9' do
17
19
  gem 'sqlite3', '~> 1.3.6'
18
20
  gem 'rails', github: 'rails/rails', branch: '5-0-stable'
19
21
  gem 'graphql', '~> 1.9.0'
22
+ gem 'rspec-rails', '< 4.0'
20
23
  end
21
24
 
22
25
  appraise 'rails5.1-graphql1.8' do
@@ -25,12 +28,14 @@ appraise 'rails5.1-graphql1.8' do
25
28
  gem 'graphql', '~> 1.8.0'
26
29
  gem 'devise_token_auth', '0.1.43'
27
30
  gem 'devise', '>= 4.3'
31
+ gem 'rspec-rails', '< 4.0'
28
32
  end
29
33
 
30
34
  appraise 'rails5.1-graphql1.9' do
31
35
  gem 'sqlite3', '~> 1.3.6'
32
36
  gem 'rails', github: 'rails/rails', branch: '5-1-stable'
33
37
  gem 'graphql', '~> 1.9.0'
38
+ gem 'rspec-rails', '< 4.0'
34
39
  end
35
40
 
36
41
  appraise 'rails5.2-graphql1.8' do
@@ -39,18 +44,21 @@ appraise 'rails5.2-graphql1.8' do
39
44
  gem 'graphql', '~> 1.8.0'
40
45
  gem 'devise_token_auth', '0.1.43'
41
46
  gem 'devise', '>= 4.4.2'
47
+ gem 'rspec-rails', '< 4.0'
42
48
  end
43
49
 
44
50
  appraise 'rails5.2-graphql1.9' do
45
51
  gem 'sqlite3', '~> 1.3.6'
46
52
  gem 'rails', github: 'rails/rails', branch: '5-2-stable'
47
53
  gem 'graphql', '~> 1.9.0'
54
+ gem 'rspec-rails', '< 4.0'
48
55
  end
49
56
 
50
57
  appraise 'rails5.2-graphql1.10' do
51
58
  gem 'sqlite3', '~> 1.3.6'
52
59
  gem 'rails', github: 'rails/rails', branch: '5-2-stable'
53
60
  gem 'graphql', '~> 1.10.0'
61
+ gem 'rspec-rails', '< 4.0'
54
62
  end
55
63
 
56
64
  appraise 'rails6.0-graphql1.8' do
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## [v0.11.0](https://github.com/graphql-devise/graphql_devise/tree/v0.11.0) (2020-04-11)
4
+
5
+ [Full Changelog](https://github.com/graphql-devise/graphql_devise/compare/v0.10.1...v0.11.0)
6
+
7
+ **Breaking changes:**
8
+
9
+ - Make Authenticatable type not null [\#80](https://github.com/graphql-devise/graphql_devise/pull/80) ([mcelicalderon](https://github.com/mcelicalderon))
10
+
11
+ **Implemented enhancements:**
12
+
13
+ - Add mount method option sanitizer [\#78](https://github.com/graphql-devise/graphql_devise/pull/78) ([mcelicalderon](https://github.com/mcelicalderon))
14
+
15
+ **Fixed bugs:**
16
+
17
+ - Refactor mount method operations [\#79](https://github.com/graphql-devise/graphql_devise/pull/79) ([mcelicalderon](https://github.com/mcelicalderon))
18
+ - Fix routes GQL ruby \(v1.10.0\) version check [\#74](https://github.com/graphql-devise/graphql_devise/pull/74) ([mcelicalderon](https://github.com/mcelicalderon))
19
+
3
20
  ## [v0.10.1](https://github.com/graphql-devise/graphql_devise/tree/v0.10.1) (2020-03-21)
4
21
 
5
22
  [Full Changelog](https://github.com/graphql-devise/graphql_devise/compare/v0.10.0...v0.10.1)
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
  spec.metadata['homepage_uri'] = spec.homepage
17
17
  spec.metadata['source_code_uri'] = 'https://github.com/graphql-devise/graphql_devise'
18
18
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
19
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|gemfiles)/}) }
20
20
  end
21
21
  spec.bindir = 'exe'
22
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
@@ -37,8 +37,8 @@ Gem::Specification.new do |spec|
37
37
  spec.add_development_dependency 'github_changelog_generator'
38
38
  spec.add_development_dependency 'pry', '~> 0.12.2'
39
39
  spec.add_development_dependency 'pry-byebug'
40
- spec.add_development_dependency 'rake', '~> 10.0'
41
- spec.add_development_dependency 'rspec-rails'
40
+ spec.add_development_dependency 'rake', '>= 12.3.3'
41
+ spec.add_development_dependency 'rspec-rails', '~> 4.0'
42
42
  spec.add_development_dependency 'rubocop', '0.68.1'
43
43
  spec.add_development_dependency 'rubocop-performance'
44
44
  spec.add_development_dependency 'rubocop-rspec'
@@ -1,13 +1,29 @@
1
1
  require 'rails'
2
2
  require 'graphql'
3
3
  require 'devise_token_auth'
4
+
5
+ module GraphqlDevise
6
+ class Error < StandardError; end
7
+
8
+ class InvalidMountOptionsError < GraphqlDevise::Error; end
9
+ end
10
+
11
+ require 'graphql_devise/concerns/controller_methods'
12
+ require 'graphql_devise/types/authenticatable_type'
13
+ require 'graphql_devise/types/credential_type'
14
+ require 'graphql_devise/types/mutation_type'
15
+ require 'graphql_devise/types/query_type'
16
+ require 'graphql_devise/default_operations/mutations'
17
+ require 'graphql_devise/default_operations/resolvers'
18
+ require 'graphql_devise/resolvers/dummy'
19
+
4
20
  require 'graphql_devise/engine'
5
21
  require 'graphql_devise/version'
6
22
  require 'graphql_devise/error_codes'
7
23
  require 'graphql_devise/user_error'
8
24
  require 'graphql_devise/detailed_user_error'
9
- require 'graphql_devise/concerns/controller_methods'
10
25
 
11
- module GraphqlDevise
12
- class Error < StandardError; end
13
- end
26
+ require 'graphql_devise/mount_method/option_sanitizer'
27
+ require 'graphql_devise/mount_method/options_validator'
28
+ require 'graphql_devise/mount_method/operation_preparer'
29
+ require 'graphql_devise/mount_method/operation_sanitizer'
@@ -0,0 +1,20 @@
1
+ require 'graphql_devise/mutations/base'
2
+ require 'graphql_devise/mutations/login'
3
+ require 'graphql_devise/mutations/logout'
4
+ require 'graphql_devise/mutations/resend_confirmation'
5
+ require 'graphql_devise/mutations/send_password_reset'
6
+ require 'graphql_devise/mutations/sign_up'
7
+ require 'graphql_devise/mutations/update_password'
8
+
9
+ module GraphqlDevise
10
+ module DefaultOperations
11
+ MUTATIONS = {
12
+ login: GraphqlDevise::Mutations::Login,
13
+ logout: GraphqlDevise::Mutations::Logout,
14
+ sign_up: GraphqlDevise::Mutations::SignUp,
15
+ update_password: GraphqlDevise::Mutations::UpdatePassword,
16
+ send_password_reset: GraphqlDevise::Mutations::SendPasswordReset,
17
+ resend_confirmation: GraphqlDevise::Mutations::ResendConfirmation
18
+ }.freeze
19
+ end
20
+ end
@@ -0,0 +1,12 @@
1
+ require 'graphql_devise/resolvers/base'
2
+ require 'graphql_devise/resolvers/check_password_token'
3
+ require 'graphql_devise/resolvers/confirm_account'
4
+
5
+ module GraphqlDevise
6
+ module DefaultOperations
7
+ QUERIES = {
8
+ confirm_account: GraphqlDevise::Resolvers::ConfirmAccount,
9
+ check_password_token: GraphqlDevise::Resolvers::CheckPasswordToken
10
+ }.freeze
11
+ end
12
+ end
@@ -0,0 +1,41 @@
1
+ require_relative 'operation_preparers/gql_name_setter'
2
+ require_relative 'operation_preparers/mutation_field_setter'
3
+ require_relative 'operation_preparers/resolver_type_setter'
4
+ require_relative 'operation_preparers/resource_name_setter'
5
+ require_relative 'operation_preparers/default_operation_preparer'
6
+ require_relative 'operation_preparers/custom_operation_preparer'
7
+
8
+ module GraphqlDevise
9
+ module MountMethod
10
+ class OperationPreparer
11
+ def initialize(resource:, selected_operations:, preparer:, custom:, additional_operations:)
12
+ @selected_operations = selected_operations
13
+ @preparer = preparer
14
+ @mapping_name = resource.underscore.tr('/', '_')
15
+ @custom = custom
16
+ @additional_operations = additional_operations
17
+ end
18
+
19
+ def call
20
+ default_operations = OperationPreparers::DefaultOperationPreparer.new(
21
+ selected_operations: @selected_operations,
22
+ custom_keys: @custom.keys,
23
+ mapping_name: @mapping_name,
24
+ preparer: @preparer
25
+ ).call
26
+
27
+ custom_operations = OperationPreparers::CustomOperationPreparer.new(
28
+ selected_keys: @selected_operations.keys,
29
+ custom_operations: @custom,
30
+ mapping_name: @mapping_name
31
+ ).call
32
+
33
+ additional_operations = @additional_operations.each_with_object({}) do |(action, operation), result|
34
+ result[action] = OperationPreparers::ResourceNameSetter.new(@mapping_name).call(operation)
35
+ end
36
+
37
+ default_operations.merge(custom_operations).merge(additional_operations)
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,24 @@
1
+ module GraphqlDevise
2
+ module MountMethod
3
+ module OperationPreparers
4
+ class CustomOperationPreparer
5
+ def initialize(selected_keys:, custom_operations:, mapping_name:)
6
+ @selected_keys = selected_keys
7
+ @custom_operations = custom_operations
8
+ @mapping_name = mapping_name
9
+ end
10
+
11
+ def call
12
+ @custom_operations.slice(*@selected_keys).each_with_object({}) do |(action, operation), result|
13
+ mapped_action = "#{@mapping_name}_#{action}"
14
+
15
+ result[mapped_action.to_sym] = [
16
+ OperationPreparers::GqlNameSetter.new(mapped_action),
17
+ OperationPreparers::ResourceNameSetter.new(@mapping_name)
18
+ ].reduce(operation) { |prepared_operation, preparer| preparer.call(prepared_operation) }
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,32 @@
1
+ module GraphqlDevise
2
+ module MountMethod
3
+ module OperationPreparers
4
+ class DefaultOperationPreparer
5
+ def initialize(selected_operations:, custom_keys:, mapping_name:, preparer:)
6
+ @selected_operations = selected_operations
7
+ @custom_keys = custom_keys
8
+ @mapping_name = mapping_name
9
+ @preparer = preparer
10
+ end
11
+
12
+ def call
13
+ @selected_operations.except(*@custom_keys).each_with_object({}) do |(action, operation), result|
14
+ mapped_action = "#{@mapping_name}_#{action}"
15
+
16
+ result[mapped_action.to_sym] = [
17
+ OperationPreparers::GqlNameSetter.new(mapped_action),
18
+ @preparer,
19
+ OperationPreparers::ResourceNameSetter.new(@mapping_name)
20
+ ].reduce(child_class(operation)) { |prepared_operation, preparer| preparer.call(prepared_operation) }
21
+ end
22
+ end
23
+
24
+ private
25
+
26
+ def child_class(operation)
27
+ Class.new(operation)
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,23 @@
1
+ module GraphqlDevise
2
+ module MountMethod
3
+ module OperationPreparers
4
+ class GqlNameSetter
5
+ def initialize(mapping_name)
6
+ @mapping_name = mapping_name
7
+ end
8
+
9
+ def call(operation)
10
+ operation.graphql_name(graphql_name)
11
+
12
+ operation
13
+ end
14
+
15
+ private
16
+
17
+ def graphql_name
18
+ @mapping_name.camelize(:upper)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,17 @@
1
+ module GraphqlDevise
2
+ module MountMethod
3
+ module OperationPreparers
4
+ class MutationFieldSetter
5
+ def initialize(authenticatable_type)
6
+ @authenticatable_type = authenticatable_type
7
+ end
8
+
9
+ def call(mutation)
10
+ mutation.field(:authenticatable, @authenticatable_type, null: false)
11
+
12
+ mutation
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ module GraphqlDevise
2
+ module MountMethod
3
+ module OperationPreparers
4
+ class ResolverTypeSetter
5
+ def initialize(authenticatable_type)
6
+ @authenticatable_type = authenticatable_type
7
+ end
8
+
9
+ def call(resolver)
10
+ resolver.type(@authenticatable_type, null: false)
11
+
12
+ resolver
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ module GraphqlDevise
2
+ module MountMethod
3
+ module OperationPreparers
4
+ class ResourceNameSetter
5
+ def initialize(name)
6
+ @name = name
7
+ end
8
+
9
+ def call(operation)
10
+ operation.instance_variable_set(:@resource_name, @name.to_sym)
11
+
12
+ operation
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,29 @@
1
+ module GraphqlDevise
2
+ module MountMethod
3
+ class OperationSanitizer
4
+ def self.call(default:, only:, skipped:)
5
+ new(
6
+ default: default,
7
+ only: only,
8
+ skipped: skipped
9
+ ).call
10
+ end
11
+
12
+ def initialize(default:, only:, skipped:)
13
+ @default = default
14
+ @only = only
15
+ @skipped = skipped
16
+ end
17
+
18
+ def call
19
+ if @only.present?
20
+ @default.slice(*@only)
21
+ elsif @skipped.present?
22
+ @default.except(*@skipped)
23
+ else
24
+ @default
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,18 @@
1
+ require_relative 'supported_options'
2
+
3
+ module GraphqlDevise
4
+ module MountMethod
5
+ class OptionSanitizer
6
+ def initialize(options = {}, supported_options = MountMethod::SUPPORTED_OPTIONS)
7
+ @options = options
8
+ @supported_options = supported_options
9
+ end
10
+
11
+ def call!
12
+ @supported_options.each_with_object(Struct.new(*@supported_options.keys).new) do |(key, checker), result|
13
+ result[key] = checker.call!(@options[key], key)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,26 @@
1
+ module GraphqlDevise
2
+ module MountMethod
3
+ module OptionSanitizers
4
+ class ArrayChecker
5
+ def initialize(element_type)
6
+ @element_type = element_type
7
+ @default_value = []
8
+ end
9
+
10
+ def call!(value, key)
11
+ return @default_value if value.blank?
12
+
13
+ unless value.instance_of?(Array)
14
+ raise GraphqlDevise::InvalidMountOptionsError, "`#{key}` option has an invalid value. Array expected."
15
+ end
16
+
17
+ unless value.all? { |element| element.instance_of?(@element_type) }
18
+ raise GraphqlDevise::InvalidMountOptionsError, "`#{key}` option has invalid elements. #{@element_type} expected."
19
+ end
20
+
21
+ value
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end