ibrain-core 0.4.5 → 0.4.6

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 (85) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/ibrain/base_controller.rb +12 -14
  3. data/app/controllers/ibrain/core/graphql_controller.rb +79 -83
  4. data/app/graphql/ibrain/base_schema.rb +50 -52
  5. data/app/graphql/ibrain/extentions/default_value.rb +7 -11
  6. data/app/graphql/ibrain/extentions/roles.rb +15 -20
  7. data/app/graphql/ibrain/extentions/session_required.rb +10 -14
  8. data/app/graphql/ibrain/lazy/base.rb +2 -6
  9. data/app/graphql/ibrain/loaders/association_loader.rb +51 -55
  10. data/app/graphql/ibrain/mutations/base_mutation.rb +52 -56
  11. data/app/graphql/ibrain/policies/base_policy.rb +43 -47
  12. data/app/graphql/ibrain/policies/graphql_policy.rb +2 -6
  13. data/app/graphql/ibrain/resolvers/base_aggregate.rb +6 -10
  14. data/app/graphql/ibrain/resolvers/base_resolver.rb +8 -12
  15. data/app/graphql/ibrain/types/aggregate_type.rb +4 -8
  16. data/app/graphql/ibrain/types/attribute_type.rb +2 -5
  17. data/app/graphql/ibrain/types/base_api_connection.rb +6 -10
  18. data/app/graphql/ibrain/types/base_api_edge.rb +4 -8
  19. data/app/graphql/ibrain/types/base_api_field.rb +7 -11
  20. data/app/graphql/ibrain/types/base_api_object.rb +6 -10
  21. data/app/graphql/ibrain/types/base_argument.rb +3 -7
  22. data/app/graphql/ibrain/types/base_connection.rb +7 -11
  23. data/app/graphql/ibrain/types/base_edge.rb +3 -7
  24. data/app/graphql/ibrain/types/base_enum.rb +1 -5
  25. data/app/graphql/ibrain/types/base_field.rb +6 -10
  26. data/app/graphql/ibrain/types/base_input_object.rb +6 -10
  27. data/app/graphql/ibrain/types/base_interface.rb +5 -9
  28. data/app/graphql/ibrain/types/base_object.rb +12 -16
  29. data/app/graphql/ibrain/types/base_scalar.rb +1 -5
  30. data/app/graphql/ibrain/types/base_type.rb +4 -10
  31. data/app/graphql/ibrain/types/base_union.rb +3 -7
  32. data/app/graphql/ibrain/types/filter_type.rb +1 -5
  33. data/app/graphql/ibrain/types/node_type.rb +4 -8
  34. data/app/graphql/ibrain/util/field_combiner.rb +5 -9
  35. data/app/graphql/ibrain/util/query_combiner.rb +4 -8
  36. data/app/models/concerns/ibrain/soft_deletable.rb +6 -8
  37. data/app/models/concerns/ibrain/user_api_authentication.rb +14 -16
  38. data/app/models/concerns/ibrain/user_methods.rb +11 -13
  39. data/app/models/ibrain/ability.rb +31 -32
  40. data/app/models/ibrain/aggregate.rb +5 -7
  41. data/app/models/ibrain/application_record.rb +2 -4
  42. data/app/models/ibrain/legacy_user.rb +7 -13
  43. data/app/models/ibrain/role.rb +6 -8
  44. data/app/models/ibrain/role_user.rb +8 -10
  45. data/app/repositories/ibrain/base_repository.rb +9 -11
  46. data/lib/generators/ibrain/core/model_generator.rb +17 -21
  47. data/lib/generators/ibrain/graphql/core.rb +55 -59
  48. data/lib/generators/ibrain/graphql/mutation_generator.rb +58 -66
  49. data/lib/generators/ibrain/graphql/object_generator.rb +58 -70
  50. data/lib/generators/ibrain/graphql/resolver_generator.rb +17 -25
  51. data/lib/generators/ibrain/graphql/resolvers_generator.rb +59 -67
  52. data/lib/generators/ibrain/graphql/templates/aggregate.erb +5 -7
  53. data/lib/generators/ibrain/graphql/templates/input.erb +5 -9
  54. data/lib/generators/ibrain/graphql/templates/mutation.erb +24 -26
  55. data/lib/generators/ibrain/graphql/templates/object.erb +6 -10
  56. data/lib/generators/ibrain/graphql/templates/resolver.erb +9 -11
  57. data/lib/generators/ibrain/graphql/templates/resolvers.erb +8 -10
  58. data/lib/generators/ibrain/graphql/type_generator.rb +84 -88
  59. data/lib/generators/ibrain/install/install_generator.rb +137 -140
  60. data/lib/generators/ibrain/install/templates/graphql/types/mutation_type.rb.tt +13 -15
  61. data/lib/generators/ibrain/install/templates/graphql/types/query_type.rb.tt +11 -13
  62. data/lib/generators/ibrain/install/templates/rubocop.yml.tt +83 -30
  63. data/lib/ibrain/app_configuration.rb +34 -36
  64. data/lib/ibrain/core/class_constantizer.rb +30 -33
  65. data/lib/ibrain/core/controller_helpers/auth.rb +53 -59
  66. data/lib/ibrain/core/controller_helpers/current_host.rb +5 -11
  67. data/lib/ibrain/core/controller_helpers/response.rb +43 -49
  68. data/lib/ibrain/core/controller_helpers/strong_parameters.rb +9 -15
  69. data/lib/ibrain/core/engine.rb +5 -9
  70. data/lib/ibrain/core/environment.rb +5 -9
  71. data/lib/ibrain/core/environment_extension.rb +13 -17
  72. data/lib/ibrain/core/role_configuration.rb +52 -54
  73. data/lib/ibrain/core/validators/email.rb +15 -17
  74. data/lib/ibrain/core/version.rb +2 -2
  75. data/lib/ibrain/core/versioned_value.rb +61 -65
  76. data/lib/ibrain/encryptor.rb +18 -20
  77. data/lib/ibrain/logger.rb +13 -15
  78. data/lib/ibrain/permission_sets/base.rb +22 -26
  79. data/lib/ibrain/permission_sets/super_user.rb +3 -7
  80. data/lib/ibrain/permitted_attributes.rb +18 -20
  81. data/lib/ibrain/preferences/configuration.rb +135 -137
  82. data/lib/ibrain/preferences/preferable.rb +158 -162
  83. data/lib/ibrain/preferences/preferable_class_methods.rb +112 -114
  84. data/lib/ibrain/user_class_handle.rb +22 -24
  85. metadata +2 -2
@@ -1,73 +1,69 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Ibrain
4
- module Mutations
5
- class BaseMutation < GraphQL::Schema::RelayClassicMutation
6
- argument_class Types::BaseArgument
7
- field_class Types::BaseField
8
- input_object_class Types::BaseInputObject
9
- object_class Types::BaseObject
3
+ class Ibrain::Mutations::BaseMutation < GraphQL::Schema::RelayClassicMutation
4
+ argument_class Types::BaseArgument
5
+ field_class Types::BaseField
6
+ input_object_class Types::BaseInputObject
7
+ object_class Types::BaseObject
10
8
 
11
- argument :attribute, Types::AttributeType, required: false
12
- argument :attributes, [Types::AttributeType], required: false
9
+ argument :attribute, Types::AttributeType, required: false
10
+ argument :attributes, [Types::AttributeType], required: false
13
11
 
14
- def ready?(args)
15
- @params = ActionController::Parameters.new(
16
- args.to_h.with_indifferent_access.transform_keys(&:underscore)
17
- )
18
- @resource = load_resource
19
- true
20
- end
12
+ def ready?(args)
13
+ @params = ActionController::Parameters.new(
14
+ args.to_h.with_indifferent_access.transform_keys(&:underscore)
15
+ )
16
+ @resource = load_resource
17
+ true
18
+ end
21
19
 
22
- protected
20
+ protected
23
21
 
24
- attr_reader :params, :resource
22
+ attr_reader :params, :resource
25
23
 
26
- def upload_permitted
27
- %i[content_type headers original_filename tempfile]
28
- end
24
+ def upload_permitted
25
+ %i[content_type headers original_filename tempfile]
26
+ end
29
27
 
30
- def cryptor
31
- ::Ibrain::Encryptor.new
32
- end
28
+ def cryptor
29
+ ::Ibrain::Encryptor.new
30
+ end
33
31
 
34
- def current_user
35
- context[:current_user]
36
- end
32
+ def current_user
33
+ context[:current_user]
34
+ end
37
35
 
38
- def controller
39
- context[:controller]
40
- end
36
+ def controller
37
+ context[:controller]
38
+ end
41
39
 
42
- def session
43
- context[:session]
44
- end
40
+ def session
41
+ context[:session]
42
+ end
45
43
 
46
- def request
47
- context[:request]
48
- end
44
+ def request
45
+ context[:request]
46
+ end
49
47
 
50
- def graphql_return
51
- {
52
- returning: resource.reload
53
- }
54
- end
48
+ def graphql_return
49
+ {
50
+ returning: resource.reload
51
+ }
52
+ end
55
53
 
56
- def success_response
57
- {
58
- success: true
59
- }
60
- end
54
+ def success_response
55
+ {
56
+ success: true
57
+ }
58
+ end
61
59
 
62
- def id_from_params
63
- params[:id]
64
- end
60
+ def id_from_params
61
+ params[:id]
62
+ end
65
63
 
66
- def attribute_params
67
- params[:attributes].to_params
68
- rescue StandardError
69
- ActionController::Parameters.new({})
70
- end
71
- end
64
+ def attribute_params
65
+ params[:attributes].to_params
66
+ rescue StandardError
67
+ ActionController::Parameters.new({})
72
68
  end
73
- end
69
+ end
@@ -1,51 +1,47 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Ibrain
4
- module Policies
5
- class BasePolicy
6
- class << self
7
- def query_rules
8
- {
9
- '*': {
10
- guard: ->(_obj, _args, _ctx) { false }
11
- }
12
- }
13
- end
14
-
15
- def mutation_rules
16
- {
17
- '*': {
18
- guard: ->(_obj, _args, _ctx) { false }
19
- }
20
- }
21
- end
22
-
23
- def rules
24
- {
25
- 'Types::QueryType' => query_rules,
26
- 'Types::MutationType' => mutation_rules
27
- }.freeze
28
- end
29
-
30
- def roles
31
- Ibrain.user_class.roles.keys
32
- end
33
-
34
- def has_permission?(current_user, resource)
35
- return false if current_user.blank?
36
- return true if current_user.super_admin?
37
-
38
- current_user.try(:scope).to_s.split(',').include?(resource)
39
- end
40
-
41
- def guard(type, field)
42
- rules.dig(type.name, field, :guard)
43
- end
44
-
45
- def not_authorized_handler(type, field)
46
- rules.dig(type, field, :not_authorized) || rules.dig(type, :*, :not_authorized)
47
- end
48
- end
3
+ class Ibrain::Policies::BasePolicy
4
+ class << self
5
+ def query_rules
6
+ {
7
+ '*': {
8
+ guard: ->(_obj, _args, _ctx) { false }
9
+ }
10
+ }
11
+ end
12
+
13
+ def mutation_rules
14
+ {
15
+ '*': {
16
+ guard: ->(_obj, _args, _ctx) { false }
17
+ }
18
+ }
19
+ end
20
+
21
+ def rules
22
+ {
23
+ 'Types::QueryType' => query_rules,
24
+ 'Types::MutationType' => mutation_rules
25
+ }.freeze
26
+ end
27
+
28
+ def roles
29
+ Ibrain.user_class.roles.keys
30
+ end
31
+
32
+ def has_permission?(current_user, resource)
33
+ return false if current_user.blank?
34
+ return true if current_user.super_admin?
35
+
36
+ current_user.try(:scope).to_s.split(',').include?(resource)
37
+ end
38
+
39
+ def guard(type, field)
40
+ rules.dig(type.name, field, :guard)
41
+ end
42
+
43
+ def not_authorized_handler(type, field)
44
+ rules.dig(type, field, :not_authorized) || rules.dig(type, :*, :not_authorized)
49
45
  end
50
46
  end
51
- end
47
+ end
@@ -1,8 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Ibrain
4
- module Policies
5
- class GraphqlPolicy < BasePolicy
6
- end
7
- end
8
- end
3
+ class Ibrain::Policies::GraphqlPolicy < BasePolicy
4
+ end
@@ -1,13 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Ibrain
4
- module Resolvers
5
- class BaseAggregate < BaseResolver
6
- type Ibrain::Types::BaseObject.connection_type, null: false
3
+ class Ibrain::Resolvers::BaseAggregate < BaseResolver
4
+ type Ibrain::Types::BaseObject.connection_type, null: false
7
5
 
8
- argument :where, Ibrain::Types::FilterType, required: false, default_value: nil
9
- argument :limit, Int, required: false, default_value: 10
10
- argument :offset, Int, required: false, default_value: 0
11
- end
12
- end
13
- end
6
+ argument :where, Ibrain::Types::FilterType, required: false, default_value: nil
7
+ argument :limit, Int, required: false, default_value: 10
8
+ argument :offset, Int, required: false, default_value: 0
9
+ end
@@ -1,17 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Ibrain
4
- module Resolvers
5
- class BaseResolver < GraphQL::Schema::Resolver
6
- argument_class ::Ibrain::Types::BaseArgument
3
+ class Ibrain::Resolvers::BaseResolver < GraphQL::Schema::Resolver
4
+ argument_class ::Ibrain::Types::BaseArgument
7
5
 
8
- def current_user
9
- context.fetch(:current_user)
10
- end
6
+ def current_user
7
+ context.fetch(:current_user)
8
+ end
11
9
 
12
- def controller
13
- context[:controller]
14
- end
15
- end
10
+ def controller
11
+ context[:controller]
16
12
  end
17
- end
13
+ end
@@ -1,11 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Ibrain
4
- module Types
5
- class AggregateType < BaseObject
6
- graphql_name 'aggregate'
3
+ class Ibrain::Types::AggregateType < Ibrain::Types::BaseObject
4
+ graphql_name 'aggregate'
7
5
 
8
- field :count, Int, null: false
9
- end
10
- end
11
- end
6
+ field :count, Int, null: false
7
+ end
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Ibrain
4
- module Types
5
- class AttributeType < BaseScalar
6
- end
7
- end
3
+
4
+ class Ibrain::Types::AttributeType < Ibrain::Types::BaseScalar
8
5
  end
@@ -1,16 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Ibrain
4
- module Types
5
- class BaseApiConnection < Types::BaseObject
6
- # add `nodes` and `pageInfo` fields, as well as `edge_type(...)` and `node_nullable(...)` overrides
7
- include GraphQL::Types::Relay::ConnectionBehaviors
3
+ class Ibrain::Types::BaseApiConnection < Ibrain::Types::BaseObject
4
+ # add `nodes` and `pageInfo` fields, as well as `edge_type(...)` and `node_nullable(...)` overrides
5
+ include GraphQL::Types::Relay::ConnectionBehaviors
8
6
 
9
- field :aggregate, Ibrain::Types::AggregateType, null: false, camelize: false
7
+ field :aggregate, Ibrain::Types::AggregateType, null: false, camelize: false
10
8
 
11
- def aggregate
12
- Ibrain::Aggregate.new(object.items.size)
13
- end
14
- end
9
+ def aggregate
10
+ Ibrain::Aggregate.new(object.items.size)
15
11
  end
16
12
  end
@@ -1,10 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Ibrain
4
- module Types
5
- class BaseApiEdge < Types::BaseObject
6
- # add `node` and `cursor` fields, as well as `node_type(...)` override
7
- include GraphQL::Types::Relay::EdgeBehaviors
8
- end
9
- end
10
- end
3
+ class Ibrain::Types::BaseApiEdge < Ibrain::Types::BaseObject
4
+ # add `node` and `cursor` fields, as well as `node_type(...)` override
5
+ include GraphQL::Types::Relay::EdgeBehaviors
6
+ end
@@ -1,16 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Ibrain
4
- module Types
5
- class BaseApiField < GraphQL::Schema::Field
6
- argument_class ::Ibrain::Types::BaseArgument
3
+ class Ibrain::Types::BaseApiField < GraphQL::Schema::Field
4
+ argument_class Ibrain::Types::BaseArgument
7
5
 
8
- def initialize(*args, session_required: true, roles: nil, **kwargs, &block)
9
- super(*args, camelize: false, **kwargs, &block)
6
+ def initialize(*args, session_required: true, roles: nil, **kwargs, &block)
7
+ super(*args, camelize: false, **kwargs, &block)
10
8
 
11
- extension(Ibrain::Extentions::SessionRequired, session_required: session_required) if session_required
12
- extension(Ibrain::Extentions::Roles, roles: roles) if roles
13
- end
14
- end
9
+ extension(Ibrain::Extentions::SessionRequired, session_required: session_required) if session_required
10
+ extension(Ibrain::Extentions::Roles, roles: roles) if roles
15
11
  end
16
- end
12
+ end
@@ -1,14 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Ibrain
4
- module Types
5
- class BaseApiObject < GraphQL::Schema::Object
6
- include GraphQL::Relay::Node
3
+ class Ibrain::Types::BaseApiObject < GraphQL::Schema::Object
4
+ include GraphQL::Relay::Node
7
5
 
8
- edge_type_class(Ibrain::Types::BaseApiEdge)
9
- connection_type_class(Ibrain::Types::BaseApiConnection)
6
+ edge_type_class(Ibrain::Types::BaseApiEdge)
7
+ connection_type_class(Ibrain::Types::BaseApiConnection)
10
8
 
11
- field_class Ibrain::Types::BaseApiField
12
- end
13
- end
14
- end
9
+ field_class Ibrain::Types::BaseApiField
10
+ end
@@ -1,11 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Ibrain
4
- module Types
5
- class BaseArgument < GraphQL::Schema::Argument
6
- def initialize(*args, **kwargs, &block)
7
- super(*args, camelize: false, **kwargs, &block)
8
- end
9
- end
3
+ class Ibrain::Types::BaseArgument < GraphQL::Schema::Argument
4
+ def initialize(*args, **kwargs, &block)
5
+ super(*args, camelize: false, **kwargs, &block)
10
6
  end
11
7
  end
@@ -1,16 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Ibrain
4
- module Types
5
- class BaseConnection < Types::BaseObject
6
- # add `nodes` and `pageInfo` fields, as well as `edge_type(...)` and `node_nullable(...)` overrides
7
- include GraphQL::Types::Relay::ConnectionBehaviors
3
+ class Ibrain::Types::BaseConnection < Types::BaseObject
4
+ # add `nodes` and `pageInfo` fields, as well as `edge_type(...)` and `node_nullable(...)` overrides
5
+ include GraphQL::Types::Relay::ConnectionBehaviors
8
6
 
9
- field :aggregate, Ibrain::Types::AggregateType, null: false, camelize: false
7
+ field :aggregate, Ibrain::Types::AggregateType, null: false, camelize: false
10
8
 
11
- def aggregate
12
- Ibrain::Aggregate.new(object.items.size)
13
- end
14
- end
9
+ def aggregate
10
+ Ibrain::Aggregate.new(object.items.size)
15
11
  end
16
- end
12
+ end
@@ -1,10 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Ibrain
4
- module Types
5
- class BaseEdge < Types::BaseObject
6
- # add `node` and `cursor` fields, as well as `node_type(...)` override
7
- include GraphQL::Types::Relay::EdgeBehaviors
8
- end
9
- end
3
+ class Ibrain::Types::BaseEdge < Types::BaseObject
4
+ # add `node` and `cursor` fields, as well as `node_type(...)` override
5
+ include GraphQL::Types::Relay::EdgeBehaviors
10
6
  end
@@ -1,8 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Ibrain
4
- module Types
5
- class BaseEnum < GraphQL::Schema::Enum
6
- end
7
- end
3
+ class Ibrain::Types::BaseEnum < GraphQL::Schema::Enum
8
4
  end
@@ -1,16 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Ibrain
4
- module Types
5
- class BaseField < GraphQL::Schema::Field
6
- argument_class ::Ibrain::Types::BaseArgument
3
+ class Ibrain::Types::BaseField < GraphQL::Schema::Field
4
+ argument_class Ibrain::Types::BaseArgument
7
5
 
8
- def initialize(*args, default_value: nil, roles: nil, **kwargs, &block)
9
- super(*args, camelize: false, **kwargs, &block)
6
+ def initialize(*args, default_value: nil, roles: nil, **kwargs, &block)
7
+ super(*args, camelize: false, **kwargs, &block)
10
8
 
11
- extension(::Ibrain::Extentions::DefaultValue, default_value: default_value) unless default_value.nil?
12
- extension(Ibrain::Extentions::Roles, roles: roles) if roles
13
- end
14
- end
9
+ extension(Ibrain::Extentions::DefaultValue, default_value: default_value) unless default_value.nil?
10
+ extension(Ibrain::Extentions::Roles, roles: roles) if roles
15
11
  end
16
12
  end
@@ -1,15 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Ibrain
4
- module Types
5
- class BaseInputObject < GraphQL::Schema::InputObject
6
- argument_class Ibrain::Types::BaseArgument
3
+ class Ibrain::Types::BaseInputObject < GraphQL::Schema::InputObject
4
+ argument_class Ibrain::Types::BaseArgument
7
5
 
8
- def to_params
9
- ActionController::Parameters.new(
10
- to_h.with_indifferent_access.transform_keys(&:underscore)
11
- )
12
- end
13
- end
6
+ def to_params
7
+ ActionController::Parameters.new(
8
+ to_h.with_indifferent_access.transform_keys(&:underscore)
9
+ )
14
10
  end
15
11
  end
@@ -1,14 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Ibrain
4
- module Types
5
- module BaseInterface
6
- include GraphQL::Schema::Interface
3
+ module Ibrain::Types::BaseInterface
4
+ include GraphQL::Schema::Interface
7
5
 
8
- edge_type_class(Ibrain::Types::BaseEdge)
9
- connection_type_class(Ibrain::Types::BaseConnection)
6
+ edge_type_class(Ibrain::Types::BaseEdge)
7
+ connection_type_class(Ibrain::Types::BaseConnection)
10
8
 
11
- field_class Ibrain::Types::BaseField
12
- end
13
- end
9
+ field_class Ibrain::Types::BaseField
14
10
  end
@@ -1,26 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Ibrain
4
- module Types
5
- class BaseObject < GraphQL::Schema::Object
6
- include GraphQL::Relay::Node
3
+ class Ibrain::Types::BaseObject < GraphQL::Schema::Object
4
+ include GraphQL::Relay::Node
7
5
 
8
- edge_type_class(Ibrain::Types::BaseEdge)
9
- connection_type_class(Ibrain::Types::BaseConnection)
6
+ edge_type_class(Ibrain::Types::BaseEdge)
7
+ connection_type_class(Ibrain::Types::BaseConnection)
10
8
 
11
- field_class ::Ibrain::Types::BaseField
9
+ field_class Ibrain::Types::BaseField
12
10
 
13
- field :name, String, null: true
11
+ field :name, String, null: true
14
12
 
15
- protected
13
+ protected
16
14
 
17
- def loader
18
- Ibrain::Loaders::AssociationLoader
19
- end
15
+ def loader
16
+ Ibrain::Loaders::AssociationLoader
17
+ end
20
18
 
21
- def current_user
22
- context.try(:fetch, :current_user)
23
- end
24
- end
19
+ def current_user
20
+ context.try(:fetch, :current_user)
25
21
  end
26
22
  end
@@ -1,8 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Ibrain
4
- module Types
5
- class BaseScalar < GraphQL::Schema::Scalar
6
- end
7
- end
3
+ class Ibrain::Types::BaseScalar < GraphQL::Schema::Scalar
8
4
  end
@@ -1,13 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Ibrain
4
- module Types
5
- class BaseType < BaseObject
6
- def self.graphql_name(name = "")
7
- return name if name.present?
8
-
9
- self.name.demodulize.gsub('Type', '').classify.constantize.table_name
10
- end
11
- end
3
+ class Ibrain::Types::BaseType < Ibrain::Types::BaseObject
4
+ def self.graphql_name
5
+ self.class.table_name
12
6
  end
13
- end
7
+ end
@@ -1,10 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Ibrain
4
- module Types
5
- class BaseUnion < GraphQL::Schema::Union
6
- edge_type_class(Ibrain::Types::BaseEdge)
7
- connection_type_class(Ibrain::Types::BaseConnection)
8
- end
9
- end
3
+ class Ibrain::Types::BaseUnion < GraphQL::Schema::Union
4
+ edge_type_class(Ibrain::Types::BaseEdge)
5
+ connection_type_class(Ibrain::Types::BaseConnection)
10
6
  end
@@ -1,8 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Ibrain
4
- module Types
5
- class FilterType < GraphQL::Schema::Scalar
6
- end
7
- end
3
+ class Ibrain::Types::FilterType < GraphQL::Schema::Scalar
8
4
  end
@@ -1,11 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Ibrain
4
- module Types
5
- module NodeType
6
- include Ibrain::Types::BaseInterface
7
- # Add the `id` field
8
- include GraphQL::Types::Relay::NodeBehaviors
9
- end
10
- end
3
+ module Ibrain::Types::NodeType
4
+ include Ibrain::Types::BaseInterface
5
+ # Add the `id` field
6
+ include GraphQL::Types::Relay::NodeBehaviors
11
7
  end
@@ -1,13 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Ibrain
4
- module Util
5
- class FieldCombiner
6
- def self.combine(query_types)
7
- Array(query_types).inject({}) do |acc, query_type|
8
- acc.merge!(query_type.fields)
9
- end
10
- end
3
+ class Ibrain::Util::FieldCombiner
4
+ def self.combine(query_types)
5
+ Array(query_types).inject({}) do |acc, query_type|
6
+ acc.merge!(query_type.fields)
11
7
  end
12
8
  end
13
- end
9
+ end