graphql_rails 2.1.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +1 -1
  3. data/.ruby-version +1 -1
  4. data/CHANGELOG.md +14 -0
  5. data/Gemfile.lock +117 -116
  6. data/docs/README.md +23 -45
  7. data/docs/_sidebar.md +0 -1
  8. data/docs/components/controller.md +15 -1
  9. data/docs/components/decorator.md +1 -1
  10. data/docs/components/model.md +62 -0
  11. data/docs/components/routes.md +45 -8
  12. data/lib/graphql_rails/attributes/attribute.rb +8 -14
  13. data/lib/graphql_rails/attributes/attribute_configurable.rb +15 -0
  14. data/lib/graphql_rails/attributes/input_attribute.rb +17 -1
  15. data/lib/graphql_rails/attributes/type_parseable.rb +1 -7
  16. data/lib/graphql_rails/controller/build_controller_action_resolver.rb +2 -0
  17. data/lib/graphql_rails/controller/log_controller_action.rb +7 -2
  18. data/lib/graphql_rails/controller.rb +1 -1
  19. data/lib/graphql_rails/decorator/relation_decorator.rb +22 -18
  20. data/lib/graphql_rails/decorator.rb +12 -4
  21. data/lib/graphql_rails/errors/system_error.rb +11 -1
  22. data/lib/graphql_rails/errors/validation_error.rb +14 -1
  23. data/lib/graphql_rails/input_configurable.rb +1 -1
  24. data/lib/graphql_rails/model/find_or_build_graphql_type.rb +1 -5
  25. data/lib/graphql_rails/router/build_schema_action_type.rb +112 -0
  26. data/lib/graphql_rails/router/mutation_route.rb +4 -0
  27. data/lib/graphql_rails/router/query_route.rb +4 -0
  28. data/lib/graphql_rails/router/resource_routes_builder.rb +8 -0
  29. data/lib/graphql_rails/router/route.rb +3 -2
  30. data/lib/graphql_rails/router/schema_builder.rb +14 -18
  31. data/lib/graphql_rails/router/subscription_route.rb +22 -0
  32. data/lib/graphql_rails/router.rb +32 -10
  33. data/lib/graphql_rails/version.rb +1 -1
  34. metadata +5 -4
  35. data/docs/getting_started/quick_start.md +0 -62
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bd5007444af16b72661bd4c9ad03866017b9fbbaadbd4a4bccc5c788c73f95bf
4
- data.tar.gz: 884390854d3490c9b323f82c527b922a087a0617a1a862fb5cbcd3d18f31e955
3
+ metadata.gz: 9f06459a3c8c16e40dffd181d7c08128558e2bdca598845b9e94f51852681e61
4
+ data.tar.gz: 1a4ddc9e11a4c5ef22240f7e36b3070bcf89b712c561cad12e41ede1dc18fbc3
5
5
  SHA512:
6
- metadata.gz: dcc498d22901bfecb649f44b266634ed762d119d0c4d876df04fbe5ae595173e61c3fe53078ea1803000fd5ec6faaa8686e1198aa2037ae6f09b91bf4e20b001
7
- data.tar.gz: 58a8ae501e143744082ca85ac0dba51bdcf5883fa949b25d23fd4c5510c28b877c4f5ca9cbc7f0af5d6d19b7c742fa835fa4b6d7afc1ccaaca0b83c153e9aeb9
6
+ metadata.gz: 23e0d160c19e3c56c00a474cb77eff10c6a86c3ce1c63f3cdb87f4c374f3c10da79b5f2529a14a026f81e6f3b2c32e9b2fecd671bd7b38066e07d020c65fa93a
7
+ data.tar.gz: a0ade6d1ce611baf97ab0a631770273c98953b04eb3991e3234c12a12f21e893962b62a1785ba5da48de7193c366129d29732c7121fbe6c4404d5e1f05cedda2
@@ -4,7 +4,7 @@ jobs:
4
4
  specs:
5
5
  strategy:
6
6
  matrix:
7
- ruby-version: ['2.6', '2.7', '3.0']
7
+ ruby-version: ['2.7', '3.0', '3.1']
8
8
 
9
9
  runs-on: ubuntu-latest
10
10
  env:
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.0.1
1
+ 3.1.2
data/CHANGELOG.md CHANGED
@@ -9,6 +9,20 @@ 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.3.0](2022-11-25)
13
+
14
+ * Added support for Ruby 3.1.2, keyword arguments for decorators support included
15
+ * Added: error backtrace to SystemError
16
+ * Fixed: skip "base" field name in validation error messages
17
+ * Added: router namespaces and named scopes
18
+ * Added: `deprecate` method/option for attributes and input attributes
19
+
20
+ ## [2.2.0](2022-01-25)
21
+
22
+ * Added: support for subscription type
23
+ * Fixed: correctly detect all graphql-ruby objects when using stringified types
24
+ * Added: make code compatible with newer graphql-ruby version
25
+
12
26
  ## [2.1.0](2022-01-12)
13
27
 
14
28
  * 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.1.0)
4
+ graphql_rails (2.3.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.0.3.4)
12
- actionpack (= 6.0.3.4)
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.0.3.4)
16
- actionpack (= 6.0.3.4)
17
- activejob (= 6.0.3.4)
18
- activerecord (= 6.0.3.4)
19
- activestorage (= 6.0.3.4)
20
- activesupport (= 6.0.3.4)
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.0.3.4)
23
- actionpack (= 6.0.3.4)
24
- actionview (= 6.0.3.4)
25
- activejob (= 6.0.3.4)
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.0.3.4)
29
- actionview (= 6.0.3.4)
30
- activesupport (= 6.0.3.4)
31
- rack (~> 2.0, >= 2.0.8)
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.0.3.4)
36
- actionpack (= 6.0.3.4)
37
- activerecord (= 6.0.3.4)
38
- activestorage (= 6.0.3.4)
39
- activesupport (= 6.0.3.4)
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.0.3.4)
42
- activesupport (= 6.0.3.4)
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.0.3.4)
48
- activesupport (= 6.0.3.4)
49
+ activejob (6.1.4.4)
50
+ activesupport (= 6.1.4.4)
49
51
  globalid (>= 0.3.6)
50
- activemodel (6.0.3.4)
51
- activesupport (= 6.0.3.4)
52
- activerecord (6.0.3.4)
53
- activemodel (= 6.0.3.4)
54
- activesupport (= 6.0.3.4)
55
- activestorage (6.0.3.4)
56
- actionpack (= 6.0.3.4)
57
- activejob (= 6.0.3.4)
58
- activerecord (= 6.0.3.4)
59
- marcel (~> 0.3.1)
60
- activesupport (6.0.3.4)
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 (>= 0.7, < 2)
63
- minitest (~> 5.1)
64
- tzinfo (~> 1.1)
65
- zeitwerk (~> 2.2, >= 2.2.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.11.0)
71
+ bson (4.14.0)
68
72
  builder (3.2.4)
69
73
  byebug (11.1.3)
70
- codecov (0.2.12)
71
- json
72
- simplecov
74
+ codecov (0.6.0)
75
+ simplecov (>= 0.15, < 0.22)
73
76
  coderay (1.1.3)
74
- concurrent-ruby (1.1.7)
77
+ concurrent-ruby (1.1.9)
75
78
  crass (1.0.6)
76
- diff-lcs (1.4.4)
77
- docile (1.3.2)
78
- erubi (1.9.0)
79
- globalid (0.4.2)
80
- activesupport (>= 4.2.0)
81
- graphql (1.13.4)
82
- i18n (1.8.5)
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.17)
85
+ i18n (1.8.11)
83
86
  concurrent-ruby (~> 1.0)
84
- json (2.3.1)
85
- loofah (2.7.0)
87
+ loofah (2.18.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.3.3)
91
- mimemagic (~> 0.3.2)
92
+ marcel (1.0.2)
92
93
  method_source (1.0.0)
93
- mimemagic (0.3.10)
94
- nokogiri (~> 1)
95
- rake
96
- mini_mime (1.0.2)
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.8.0)
96
+ minitest (5.15.0)
97
+ mongo (2.17.0)
100
98
  bson (>= 4.8.2, < 5.0.0)
101
- mongoid (7.1.4)
102
- activemodel (>= 5.1, < 6.1)
103
- mongo (>= 2.7.0, < 3.0.0)
104
- nio4r (2.5.4)
105
- nokogiri (1.12.5)
106
- mini_portile2 (~> 2.6.1)
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.9)
105
+ mini_portile2 (~> 2.8.0)
107
106
  racc (~> 1.4)
108
- parallel (1.20.1)
109
- parser (3.0.1.1)
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.5.2)
118
- rack (2.2.3)
116
+ racc (1.6.0)
117
+ rack (2.2.3.1)
119
118
  rack-test (1.1.0)
120
119
  rack (>= 1.0, < 3)
121
- rails (6.0.3.4)
122
- actioncable (= 6.0.3.4)
123
- actionmailbox (= 6.0.3.4)
124
- actionmailer (= 6.0.3.4)
125
- actionpack (= 6.0.3.4)
126
- actiontext (= 6.0.3.4)
127
- actionview (= 6.0.3.4)
128
- activejob (= 6.0.3.4)
129
- activemodel (= 6.0.3.4)
130
- activerecord (= 6.0.3.4)
131
- activestorage (= 6.0.3.4)
132
- activesupport (= 6.0.3.4)
133
- bundler (>= 1.3.0)
134
- railties (= 6.0.3.4)
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.3.0)
138
+ rails-html-sanitizer (1.4.3)
140
139
  loofah (~> 2.3)
141
- railties (6.0.3.4)
142
- actionpack (= 6.0.3.4)
143
- activesupport (= 6.0.3.4)
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.8.7)
146
- thor (>= 0.20.3, < 2.0)
147
- rainbow (3.0.0)
148
- rake (13.0.1)
149
- regexp_parser (2.1.1)
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.0)
154
+ rspec-core (3.10.1)
156
155
  rspec-support (~> 3.10.0)
157
- rspec-expectations (3.10.0)
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.0)
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.0)
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.5.0)
172
+ rubocop-ast (1.15.1)
174
173
  parser (>= 3.0.1.1)
175
- rubocop-performance (1.8.1)
176
- rubocop (>= 0.87.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.3.0)
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
- simplecov (0.19.1)
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.2.2)
190
- actionpack (>= 4.0)
191
- activesupport (>= 4.0)
191
+ sprockets-rails (3.4.2)
192
+ actionpack (>= 5.2)
193
+ activesupport (>= 5.2)
192
194
  sprockets (>= 3.0.0)
193
- thor (1.0.1)
194
- thread_safe (0.3.6)
195
- tzinfo (1.2.7)
196
- thread_safe (~> 0.1)
197
- unicode-display_width (1.7.0)
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.4.1)
202
+ zeitwerk (2.5.3)
202
203
 
203
204
  PLATFORMS
204
205
  ruby
data/docs/README.md CHANGED
@@ -42,11 +42,12 @@ GraphqlRails::Router.draw do
42
42
  resources :users
43
43
 
44
44
  # if you want custom queries or mutation
45
- query 'searchLogs', to: 'logs#search' # redirects request to LogsController
46
- mutation 'changeUserPassword', to: 'users#change_password'
45
+ query 'searchLogs', to: 'logs#search' # action is handled by LogsController#search
47
46
  end
48
47
  ```
49
48
 
49
+ See [Routes docs](components/routes.md) for more info.
50
+
50
51
  ### Define your Graphql model
51
52
 
52
53
  ```ruby
@@ -56,67 +57,42 @@ class User # works with any class including ActiveRecord
56
57
 
57
58
  graphql do |c|
58
59
  # most common attributes, like :id, :name, :title has default type, so you don't have to specify it (but you can!)
59
- c.attribute :id
60
+ c.attribute(:id)
60
61
 
61
- c.attribute :email, type: :string
62
- c.attribute :surname, type: :string
62
+ c.attribute(:email).type('String')
63
+ c.attribute(:surname).type('String')
63
64
  end
64
65
  end
65
66
  ```
66
67
 
68
+ See [Model docs](components/model.md) for more info.
69
+
67
70
  ### Define controller
68
71
 
69
72
  ```ruby
70
73
  # app/controllers/graphql/users_controller.rb
71
74
  class Graphql::UsersController < GraphqlApplicationController
72
- # graphql requires to describe which attributes controller action accepts and which returns
73
- action(:change_user_password)
74
- .permit(:password!, :id!) # Bang (!) indicates that attribute is required
75
- .returns('User!')
75
+ model('User') # specify that all actions returns User by default
76
76
 
77
- def change_user_password
78
- user = User.find(params[:id])
79
- user.update!(password: params[:password])
77
+ # DRUD actions description
78
+ action(:index).permit(id: 'ID!').returns_many
79
+ action(:show).permit(id: 'ID!').returns_single
80
+ action(:create).permit(email: 'String!').returns_single
81
+ action(:update).permit(id: 'ID!', email: 'String!').returns_single
82
+ action(:destroy).permit(id: 'ID!').returns_single
80
83
 
81
- # returned value needs to have all methods defined in model `graphql do` part
82
- user # or SomeDecorator.new(user)
84
+ def index
85
+ User.all
83
86
  end
84
87
 
85
- action(:search)
86
- .permit(search_fields!: SearchFieldsInput) # you can specify your own input fields
87
- .returns('[User!]!')
88
- def search
88
+ def show
89
+ User.find(params[:id])
89
90
  end
91
+ # ... code for create / update / destroy is skipped ...
90
92
  end
91
93
  ```
92
94
 
93
- ## Routes
94
-
95
- ```ruby
96
- GraphqlRails::Router.draw do
97
- # generates `friend`, `createFriend`, `updateFriend`, `destroyFriend`, `friends` routes
98
- resources :friends
99
- resources :shops, only: [:show, :index] # generates `shop` and `shops` routes only
100
- resources :orders, except: :update # generates all routes except `updateOrder`
101
-
102
- resources :users do
103
- # generates `findUser` query
104
- query :find, on: :member
105
-
106
- # generates `searchUsers` query
107
- query :search, on: :collection
108
- end
109
-
110
- # you can use namespaced controllers too:
111
- scope module: 'admin' do
112
- # `updateTranslations` route will be handled by `Admin::TranslationsController`
113
- mutation :updateTranslations, to: 'translations#update'
114
-
115
- # all :groups routes will be handled by `Admin::GroupsController`
116
- resources :groups
117
- end
118
- end
119
- ```
95
+ See [Controller docs](components/controlle.md) for more info.
120
96
 
121
97
  ## Testing your GraphqlRails::Controller in RSpec
122
98
 
@@ -134,6 +110,8 @@ RSpec.configure do |config|
134
110
  end
135
111
  ```
136
112
 
113
+ See [Testing docs](testing/testing.md) for more info.
114
+
137
115
  ### Helper methods
138
116
 
139
117
  There are 3 helper methods:
data/docs/_sidebar.md CHANGED
@@ -1,7 +1,6 @@
1
1
  * [Home](README)
2
2
  * Getting started
3
3
  * [Setup](getting_started/setup)
4
- * [Quick start](getting_started/quick_start)
5
4
  * Components
6
5
  * [Routes](components/routes)
7
6
  * [Model](components/model)
@@ -144,7 +144,7 @@ end
144
144
  If you do not specify `subtype` then default (without name) input will be used. You need to specify subtype if you want to use non-default input:
145
145
 
146
146
  ```ruby
147
- class OrderController < GraphqlRails::Controller
147
+ class UsersController < GraphqlRails::Controller
148
148
  # this is the input with email and full_name:
149
149
  action(:create)
150
150
  .permit_input(:input, type: 'User!')
@@ -155,6 +155,20 @@ class OrderController < GraphqlRails::Controller
155
155
  end
156
156
  ```
157
157
 
158
+ #### *deprecated*
159
+
160
+ You can mark input input as deprecated with `deprecated` option:
161
+
162
+ ```ruby
163
+ class UsersController < GraphqlRails::Controller
164
+ action(:create)
165
+ .permit_input(:input, type: 'User', deprecated: true)
166
+
167
+ action(:update)
168
+ .permit_input(:input, type: 'User', deprecated: 'use updateBasicUser instead')
169
+ end
170
+ ```
171
+
158
172
  ### *paginated*
159
173
 
160
174
  You can mark collection action as `paginated`. In this case controller will return relay connection type and it will be possible to return only partial results. No need to do anything on controller side (you should always return full list of items)
@@ -46,7 +46,7 @@ class UserDecorator < SimpleDelegator
46
46
  include GraphqlRails::Model
47
47
  include GraphqlRails::Decorator
48
48
 
49
- graphql_rails do
49
+ graphql do |c|
50
50
  # some setup, attributes, etc...
51
51
  end
52
52
 
@@ -131,6 +131,21 @@ class User
131
131
  end
132
132
  ```
133
133
 
134
+ ### attribute.deprecated
135
+
136
+ Attribute can be marked as deprecated with `deprecated` method:
137
+
138
+ ```ruby
139
+ class User
140
+ include GraphqlRails::Model
141
+
142
+ graphql do |c|
143
+ c.attribute(:legacy_name).deprecated
144
+ c.attribute(:legacy_id).deprecated('This is my custom deprecation reason')
145
+ end
146
+ end
147
+ ```
148
+
134
149
  ### attribute.groups
135
150
 
136
151
  Groups are handy feature when you want to have multiple schemas. For example, you want to have public graphql endpoint and internal graphql endpoint where each group has some unique nodes. If attribute has `groups` set, then this attribute will be visible only in appropriate group schemas.
@@ -263,6 +278,23 @@ class User
263
278
  end
264
279
  ```
265
280
 
281
+ #### *deprecated*
282
+
283
+ You can mark input input as deprecated with `deprecated` option:
284
+
285
+
286
+ ```ruby
287
+ class User
288
+ include GraphqlRails::Model
289
+
290
+ graphql.attribute(:avatar_url)
291
+ .permit_input(:size, type: :int!, deprecated: true)
292
+
293
+ graphql.attribute(:logo_url)
294
+ .permit_input(:size, type: :int!, deprecated: 'custom image size is deprecated')
295
+ end
296
+ ```
297
+
266
298
  ### attribute.paginated
267
299
 
268
300
  You can mark collection method as `paginated`. In this case method will return relay connection type and it will be possible to return only partial results. No need to do anything on method side (you should always return full list of items)
@@ -523,6 +555,36 @@ class User
523
555
  end
524
556
  ```
525
557
 
558
+
559
+ #### input attribute deprecation
560
+
561
+ You can mark input attribute as deprecated with `deprecated` method:
562
+
563
+ ```ruby
564
+ class User
565
+ include GraphqlRails::Model
566
+
567
+ graphql.input do |c|
568
+ c.attribute(:full_name).deprecated('Use firstName and lastName instead')
569
+ c.attribute(:surname).deprecated
570
+ end
571
+ end
572
+ ```
573
+
574
+ #### input attribute default value
575
+
576
+ You can set default value for input attribute:
577
+
578
+ ```ruby
579
+ class User
580
+ include GraphqlRails::Model
581
+
582
+ graphql.input do |c|
583
+ c.attribute(:is_admin).type('Boolean').default_value(false)
584
+ end
585
+ end
586
+ ```
587
+
526
588
  ## graphql_context
527
589
 
528
590
  It's possible to access graphql_context in your model using method `graphql_context`: