ibrain-core 0.1.9 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -7
- data/app/controllers/ibrain/base_controller.rb +2 -2
- data/lib/generators/ibrain/graphql/templates/resolver.erb +1 -1
- data/lib/generators/ibrain/graphql/templates/resolvers.erb +1 -1
- data/lib/generators/ibrain/install/templates/config/initializers/ibrain.rb.tt +3 -0
- data/lib/ibrain/app_configuration.rb +3 -0
- data/lib/ibrain/core/version.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a04fdcab0c02b1f8a8d58a25dae8cd1bda74a4b296e2aeb219861df4464f008
|
4
|
+
data.tar.gz: baae07824103dcc3c80ab8228b154009242bca6648f3706ab9d5e18f743c9303
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e1d2b42216cdffccbc7e5b1b103f9370c5dc8486a2a30ee5a902295a72c5d606e23881d110bb63715e105c2270834515c931ad49abbd6888437cf34ec97dda3
|
7
|
+
data.tar.gz: cdbc90d0ddaed7d02d76ad69061e84cbd7bc4b6dcfaf82ce4035f994189fbeece3c5452098393e4efdf85a4700b120ed1df8d25fea612fdcd4ce93b2e0b47694
|
data/README.md
CHANGED
@@ -54,20 +54,34 @@ bundle exec rails generate ibrain:graphql:resolvers users --model=User
|
|
54
54
|
For pagination please using aggregate body query, something like
|
55
55
|
```
|
56
56
|
query users($offset: Int, $limit: Int, $filter: Filter) {
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
57
|
+
users(offset: $offset, limit: $limit, filter: $filter) {
|
58
|
+
id
|
59
|
+
first_name
|
60
|
+
}
|
61
61
|
|
62
|
-
|
63
|
-
|
64
|
-
|
62
|
+
users_aggregate(filter: $filter) {
|
63
|
+
total_count
|
64
|
+
}
|
65
65
|
}
|
66
66
|
```
|
67
67
|
To generate graphql mutation to insert, update, delete user
|
68
68
|
```bash
|
69
69
|
bundle exec rails generate ibrain:graphql:mutation insert_user --model=User
|
70
70
|
```
|
71
|
+
|
72
|
+
Default all operation will be rejected if you not have Authorization Token at request header, so to skip authenticate please change `parent_controller` at `ibrain.rb`
|
73
|
+
```
|
74
|
+
config.parent_controller = "<Your parent controller>"
|
75
|
+
```
|
76
|
+
then create method skip_operations at this parent_controller
|
77
|
+
```
|
78
|
+
class ApplicationController < BaseController::API
|
79
|
+
def skip_operations
|
80
|
+
%w[sign_in].include?(operation_name)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
```
|
84
|
+
|
71
85
|
## Contributing
|
72
86
|
Contribution directions go here.
|
73
87
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Ibrain
|
4
|
-
class BaseController <
|
4
|
+
class BaseController < Ibrain::Config.parent_controller.constantize
|
5
5
|
include ActionController::Helpers
|
6
6
|
include Ibrain::Core::ControllerHelpers::Response
|
7
7
|
include Ibrain::Core::ControllerHelpers::StrongParameters
|
@@ -18,7 +18,7 @@ module Ibrain
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def skip_operations
|
21
|
-
|
21
|
+
super || ['IntrospectionQuery'].include?(operation_name)
|
22
22
|
end
|
23
23
|
|
24
24
|
def cryptor
|
@@ -7,7 +7,7 @@ module Resolvers
|
|
7
7
|
# description
|
8
8
|
|
9
9
|
# TODO: define return fields
|
10
|
-
type Types::Objects::<%= model_name.capitalize %>Type, null: false
|
10
|
+
type Types::Objects::<%= model_name.capitalize %>Type, null: false
|
11
11
|
|
12
12
|
argument :id, ID, required: false, description: 'TODO: describe about this argument'
|
13
13
|
|
@@ -7,7 +7,7 @@ module Resolvers
|
|
7
7
|
# description
|
8
8
|
|
9
9
|
# TODO: define return fields
|
10
|
-
type [Types::Objects::<%= model_name.capitalize %>Type], null: false
|
10
|
+
type [Types::Objects::<%= model_name.capitalize %>Type], null: false
|
11
11
|
|
12
12
|
# TODO: define resolve method
|
13
13
|
def resolve(args)
|
@@ -41,6 +41,9 @@ Ibrain.config do |config|
|
|
41
41
|
|
42
42
|
# Graphql Encryptor key
|
43
43
|
# config.ibrain_encryptor_key = Rails.application.secrets.secret_key_base.byteslice(0..31)
|
44
|
+
|
45
|
+
# Parent controller
|
46
|
+
# config.parent_controller = 'ActionController::API'
|
44
47
|
end
|
45
48
|
|
46
49
|
<% if defined?(Ibrain::Api::Engine) -%>
|
@@ -48,6 +48,9 @@ module Ibrain
|
|
48
48
|
# Graphql Encryptor key
|
49
49
|
preference :ibrain_encryptor_key, :string, default: nil
|
50
50
|
|
51
|
+
# Parent controller
|
52
|
+
preference :parent_controller, :string, default: 'ActionController::API'
|
53
|
+
|
51
54
|
def static_model_preferences
|
52
55
|
@static_model_preferences ||= Ibrain::Preferences::StaticModelPreferences.new
|
53
56
|
end
|
data/lib/ibrain/core/version.rb
CHANGED