graphql_rails 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +116 -115
- data/docs/components/routes.md +4 -3
- data/lib/graphql_rails/attributes/type_parseable.rb +1 -7
- data/lib/graphql_rails/controller/log_controller_action.rb +7 -2
- data/lib/graphql_rails/input_configurable.rb +1 -1
- data/lib/graphql_rails/model/find_or_build_graphql_type.rb +1 -5
- data/lib/graphql_rails/router/mutation_route.rb +4 -0
- data/lib/graphql_rails/router/query_route.rb +4 -0
- data/lib/graphql_rails/router/resource_routes_builder.rb +8 -0
- data/lib/graphql_rails/router/schema_builder.rb +12 -3
- data/lib/graphql_rails/router/subscription_route.rb +22 -0
- data/lib/graphql_rails/router.rb +8 -2
- data/lib/graphql_rails/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1909c3b76c9addab63bcc0337232c147ceebde0d1f2252da93606b48d1843c64
|
4
|
+
data.tar.gz: 6b405941e4bae0e98abbcc07b93ac1a95fa22bcbdfcaa962d241740a15453ba7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5292647cd5c49c51bec7f9f1df33be882637ac83bd54fb23259fc2b5c6d8f351f3501c5db23f0ff7c10daafafed531b4026ff3790ff281cfd71890ff2b2c007
|
7
|
+
data.tar.gz: 054adf43e83c54be23fb33547ee521e17ae8f180f5f4c05bf3a7b78f554367e6531483d9bf66af75fe4567940f2931c56f93c2adc6af412efba8e644043af8bc
|
data/CHANGELOG.md
CHANGED
@@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
9
9
|
|
10
10
|
* Added/Changed/Deprecated/Removed/Fixed/Security: YOUR CHANGE HERE
|
11
11
|
|
12
|
+
## [2.2.0](2022-01-25)
|
13
|
+
|
14
|
+
* Added: support for subscription type
|
15
|
+
* Fixed: correctly detect all graphql-ruby objects when using stringified types
|
16
|
+
* Added: make code compatible with newer graphql-ruby version
|
17
|
+
|
12
18
|
## [2.1.0](2022-01-12)
|
13
19
|
|
14
20
|
* Added: decorated relations now can be called using "find", "empty?" and "find_by" methods
|
data/Gemfile.lock
CHANGED
@@ -1,112 +1,111 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
graphql_rails (2.
|
4
|
+
graphql_rails (2.2.0)
|
5
5
|
activesupport (>= 4)
|
6
6
|
graphql (~> 1.12, >= 1.12.4)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
actioncable (6.
|
12
|
-
actionpack (= 6.
|
11
|
+
actioncable (6.1.4.4)
|
12
|
+
actionpack (= 6.1.4.4)
|
13
|
+
activesupport (= 6.1.4.4)
|
13
14
|
nio4r (~> 2.0)
|
14
15
|
websocket-driver (>= 0.6.1)
|
15
|
-
actionmailbox (6.
|
16
|
-
actionpack (= 6.
|
17
|
-
activejob (= 6.
|
18
|
-
activerecord (= 6.
|
19
|
-
activestorage (= 6.
|
20
|
-
activesupport (= 6.
|
16
|
+
actionmailbox (6.1.4.4)
|
17
|
+
actionpack (= 6.1.4.4)
|
18
|
+
activejob (= 6.1.4.4)
|
19
|
+
activerecord (= 6.1.4.4)
|
20
|
+
activestorage (= 6.1.4.4)
|
21
|
+
activesupport (= 6.1.4.4)
|
21
22
|
mail (>= 2.7.1)
|
22
|
-
actionmailer (6.
|
23
|
-
actionpack (= 6.
|
24
|
-
actionview (= 6.
|
25
|
-
activejob (= 6.
|
23
|
+
actionmailer (6.1.4.4)
|
24
|
+
actionpack (= 6.1.4.4)
|
25
|
+
actionview (= 6.1.4.4)
|
26
|
+
activejob (= 6.1.4.4)
|
27
|
+
activesupport (= 6.1.4.4)
|
26
28
|
mail (~> 2.5, >= 2.5.4)
|
27
29
|
rails-dom-testing (~> 2.0)
|
28
|
-
actionpack (6.
|
29
|
-
actionview (= 6.
|
30
|
-
activesupport (= 6.
|
31
|
-
rack (~> 2.0, >= 2.0.
|
30
|
+
actionpack (6.1.4.4)
|
31
|
+
actionview (= 6.1.4.4)
|
32
|
+
activesupport (= 6.1.4.4)
|
33
|
+
rack (~> 2.0, >= 2.0.9)
|
32
34
|
rack-test (>= 0.6.3)
|
33
35
|
rails-dom-testing (~> 2.0)
|
34
36
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
35
|
-
actiontext (6.
|
36
|
-
actionpack (= 6.
|
37
|
-
activerecord (= 6.
|
38
|
-
activestorage (= 6.
|
39
|
-
activesupport (= 6.
|
37
|
+
actiontext (6.1.4.4)
|
38
|
+
actionpack (= 6.1.4.4)
|
39
|
+
activerecord (= 6.1.4.4)
|
40
|
+
activestorage (= 6.1.4.4)
|
41
|
+
activesupport (= 6.1.4.4)
|
40
42
|
nokogiri (>= 1.8.5)
|
41
|
-
actionview (6.
|
42
|
-
activesupport (= 6.
|
43
|
+
actionview (6.1.4.4)
|
44
|
+
activesupport (= 6.1.4.4)
|
43
45
|
builder (~> 3.1)
|
44
46
|
erubi (~> 1.4)
|
45
47
|
rails-dom-testing (~> 2.0)
|
46
48
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
47
|
-
activejob (6.
|
48
|
-
activesupport (= 6.
|
49
|
+
activejob (6.1.4.4)
|
50
|
+
activesupport (= 6.1.4.4)
|
49
51
|
globalid (>= 0.3.6)
|
50
|
-
activemodel (6.
|
51
|
-
activesupport (= 6.
|
52
|
-
activerecord (6.
|
53
|
-
activemodel (= 6.
|
54
|
-
activesupport (= 6.
|
55
|
-
activestorage (6.
|
56
|
-
actionpack (= 6.
|
57
|
-
activejob (= 6.
|
58
|
-
activerecord (= 6.
|
59
|
-
|
60
|
-
|
52
|
+
activemodel (6.1.4.4)
|
53
|
+
activesupport (= 6.1.4.4)
|
54
|
+
activerecord (6.1.4.4)
|
55
|
+
activemodel (= 6.1.4.4)
|
56
|
+
activesupport (= 6.1.4.4)
|
57
|
+
activestorage (6.1.4.4)
|
58
|
+
actionpack (= 6.1.4.4)
|
59
|
+
activejob (= 6.1.4.4)
|
60
|
+
activerecord (= 6.1.4.4)
|
61
|
+
activesupport (= 6.1.4.4)
|
62
|
+
marcel (~> 1.0.0)
|
63
|
+
mini_mime (>= 1.1.0)
|
64
|
+
activesupport (6.1.4.4)
|
61
65
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
62
|
-
i18n (>=
|
63
|
-
minitest (
|
64
|
-
tzinfo (~>
|
65
|
-
zeitwerk (~> 2.
|
66
|
+
i18n (>= 1.6, < 2)
|
67
|
+
minitest (>= 5.1)
|
68
|
+
tzinfo (~> 2.0)
|
69
|
+
zeitwerk (~> 2.3)
|
66
70
|
ast (2.4.2)
|
67
|
-
bson (4.
|
71
|
+
bson (4.14.0)
|
68
72
|
builder (3.2.4)
|
69
73
|
byebug (11.1.3)
|
70
|
-
codecov (0.
|
71
|
-
|
72
|
-
simplecov
|
74
|
+
codecov (0.6.0)
|
75
|
+
simplecov (>= 0.15, < 0.22)
|
73
76
|
coderay (1.1.3)
|
74
|
-
concurrent-ruby (1.1.
|
77
|
+
concurrent-ruby (1.1.9)
|
75
78
|
crass (1.0.6)
|
76
|
-
diff-lcs (1.
|
77
|
-
docile (1.
|
78
|
-
erubi (1.
|
79
|
-
globalid (0.
|
80
|
-
activesupport (>=
|
81
|
-
graphql (1.13.
|
82
|
-
i18n (1.8.
|
79
|
+
diff-lcs (1.5.0)
|
80
|
+
docile (1.4.0)
|
81
|
+
erubi (1.10.0)
|
82
|
+
globalid (1.0.0)
|
83
|
+
activesupport (>= 5.0)
|
84
|
+
graphql (1.13.6)
|
85
|
+
i18n (1.8.11)
|
83
86
|
concurrent-ruby (~> 1.0)
|
84
|
-
|
85
|
-
loofah (2.7.0)
|
87
|
+
loofah (2.13.0)
|
86
88
|
crass (~> 1.0.2)
|
87
89
|
nokogiri (>= 1.5.9)
|
88
90
|
mail (2.7.1)
|
89
91
|
mini_mime (>= 0.1.1)
|
90
|
-
marcel (0.
|
91
|
-
mimemagic (~> 0.3.2)
|
92
|
+
marcel (1.0.2)
|
92
93
|
method_source (1.0.0)
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
mini_portile2 (2.6.1)
|
98
|
-
minitest (5.14.2)
|
99
|
-
mongo (2.13.1)
|
94
|
+
mini_mime (1.1.2)
|
95
|
+
mini_portile2 (2.7.1)
|
96
|
+
minitest (5.15.0)
|
97
|
+
mongo (2.17.0)
|
100
98
|
bson (>= 4.8.2, < 5.0.0)
|
101
|
-
mongoid (7.
|
102
|
-
activemodel (>= 5.1, < 6.
|
103
|
-
mongo (>= 2.
|
104
|
-
|
105
|
-
|
106
|
-
|
99
|
+
mongoid (7.3.3)
|
100
|
+
activemodel (>= 5.1, < 6.2)
|
101
|
+
mongo (>= 2.10.5, < 3.0.0)
|
102
|
+
ruby2_keywords (~> 0.0.5)
|
103
|
+
nio4r (2.5.8)
|
104
|
+
nokogiri (1.13.1)
|
105
|
+
mini_portile2 (~> 2.7.0)
|
107
106
|
racc (~> 1.4)
|
108
|
-
parallel (1.
|
109
|
-
parser (3.0.
|
107
|
+
parallel (1.21.0)
|
108
|
+
parser (3.1.0.0)
|
110
109
|
ast (~> 2.4.1)
|
111
110
|
pry (0.13.1)
|
112
111
|
coderay (~> 1.1)
|
@@ -114,53 +113,53 @@ GEM
|
|
114
113
|
pry-byebug (3.9.0)
|
115
114
|
byebug (~> 11.0)
|
116
115
|
pry (~> 0.13.0)
|
117
|
-
racc (1.
|
116
|
+
racc (1.6.0)
|
118
117
|
rack (2.2.3)
|
119
118
|
rack-test (1.1.0)
|
120
119
|
rack (>= 1.0, < 3)
|
121
|
-
rails (6.
|
122
|
-
actioncable (= 6.
|
123
|
-
actionmailbox (= 6.
|
124
|
-
actionmailer (= 6.
|
125
|
-
actionpack (= 6.
|
126
|
-
actiontext (= 6.
|
127
|
-
actionview (= 6.
|
128
|
-
activejob (= 6.
|
129
|
-
activemodel (= 6.
|
130
|
-
activerecord (= 6.
|
131
|
-
activestorage (= 6.
|
132
|
-
activesupport (= 6.
|
133
|
-
bundler (>= 1.
|
134
|
-
railties (= 6.
|
120
|
+
rails (6.1.4.4)
|
121
|
+
actioncable (= 6.1.4.4)
|
122
|
+
actionmailbox (= 6.1.4.4)
|
123
|
+
actionmailer (= 6.1.4.4)
|
124
|
+
actionpack (= 6.1.4.4)
|
125
|
+
actiontext (= 6.1.4.4)
|
126
|
+
actionview (= 6.1.4.4)
|
127
|
+
activejob (= 6.1.4.4)
|
128
|
+
activemodel (= 6.1.4.4)
|
129
|
+
activerecord (= 6.1.4.4)
|
130
|
+
activestorage (= 6.1.4.4)
|
131
|
+
activesupport (= 6.1.4.4)
|
132
|
+
bundler (>= 1.15.0)
|
133
|
+
railties (= 6.1.4.4)
|
135
134
|
sprockets-rails (>= 2.0.0)
|
136
135
|
rails-dom-testing (2.0.3)
|
137
136
|
activesupport (>= 4.2.0)
|
138
137
|
nokogiri (>= 1.6)
|
139
|
-
rails-html-sanitizer (1.
|
138
|
+
rails-html-sanitizer (1.4.2)
|
140
139
|
loofah (~> 2.3)
|
141
|
-
railties (6.
|
142
|
-
actionpack (= 6.
|
143
|
-
activesupport (= 6.
|
140
|
+
railties (6.1.4.4)
|
141
|
+
actionpack (= 6.1.4.4)
|
142
|
+
activesupport (= 6.1.4.4)
|
144
143
|
method_source
|
145
|
-
rake (>= 0.
|
146
|
-
thor (
|
147
|
-
rainbow (3.
|
148
|
-
rake (13.0.
|
149
|
-
regexp_parser (2.
|
144
|
+
rake (>= 0.13)
|
145
|
+
thor (~> 1.0)
|
146
|
+
rainbow (3.1.1)
|
147
|
+
rake (13.0.6)
|
148
|
+
regexp_parser (2.2.0)
|
150
149
|
rexml (3.2.5)
|
151
150
|
rspec (3.10.0)
|
152
151
|
rspec-core (~> 3.10.0)
|
153
152
|
rspec-expectations (~> 3.10.0)
|
154
153
|
rspec-mocks (~> 3.10.0)
|
155
|
-
rspec-core (3.10.
|
154
|
+
rspec-core (3.10.1)
|
156
155
|
rspec-support (~> 3.10.0)
|
157
|
-
rspec-expectations (3.10.
|
156
|
+
rspec-expectations (3.10.2)
|
158
157
|
diff-lcs (>= 1.2.0, < 2.0)
|
159
158
|
rspec-support (~> 3.10.0)
|
160
|
-
rspec-mocks (3.10.
|
159
|
+
rspec-mocks (3.10.2)
|
161
160
|
diff-lcs (>= 1.2.0, < 2.0)
|
162
161
|
rspec-support (~> 3.10.0)
|
163
|
-
rspec-support (3.10.
|
162
|
+
rspec-support (3.10.3)
|
164
163
|
rubocop (1.5.2)
|
165
164
|
parallel (~> 1.10)
|
166
165
|
parser (>= 2.7.1.5)
|
@@ -170,35 +169,37 @@ GEM
|
|
170
169
|
rubocop-ast (>= 1.2.0, < 2.0)
|
171
170
|
ruby-progressbar (~> 1.7)
|
172
171
|
unicode-display_width (>= 1.4.0, < 2.0)
|
173
|
-
rubocop-ast (1.
|
172
|
+
rubocop-ast (1.15.1)
|
174
173
|
parser (>= 3.0.1.1)
|
175
|
-
rubocop-performance (1.
|
176
|
-
rubocop (>= 0.
|
174
|
+
rubocop-performance (1.10.2)
|
175
|
+
rubocop (>= 0.90.0, < 2.0)
|
177
176
|
rubocop-ast (>= 0.4.0)
|
178
|
-
rubocop-rspec (2.
|
177
|
+
rubocop-rspec (2.4.0)
|
179
178
|
rubocop (~> 1.0)
|
180
179
|
rubocop-ast (>= 1.1.0)
|
181
180
|
ruby-progressbar (1.11.0)
|
182
|
-
|
181
|
+
ruby2_keywords (0.0.5)
|
182
|
+
simplecov (0.21.2)
|
183
183
|
docile (~> 1.1)
|
184
184
|
simplecov-html (~> 0.11)
|
185
|
+
simplecov_json_formatter (~> 0.1)
|
185
186
|
simplecov-html (0.12.3)
|
187
|
+
simplecov_json_formatter (0.1.3)
|
186
188
|
sprockets (4.0.2)
|
187
189
|
concurrent-ruby (~> 1.0)
|
188
190
|
rack (> 1, < 3)
|
189
|
-
sprockets-rails (3.
|
190
|
-
actionpack (>=
|
191
|
-
activesupport (>=
|
191
|
+
sprockets-rails (3.4.2)
|
192
|
+
actionpack (>= 5.2)
|
193
|
+
activesupport (>= 5.2)
|
192
194
|
sprockets (>= 3.0.0)
|
193
|
-
thor (1.
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
websocket-driver (0.7.3)
|
195
|
+
thor (1.2.1)
|
196
|
+
tzinfo (2.0.4)
|
197
|
+
concurrent-ruby (~> 1.0)
|
198
|
+
unicode-display_width (1.8.0)
|
199
|
+
websocket-driver (0.7.5)
|
199
200
|
websocket-extensions (>= 0.1.0)
|
200
201
|
websocket-extensions (0.1.5)
|
201
|
-
zeitwerk (2.
|
202
|
+
zeitwerk (2.5.3)
|
202
203
|
|
203
204
|
PLATFORMS
|
204
205
|
ruby
|
data/docs/components/routes.md
CHANGED
@@ -73,14 +73,15 @@ end
|
|
73
73
|
|
74
74
|
This will generate `userDetails` field on GraphQL side.
|
75
75
|
|
76
|
-
## _query_ and _mutation_
|
76
|
+
## _query_ and _mutation_ & _subscription_
|
77
77
|
|
78
|
-
in case you want to have non-CRUD controller with custom actions you can define your own `query`/`mutation` actions like this:
|
78
|
+
in case you want to have non-CRUD controller with custom actions you can define your own `query`/`mutation`/`subscription` actions like this:
|
79
79
|
|
80
80
|
```ruby
|
81
81
|
MyGraphqlSchema = GraphqlRails::Router.draw do
|
82
82
|
mutation :logIn, to: 'sessions#login'
|
83
|
-
query :me, to 'users#current_user'
|
83
|
+
query :me, to: 'users#current_user'
|
84
|
+
subscribtion :new_message, to: 'messages#created'
|
84
85
|
end
|
85
86
|
```
|
86
87
|
|
@@ -52,12 +52,6 @@ module GraphqlRails
|
|
52
52
|
GraphQL::InputObjectType
|
53
53
|
].freeze
|
54
54
|
|
55
|
-
PARSEABLE_RAW_GRAPHQL_TYPES = [
|
56
|
-
GraphQL::Schema::Object,
|
57
|
-
GraphQL::Schema::Scalar,
|
58
|
-
GraphQL::Schema::Enum
|
59
|
-
].freeze
|
60
|
-
|
61
55
|
RAW_GRAPHQL_TYPES = (WRAPPER_TYPES + GRAPHQL_BASE_TYPES).freeze
|
62
56
|
|
63
57
|
def unwrapped_scalar_type
|
@@ -103,7 +97,7 @@ module GraphqlRails
|
|
103
97
|
def graphql_type_object?(type_class)
|
104
98
|
return false unless type_class.is_a?(Class)
|
105
99
|
|
106
|
-
|
100
|
+
type_class < GraphQL::Schema::Member
|
107
101
|
end
|
108
102
|
|
109
103
|
def applicable_graphql_type?(type)
|
@@ -62,9 +62,14 @@ module GraphqlRails
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def parameter_filter_class
|
65
|
-
|
65
|
+
if ActiveSupport.gem_version.segments.first < 6
|
66
|
+
return ActiveSupport::ParameterFilter if Object.const_defined?('ActiveSupport::ParameterFilter')
|
66
67
|
|
67
|
-
|
68
|
+
ActionDispatch::Http::ParameterFilter
|
69
|
+
else
|
70
|
+
require 'active_support/parameter_filter'
|
71
|
+
ActiveSupport::ParameterFilter
|
72
|
+
end
|
68
73
|
end
|
69
74
|
end
|
70
75
|
end
|
@@ -46,11 +46,7 @@ module GraphqlRails
|
|
46
46
|
|
47
47
|
def find_or_build_dynamic_type(attribute)
|
48
48
|
graphql_model = attribute.graphql_model
|
49
|
-
if graphql_model
|
50
|
-
find_or_build_graphql_model_type(graphql_model)
|
51
|
-
else
|
52
|
-
AddFieldsToGraphqlType.call(klass: klass, attributes: [attribute])
|
53
|
-
end
|
49
|
+
find_or_build_graphql_model_type(graphql_model) if graphql_model
|
54
50
|
end
|
55
51
|
|
56
52
|
def find_or_build_graphql_model_type(graphql_model)
|
@@ -28,6 +28,10 @@ module GraphqlRails
|
|
28
28
|
routes << build_mutation(*args, **kwargs)
|
29
29
|
end
|
30
30
|
|
31
|
+
def subscription(*args, **kwargs)
|
32
|
+
routes << build_subscription(*args, **kwargs)
|
33
|
+
end
|
34
|
+
|
31
35
|
private
|
32
36
|
|
33
37
|
attr_reader :autogenerated_action_names, :name, :options
|
@@ -62,6 +66,10 @@ module GraphqlRails
|
|
62
66
|
build_route(QueryRoute, *args, **kwargs)
|
63
67
|
end
|
64
68
|
|
69
|
+
def build_subscription(*args, **kwargs)
|
70
|
+
build_route(SubscriptionRoute, *args, **kwargs)
|
71
|
+
end
|
72
|
+
|
65
73
|
# rubocop:disable Metrics/ParameterLists
|
66
74
|
def build_route(builder, action, prefix: action, suffix: false, on: :member, **custom_options)
|
67
75
|
if suffix == true
|
@@ -6,11 +6,12 @@ module GraphqlRails
|
|
6
6
|
class SchemaBuilder
|
7
7
|
require_relative './plain_cursor_encoder'
|
8
8
|
|
9
|
-
attr_reader :queries, :mutations, :raw_actions
|
9
|
+
attr_reader :queries, :mutations, :subscriptions, :raw_actions
|
10
10
|
|
11
|
-
def initialize(queries:, mutations:, raw_actions:, group: nil)
|
11
|
+
def initialize(queries:, mutations:, subscriptions:, raw_actions:, group: nil)
|
12
12
|
@queries = queries
|
13
13
|
@mutations = mutations
|
14
|
+
@subscriptions = subscriptions
|
14
15
|
@raw_actions = raw_actions
|
15
16
|
@group = group
|
16
17
|
end
|
@@ -18,6 +19,7 @@ module GraphqlRails
|
|
18
19
|
def call
|
19
20
|
query_type = build_group_type('Query', queries)
|
20
21
|
mutation_type = build_group_type('Mutation', mutations)
|
22
|
+
subscription_type = build_group_type('Subscription', subscriptions)
|
21
23
|
raw = raw_actions
|
22
24
|
|
23
25
|
Class.new(GraphQL::Schema) do
|
@@ -30,6 +32,7 @@ module GraphqlRails
|
|
30
32
|
|
31
33
|
query(query_type) if query_type
|
32
34
|
mutation(mutation_type) if mutation_type
|
35
|
+
subscription(subscription_type) if subscription_type
|
33
36
|
end
|
34
37
|
end
|
35
38
|
|
@@ -39,7 +42,13 @@ module GraphqlRails
|
|
39
42
|
|
40
43
|
def build_group_type(type_name, routes)
|
41
44
|
group_name = group
|
42
|
-
group_routes =
|
45
|
+
group_routes =
|
46
|
+
routes
|
47
|
+
.select { |route| route.show_in_group?(group_name) }
|
48
|
+
.reverse
|
49
|
+
.uniq(&:name)
|
50
|
+
.reverse
|
51
|
+
|
43
52
|
return if group_routes.empty?
|
44
53
|
|
45
54
|
build_type(type_name, group_routes)
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'route'
|
4
|
+
|
5
|
+
module GraphqlRails
|
6
|
+
class Router
|
7
|
+
# stores subscription type graphql action info
|
8
|
+
class SubscriptionRoute < Route
|
9
|
+
def query?
|
10
|
+
false
|
11
|
+
end
|
12
|
+
|
13
|
+
def mutation?
|
14
|
+
false
|
15
|
+
end
|
16
|
+
|
17
|
+
def subscription?
|
18
|
+
true
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/graphql_rails/router.rb
CHANGED
@@ -5,6 +5,7 @@ require 'active_support/core_ext/string/inflections'
|
|
5
5
|
require 'graphql_rails/router/schema_builder'
|
6
6
|
require 'graphql_rails/router/mutation_route'
|
7
7
|
require 'graphql_rails/router/query_route'
|
8
|
+
require 'graphql_rails/router/subscription_route'
|
8
9
|
require 'graphql_rails/router/resource_routes_builder'
|
9
10
|
|
10
11
|
module GraphqlRails
|
@@ -27,6 +28,7 @@ module GraphqlRails
|
|
27
28
|
@group_names = group_names
|
28
29
|
@routes ||= Set.new
|
29
30
|
@raw_graphql_actions ||= []
|
31
|
+
@graphql_schema = {}
|
30
32
|
end
|
31
33
|
|
32
34
|
def group(*group_names, &block)
|
@@ -57,6 +59,10 @@ module GraphqlRails
|
|
57
59
|
routes << build_route(MutationRoute, name, **options)
|
58
60
|
end
|
59
61
|
|
62
|
+
def subscription(name, **options)
|
63
|
+
routes << build_route(SubscriptionRoute, name, **options)
|
64
|
+
end
|
65
|
+
|
60
66
|
RAW_ACTION_NAMES.each do |action_name|
|
61
67
|
define_method(action_name) do |*args, &block|
|
62
68
|
add_raw_action(action_name, *args, &block)
|
@@ -64,17 +70,17 @@ module GraphqlRails
|
|
64
70
|
end
|
65
71
|
|
66
72
|
def graphql_schema(group = nil)
|
67
|
-
@graphql_schema ||= {}
|
68
73
|
@graphql_schema[group&.to_sym] ||= SchemaBuilder.new(
|
69
74
|
queries: routes.select(&:query?),
|
70
75
|
mutations: routes.select(&:mutation?),
|
76
|
+
subscriptions: routes.select(&:subscription?),
|
71
77
|
raw_actions: raw_graphql_actions,
|
72
78
|
group: group
|
73
79
|
).call
|
74
80
|
end
|
75
81
|
|
76
82
|
def reload_schema
|
77
|
-
@graphql_schema
|
83
|
+
@graphql_schema.clear
|
78
84
|
end
|
79
85
|
|
80
86
|
private
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Povilas Jurčys
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-01-
|
11
|
+
date: 2022-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|
@@ -226,6 +226,7 @@ files:
|
|
226
226
|
- lib/graphql_rails/router/resource_routes_builder.rb
|
227
227
|
- lib/graphql_rails/router/route.rb
|
228
228
|
- lib/graphql_rails/router/schema_builder.rb
|
229
|
+
- lib/graphql_rails/router/subscription_route.rb
|
229
230
|
- lib/graphql_rails/rspec_controller_helpers.rb
|
230
231
|
- lib/graphql_rails/tasks/dump_graphql_schema.rb
|
231
232
|
- lib/graphql_rails/tasks/dump_graphql_schemas.rb
|