ibrain-core 0.1.4 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/ibrain/base_controller.rb +1 -1
- data/app/controllers/ibrain/graphql_controller.rb +18 -1
- data/app/graphql/ibrain/lazy/base.rb +1 -1
- data/app/graphql/ibrain/mutations/base_mutation.rb +12 -0
- data/app/graphql/ibrain/resolvers/base_resolver.rb +4 -0
- data/app/graphql/ibrain/types/attribute_type.rb +8 -0
- data/app/graphql/ibrain/types/base_node.rb +1 -1
- data/app/models/{ibrain/concerns → concerns/ibrain}/ransackable_attributes.rb +0 -0
- data/app/models/{ibrain/concerns → concerns/ibrain}/soft_deletable.rb +0 -0
- data/app/models/{ibrain/concerns → concerns/ibrain}/user_api_authentication.rb +0 -0
- data/app/models/{ibrain/concerns → concerns/ibrain}/user_methods.rb +0 -2
- data/app/models/ibrain/base.rb +6 -0
- data/app/models/ibrain/legacy_user.rb +1 -1
- data/lib/generators/ibrain/install/install_generator.rb +1 -1
- data/lib/generators/ibrain/install/templates/config/initializers/cors.tt +1 -1
- data/lib/ibrain/core/version.rb +2 -2
- data/lib/ibrain/core.rb +1 -0
- metadata +21 -7
- data/app/graphql/mutations/insert_user.rb +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48487077f193996a5756c2c1e000b4ff5df6bd8e8364b557edcdfc0958a625aa
|
4
|
+
data.tar.gz: ab5e00f8d7c86202c0b13b53d808b26bb9cc60bbd7480e1ee0c012a3e4795df5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 869c5f04e5b7dd23aa84c4159909c63c9913e10dc4c3a1c2832d2a566fd8a2f5dfe52f1a10628695f64b6fdbe8a1d7fec955c38511868c592e6b48c99bb3b682
|
7
|
+
data.tar.gz: ccb1c397c1493b1d788af86f3dca9a368150165825e8ed82af04b06b481a96ed66e376ce3c3f53a6ce2a183f2bf80af83446a7b719d7a66b4e5d0a151251a2d5
|
@@ -2,6 +2,15 @@
|
|
2
2
|
|
3
3
|
module Ibrain
|
4
4
|
class GraphqlController < Ibrain::BaseController
|
5
|
+
include Devise::Controllers::ScopedViews
|
6
|
+
|
7
|
+
before_action :authenticate_user!, unless: :skip_operations
|
8
|
+
before_action :map_user_class_to_request
|
9
|
+
|
10
|
+
helpers = %w(resource scope_name resource_name signed_in_resource
|
11
|
+
resource_class resource_params devise_mapping)
|
12
|
+
helper_method(*helpers)
|
13
|
+
|
5
14
|
def execute
|
6
15
|
query, variables, operation_name = normalize_entity
|
7
16
|
|
@@ -10,7 +19,9 @@ module Ibrain
|
|
10
19
|
variables: variables,
|
11
20
|
context: {
|
12
21
|
session: session,
|
13
|
-
current_user: try_ibrain_current_user
|
22
|
+
current_user: try_ibrain_current_user,
|
23
|
+
controller: self,
|
24
|
+
request: request
|
14
25
|
},
|
15
26
|
operation_name: operation_name
|
16
27
|
)
|
@@ -51,5 +62,11 @@ module Ibrain
|
|
51
62
|
def schema
|
52
63
|
Ibrain::Config.graphql_schema.safe_constantize
|
53
64
|
end
|
65
|
+
|
66
|
+
def map_user_class_to_request
|
67
|
+
return if request.env['devise.mapping'].present?
|
68
|
+
|
69
|
+
request.env['devise.mapping'] = Ibrain.user_class
|
70
|
+
end
|
54
71
|
end
|
55
72
|
end
|
File without changes
|
File without changes
|
File without changes
|
@@ -5,10 +5,8 @@ module Ibrain
|
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
|
7
7
|
include Ibrain::UserApiAuthentication
|
8
|
-
include Ibrain::UserReporting
|
9
8
|
|
10
9
|
included do
|
11
|
-
extend Ibrain::DisplayMoney
|
12
10
|
after_create :auto_generate_ibrain_api_key
|
13
11
|
|
14
12
|
include Ibrain::RansackableAttributes unless included_modules.include?(Ibrain::RansackableAttributes)
|
data/app/models/ibrain/base.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
IGNORE_ATTRIBUTES = %w(id created_at updated_at)
|
4
|
+
|
3
5
|
class Ibrain::Base < Ibrain::ApplicationRecord
|
4
6
|
include ActionView::Helpers::DateHelper
|
5
7
|
|
@@ -49,5 +51,9 @@ class Ibrain::Base < Ibrain::ApplicationRecord
|
|
49
51
|
def adjust_date_for_cdt(datetime)
|
50
52
|
datetime.in_time_zone('UTC')
|
51
53
|
end
|
54
|
+
|
55
|
+
def permitted_attributes
|
56
|
+
column_names.reject { |k| IGNORE_ATTRIBUTES.include?(k) }
|
57
|
+
end
|
52
58
|
end
|
53
59
|
end
|
@@ -55,7 +55,7 @@ module Ibrain
|
|
55
55
|
Would you like to install it? (Y/n)"))
|
56
56
|
|
57
57
|
@plugins_to_be_installed << 'ibrain-auth' unless system('gem list | grep ibrain-auth')
|
58
|
-
@plugin_generators_to_run <<
|
58
|
+
@plugin_generators_to_run << "ibrain:auth:install --with-ridgpole=#{options[:with_ridgepole]}"
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
data/lib/ibrain/core/version.rb
CHANGED
data/lib/ibrain/core.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ibrain-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tai Nguyen Van
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord-session_store
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 1.15.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: discard
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.2'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.2'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: friendly_id
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -183,6 +197,7 @@ files:
|
|
183
197
|
- app/graphql/ibrain/resolvers/base_aggregate.rb
|
184
198
|
- app/graphql/ibrain/resolvers/base_resolver.rb
|
185
199
|
- app/graphql/ibrain/types/aggregate_type.rb
|
200
|
+
- app/graphql/ibrain/types/attribute_type.rb
|
186
201
|
- app/graphql/ibrain/types/base_argument.rb
|
187
202
|
- app/graphql/ibrain/types/base_connection.rb
|
188
203
|
- app/graphql/ibrain/types/base_edge.rb
|
@@ -199,14 +214,13 @@ files:
|
|
199
214
|
- app/graphql/ibrain/types/node_type.rb
|
200
215
|
- app/graphql/ibrain/util/field_combiner.rb
|
201
216
|
- app/graphql/ibrain/util/query_combiner.rb
|
202
|
-
- app/
|
217
|
+
- app/models/concerns/ibrain/ransackable_attributes.rb
|
218
|
+
- app/models/concerns/ibrain/soft_deletable.rb
|
219
|
+
- app/models/concerns/ibrain/user_api_authentication.rb
|
220
|
+
- app/models/concerns/ibrain/user_methods.rb
|
203
221
|
- app/models/ibrain/ability.rb
|
204
222
|
- app/models/ibrain/application_record.rb
|
205
223
|
- app/models/ibrain/base.rb
|
206
|
-
- app/models/ibrain/concerns/ransackable_attributes.rb
|
207
|
-
- app/models/ibrain/concerns/soft_deletable.rb
|
208
|
-
- app/models/ibrain/concerns/user_api_authentication.rb
|
209
|
-
- app/models/ibrain/concerns/user_methods.rb
|
210
224
|
- app/models/ibrain/legacy_user.rb
|
211
225
|
- app/models/ibrain/role.rb
|
212
226
|
- app/models/ibrain/role_user.rb
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Ibrain
|
4
|
-
module Mutations
|
5
|
-
class InsertUser < Ibrain::Mutations::BaseMutation
|
6
|
-
# TODO: define return fields
|
7
|
-
# field :post, Types::PostType, null: false
|
8
|
-
|
9
|
-
# TODO: define arguments
|
10
|
-
# argument :name, String, required: true
|
11
|
-
|
12
|
-
# TODO: define resolve method
|
13
|
-
# def resolve(name:)
|
14
|
-
# { post: ... }
|
15
|
-
# end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|