graphql_rails 0.6.0 → 1.2.0
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.
- checksums.yaml +4 -4
- data/.hound.yml +1 -0
- data/.rubocop.yml +3 -3
- data/.ruby-version +1 -1
- data/.travis.yml +2 -2
- data/CHANGELOG.md +38 -0
- data/Gemfile +3 -2
- data/Gemfile.lock +181 -71
- data/docs/README.md +48 -9
- data/docs/_sidebar.md +5 -0
- data/docs/components/controller.md +294 -8
- data/docs/components/decorator.md +69 -0
- data/docs/components/model.md +349 -11
- data/docs/components/routes.md +43 -1
- data/docs/getting_started/quick_start.md +9 -2
- data/docs/index.html +1 -1
- data/docs/logging_and_monitoring/logging_and_monitoring.md +35 -0
- data/docs/other_tools/query_runner.md +49 -0
- data/docs/other_tools/schema_dump.md +29 -0
- data/docs/testing/testing.md +3 -1
- data/graphql_rails.gemspec +5 -4
- data/lib/generators/graphql_rails/install_generator.rb +50 -0
- data/lib/generators/graphql_rails/templates/example_users_controller.erb +19 -0
- data/lib/generators/graphql_rails/templates/graphql_application_controller.erb +8 -0
- data/lib/generators/graphql_rails/templates/graphql_controller.erb +20 -0
- data/lib/generators/graphql_rails/templates/graphql_router.erb +19 -0
- data/lib/generators/graphql_rails/templates/graphql_router_spec.erb +21 -0
- data/lib/graphql_rails.rb +7 -1
- data/lib/graphql_rails/attributes.rb +13 -0
- data/lib/graphql_rails/{attribute → attributes}/attributable.rb +25 -20
- data/lib/graphql_rails/attributes/attribute.rb +94 -0
- data/lib/graphql_rails/{attribute → attributes}/attribute_name_parser.rb +2 -2
- data/lib/graphql_rails/attributes/input_attribute.rb +65 -0
- data/lib/graphql_rails/attributes/input_type_parser.rb +62 -0
- data/lib/graphql_rails/attributes/type_name_info.rb +38 -0
- data/lib/graphql_rails/attributes/type_parseable.rb +128 -0
- data/lib/graphql_rails/attributes/type_parser.rb +121 -0
- data/lib/graphql_rails/concerns/service.rb +19 -0
- data/lib/graphql_rails/controller.rb +42 -21
- data/lib/graphql_rails/controller/action.rb +12 -67
- data/lib/graphql_rails/controller/action_configuration.rb +71 -31
- data/lib/graphql_rails/controller/build_controller_action_resolver.rb +52 -0
- data/lib/graphql_rails/controller/build_controller_action_resolver/controller_action_resolver.rb +28 -0
- data/lib/graphql_rails/controller/configuration.rb +56 -4
- data/lib/graphql_rails/controller/log_controller_action.rb +71 -0
- data/lib/graphql_rails/controller/request.rb +29 -8
- data/lib/graphql_rails/controller/request/format_errors.rb +58 -0
- data/lib/graphql_rails/decorator.rb +41 -0
- data/lib/graphql_rails/decorator/relation_decorator.rb +75 -0
- data/lib/graphql_rails/errors/custom_execution_error.rb +22 -0
- data/lib/graphql_rails/errors/execution_error.rb +8 -7
- data/lib/graphql_rails/errors/system_error.rb +14 -0
- data/lib/graphql_rails/errors/validation_error.rb +1 -5
- data/lib/graphql_rails/input_configurable.rb +47 -0
- data/lib/graphql_rails/integrations.rb +19 -0
- data/lib/graphql_rails/integrations/lograge.rb +39 -0
- data/lib/graphql_rails/integrations/sentry.rb +34 -0
- data/lib/graphql_rails/model.rb +26 -4
- data/lib/graphql_rails/model/add_fields_to_graphql_type.rb +45 -0
- data/lib/graphql_rails/model/build_connection_type.rb +52 -0
- data/lib/graphql_rails/model/{configuration → build_connection_type}/count_items.rb +5 -5
- data/lib/graphql_rails/model/build_enum_type.rb +68 -0
- data/lib/graphql_rails/model/{graphql_input_type_builder.rb → build_graphql_input_type.rb} +10 -2
- data/lib/graphql_rails/model/call_graphql_model_method.rb +72 -0
- data/lib/graphql_rails/model/configurable.rb +6 -2
- data/lib/graphql_rails/model/configuration.rb +34 -19
- data/lib/graphql_rails/model/find_or_build_graphql_type.rb +64 -0
- data/lib/graphql_rails/model/find_or_build_graphql_type_class.rb +46 -0
- data/lib/graphql_rails/model/input.rb +25 -11
- data/lib/graphql_rails/query_runner.rb +68 -0
- data/lib/graphql_rails/railtie.rb +10 -0
- data/lib/graphql_rails/router.rb +40 -13
- data/lib/graphql_rails/router/resource_routes_builder.rb +19 -11
- data/lib/graphql_rails/router/route.rb +21 -6
- data/lib/graphql_rails/router/schema_builder.rb +36 -11
- data/lib/graphql_rails/rspec_controller_helpers.rb +6 -4
- data/lib/graphql_rails/tasks/dump_graphql_schema.rb +57 -0
- data/lib/graphql_rails/tasks/schema.rake +14 -0
- data/lib/graphql_rails/version.rb +1 -1
- metadata +78 -26
- data/README.md +0 -194
- data/lib/graphql_rails/attribute.rb +0 -28
- data/lib/graphql_rails/attribute/type_parser.rb +0 -115
- data/lib/graphql_rails/controller/controller_function.rb +0 -50
- data/lib/graphql_rails/controller/format_results.rb +0 -36
- data/lib/graphql_rails/model/graphql_type_builder.rb +0 -33
- data/lib/graphql_rails/model/input_attribute.rb +0 -47
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aab866d81cb8b70ef283c47914ea056c15eb07000b701414a42a7055fe1dabe1
|
4
|
+
data.tar.gz: 814a9189c63ffee28c8ab47c761b8740680da723669ea05d0d0e2256770b61d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99fe93c9a15507f4ebd0c1ec8667ddeac6b211342ca4df65b4a866fd3ba1dc34dd5661c4fba8317e4deea5241b9c52a2cb176e9d1dc0d9a57ec57d464f7e1dfa
|
7
|
+
data.tar.gz: db4a1d9fb7d4c9a20fb449a54ae5c27e784c39672052d5f95e0c7927801eaebe3c88c4899e8477da3d892c7ff420cdc29a15b3753cf6ec1e9c94c946f6c6de66
|
data/.hound.yml
CHANGED
data/.rubocop.yml
CHANGED
@@ -3,7 +3,7 @@ require: rubocop-rspec
|
|
3
3
|
RSpec/NestedGroups:
|
4
4
|
Enabled: false
|
5
5
|
|
6
|
-
|
6
|
+
Layout/LineLength:
|
7
7
|
Enabled: true
|
8
8
|
Max: 120
|
9
9
|
|
@@ -21,7 +21,7 @@ Lint/AmbiguousBlockAssociation:
|
|
21
21
|
Exclude:
|
22
22
|
- spec/**/*.rb
|
23
23
|
|
24
|
-
Naming/
|
24
|
+
Naming/MethodParameterName:
|
25
25
|
AllowedNames:
|
26
26
|
- 'to'
|
27
27
|
- 'at'
|
@@ -35,7 +35,7 @@ Style/ClassAndModuleChildren:
|
|
35
35
|
- spec/**/*_spec.rb
|
36
36
|
|
37
37
|
AllCops:
|
38
|
-
TargetRubyVersion: 2.
|
38
|
+
TargetRubyVersion: 2.7
|
39
39
|
Exclude:
|
40
40
|
- bin/*
|
41
41
|
- graphql_rails.gemspec
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.7.1
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -9,6 +9,44 @@ 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
|
+
## [1.2.0](2021-02-15)
|
13
|
+
|
14
|
+
* Added/Changed/Deprecated/Removed/Fixed/Security: YOUR CHANGE HERE
|
15
|
+
|
16
|
+
* Added: `options` argument to model level attribute. Allows disabling automatic camelCase
|
17
|
+
* Fixed: methods with complex input arguments receives `Hash` instances instead of `GraphQL::Schema::InputObject`
|
18
|
+
* Fixed: Using `ActiveSupport::ParameterFilter` (Rails 6.1), if it is defined, instead of `ActionDispatch::Http::ParameterFilter`
|
19
|
+
* Changed: graphql version is now `1.12` which may require system-wide changes.
|
20
|
+
* Fixed: improved connection wrapper for pagination to work.
|
21
|
+
* Fixed: implementation of `total` field is no longer missing when using pagination.
|
22
|
+
|
23
|
+
|
24
|
+
## [1.0.0](2020-02-07)
|
25
|
+
|
26
|
+
* Added: "required" and "optional" flags for attribute
|
27
|
+
* Added: grouped routes
|
28
|
+
* Added: added argument to model.attribute
|
29
|
+
* Added: added graphql_context to model
|
30
|
+
* Removed: `action.can_return_nil` was removed, because it does no affect anymore
|
31
|
+
* Removed: default `action` model was removed. Now each action must have `returns` part
|
32
|
+
* Added: default router added. No need to assign value to constant on Router.draw
|
33
|
+
* Added: default action added. Now actions can have custom defaults
|
34
|
+
* Added: default controller model added. Now actions can be defined in more dynamic way
|
35
|
+
* Added: install generator. Now it's possible to generate boilerplate code
|
36
|
+
|
37
|
+
## [0.8.0] (2019-09-03)
|
38
|
+
|
39
|
+
* Added: permit_input action config with extended list of permitted input options
|
40
|
+
* Added: model decorators
|
41
|
+
* Added: controller action instrumentation [@povilasjurcys](https://github.com/povilasjurcys)
|
42
|
+
* Added: sentry and lograge integrations
|
43
|
+
* Added: required: true flag for permitted attributes, inputs and model attributes
|
44
|
+
|
45
|
+
## 0.7.0 (2019-05-15)
|
46
|
+
|
47
|
+
* Added: input type now accepts `enum` param which allows create enum fields
|
48
|
+
* Added: routes now accepts `suffix: true` flag which generates GraphQL field with appended action name to the end of resource name
|
49
|
+
|
12
50
|
## 0.6.0 (2019-04-29)
|
13
51
|
|
14
52
|
* Breaking change: controller params are always underscored [@povilasjurcys](https://github.com/povilasjurcys).
|
data/Gemfile
CHANGED
@@ -5,8 +5,9 @@ source 'https://rubygems.org'
|
|
5
5
|
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
6
6
|
|
7
7
|
group :development do
|
8
|
-
gem 'rubocop'
|
9
|
-
gem 'rubocop-
|
8
|
+
gem 'rubocop', '0.91.0'
|
9
|
+
gem 'rubocop-performance', '~> 1.8', '>= 1.8.1'
|
10
|
+
gem 'rubocop-rspec', '~> 1.44', '>= 1.44.1'
|
10
11
|
end
|
11
12
|
|
12
13
|
group :test do
|
data/Gemfile.lock
CHANGED
@@ -1,110 +1,220 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
graphql_rails (
|
4
|
+
graphql_rails (1.2.0)
|
5
5
|
activesupport (>= 4)
|
6
|
-
graphql (~> 1)
|
6
|
+
graphql (~> 1.12, >= 1.12.4)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
actioncable (6.0.3.4)
|
12
|
+
actionpack (= 6.0.3.4)
|
13
|
+
nio4r (~> 2.0)
|
14
|
+
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)
|
21
|
+
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)
|
26
|
+
mail (~> 2.5, >= 2.5.4)
|
27
|
+
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)
|
32
|
+
rack-test (>= 0.6.3)
|
33
|
+
rails-dom-testing (~> 2.0)
|
34
|
+
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)
|
40
|
+
nokogiri (>= 1.8.5)
|
41
|
+
actionview (6.0.3.4)
|
42
|
+
activesupport (= 6.0.3.4)
|
43
|
+
builder (~> 3.1)
|
44
|
+
erubi (~> 1.4)
|
45
|
+
rails-dom-testing (~> 2.0)
|
46
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
47
|
+
activejob (6.0.3.4)
|
48
|
+
activesupport (= 6.0.3.4)
|
49
|
+
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)
|
18
61
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
19
62
|
i18n (>= 0.7, < 2)
|
20
63
|
minitest (~> 5.1)
|
21
64
|
tzinfo (~> 1.1)
|
22
|
-
|
23
|
-
ast (2.4.
|
24
|
-
bson (4.
|
25
|
-
|
26
|
-
|
65
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
66
|
+
ast (2.4.1)
|
67
|
+
bson (4.11.0)
|
68
|
+
builder (3.2.4)
|
69
|
+
byebug (11.1.3)
|
70
|
+
codecov (0.2.12)
|
27
71
|
json
|
28
72
|
simplecov
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
diff-lcs (1.
|
33
|
-
docile (1.3.
|
34
|
-
|
35
|
-
|
73
|
+
coderay (1.1.3)
|
74
|
+
concurrent-ruby (1.1.7)
|
75
|
+
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.12.4)
|
82
|
+
i18n (1.8.5)
|
36
83
|
concurrent-ruby (~> 1.0)
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
84
|
+
json (2.3.1)
|
85
|
+
loofah (2.7.0)
|
86
|
+
crass (~> 1.0.2)
|
87
|
+
nokogiri (>= 1.5.9)
|
88
|
+
mail (2.7.1)
|
89
|
+
mini_mime (>= 0.1.1)
|
90
|
+
marcel (0.3.3)
|
91
|
+
mimemagic (~> 0.3.2)
|
92
|
+
method_source (1.0.0)
|
93
|
+
mimemagic (0.3.5)
|
94
|
+
mini_mime (1.0.2)
|
95
|
+
mini_portile2 (2.5.0)
|
96
|
+
minitest (5.14.2)
|
97
|
+
mongo (2.13.1)
|
98
|
+
bson (>= 4.8.2, < 5.0.0)
|
99
|
+
mongoid (7.1.4)
|
100
|
+
activemodel (>= 5.1, < 6.1)
|
101
|
+
mongo (>= 2.7.0, < 3.0.0)
|
102
|
+
nio4r (2.5.4)
|
103
|
+
nokogiri (1.11.1)
|
104
|
+
mini_portile2 (~> 2.5.0)
|
105
|
+
racc (~> 1.4)
|
106
|
+
parallel (1.19.2)
|
107
|
+
parser (2.7.2.0)
|
108
|
+
ast (~> 2.4.1)
|
109
|
+
pry (0.13.1)
|
110
|
+
coderay (~> 1.1)
|
111
|
+
method_source (~> 1.0)
|
112
|
+
pry-byebug (3.9.0)
|
53
113
|
byebug (~> 11.0)
|
54
|
-
pry (~> 0.
|
55
|
-
|
114
|
+
pry (~> 0.13.0)
|
115
|
+
racc (1.5.2)
|
116
|
+
rack (2.2.3)
|
117
|
+
rack-test (1.1.0)
|
118
|
+
rack (>= 1.0, < 3)
|
119
|
+
rails (6.0.3.4)
|
120
|
+
actioncable (= 6.0.3.4)
|
121
|
+
actionmailbox (= 6.0.3.4)
|
122
|
+
actionmailer (= 6.0.3.4)
|
123
|
+
actionpack (= 6.0.3.4)
|
124
|
+
actiontext (= 6.0.3.4)
|
125
|
+
actionview (= 6.0.3.4)
|
126
|
+
activejob (= 6.0.3.4)
|
127
|
+
activemodel (= 6.0.3.4)
|
128
|
+
activerecord (= 6.0.3.4)
|
129
|
+
activestorage (= 6.0.3.4)
|
130
|
+
activesupport (= 6.0.3.4)
|
131
|
+
bundler (>= 1.3.0)
|
132
|
+
railties (= 6.0.3.4)
|
133
|
+
sprockets-rails (>= 2.0.0)
|
134
|
+
rails-dom-testing (2.0.3)
|
135
|
+
activesupport (>= 4.2.0)
|
136
|
+
nokogiri (>= 1.6)
|
137
|
+
rails-html-sanitizer (1.3.0)
|
138
|
+
loofah (~> 2.3)
|
139
|
+
railties (6.0.3.4)
|
140
|
+
actionpack (= 6.0.3.4)
|
141
|
+
activesupport (= 6.0.3.4)
|
142
|
+
method_source
|
143
|
+
rake (>= 0.8.7)
|
144
|
+
thor (>= 0.20.3, < 2.0)
|
56
145
|
rainbow (3.0.0)
|
57
|
-
rake (
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
rspec-
|
62
|
-
|
63
|
-
rspec-
|
64
|
-
rspec-
|
146
|
+
rake (13.0.1)
|
147
|
+
regexp_parser (1.8.2)
|
148
|
+
rexml (3.2.4)
|
149
|
+
rspec (3.10.0)
|
150
|
+
rspec-core (~> 3.10.0)
|
151
|
+
rspec-expectations (~> 3.10.0)
|
152
|
+
rspec-mocks (~> 3.10.0)
|
153
|
+
rspec-core (3.10.0)
|
154
|
+
rspec-support (~> 3.10.0)
|
155
|
+
rspec-expectations (3.10.0)
|
65
156
|
diff-lcs (>= 1.2.0, < 2.0)
|
66
|
-
rspec-support (~> 3.
|
67
|
-
rspec-mocks (3.
|
157
|
+
rspec-support (~> 3.10.0)
|
158
|
+
rspec-mocks (3.10.0)
|
68
159
|
diff-lcs (>= 1.2.0, < 2.0)
|
69
|
-
rspec-support (~> 3.
|
70
|
-
rspec-support (3.
|
71
|
-
rubocop (0.
|
72
|
-
jaro_winkler (~> 1.5.1)
|
160
|
+
rspec-support (~> 3.10.0)
|
161
|
+
rspec-support (3.10.0)
|
162
|
+
rubocop (0.91.0)
|
73
163
|
parallel (~> 1.10)
|
74
|
-
parser (>= 2.
|
75
|
-
psych (>= 3.1.0)
|
164
|
+
parser (>= 2.7.1.1)
|
76
165
|
rainbow (>= 2.2.2, < 4.0)
|
166
|
+
regexp_parser (>= 1.7)
|
167
|
+
rexml
|
168
|
+
rubocop-ast (>= 0.4.0, < 1.0)
|
77
169
|
ruby-progressbar (~> 1.7)
|
78
|
-
unicode-display_width (>= 1.4.0, <
|
79
|
-
rubocop-
|
80
|
-
|
81
|
-
|
82
|
-
|
170
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
171
|
+
rubocop-ast (0.8.0)
|
172
|
+
parser (>= 2.7.1.5)
|
173
|
+
rubocop-performance (1.8.1)
|
174
|
+
rubocop (>= 0.87.0)
|
175
|
+
rubocop-ast (>= 0.4.0)
|
176
|
+
rubocop-rspec (1.44.1)
|
177
|
+
rubocop (~> 0.87)
|
178
|
+
rubocop-ast (>= 0.7.1)
|
179
|
+
ruby-progressbar (1.10.1)
|
180
|
+
simplecov (0.19.1)
|
83
181
|
docile (~> 1.1)
|
84
|
-
|
85
|
-
|
86
|
-
|
182
|
+
simplecov-html (~> 0.11)
|
183
|
+
simplecov-html (0.12.3)
|
184
|
+
sprockets (4.0.2)
|
185
|
+
concurrent-ruby (~> 1.0)
|
186
|
+
rack (> 1, < 3)
|
187
|
+
sprockets-rails (3.2.2)
|
188
|
+
actionpack (>= 4.0)
|
189
|
+
activesupport (>= 4.0)
|
190
|
+
sprockets (>= 3.0.0)
|
191
|
+
thor (1.0.1)
|
87
192
|
thread_safe (0.3.6)
|
88
|
-
tzinfo (1.2.
|
193
|
+
tzinfo (1.2.7)
|
89
194
|
thread_safe (~> 0.1)
|
90
|
-
unicode-display_width (1.
|
91
|
-
|
195
|
+
unicode-display_width (1.7.0)
|
196
|
+
websocket-driver (0.7.3)
|
197
|
+
websocket-extensions (>= 0.1.0)
|
198
|
+
websocket-extensions (0.1.5)
|
199
|
+
zeitwerk (2.4.1)
|
92
200
|
|
93
201
|
PLATFORMS
|
94
202
|
ruby
|
95
203
|
|
96
204
|
DEPENDENCIES
|
97
205
|
activerecord
|
98
|
-
bundler (~>
|
206
|
+
bundler (~> 2)
|
99
207
|
codecov
|
100
208
|
graphql_rails!
|
101
209
|
mongoid
|
102
210
|
pry-byebug
|
103
|
-
|
211
|
+
rails (~> 6)
|
212
|
+
rake (~> 13.0)
|
104
213
|
rspec (~> 3.0)
|
105
|
-
rubocop
|
106
|
-
rubocop-
|
214
|
+
rubocop (= 0.91.0)
|
215
|
+
rubocop-performance (~> 1.8, >= 1.8.1)
|
216
|
+
rubocop-rspec (~> 1.44, >= 1.44.1)
|
107
217
|
simplecov
|
108
218
|
|
109
219
|
BUNDLED WITH
|
110
|
-
1.
|
220
|
+
2.1.4
|
data/docs/README.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# GraphqlRails
|
2
2
|
|
3
|
+
[](https://travis-ci.org/samesystem/graphql_rails)
|
4
|
+
[](https://codecov.io/gh/samesystem/graphql_rails)
|
5
|
+
[](https://samesystem.github.io/graphql_rails)
|
6
|
+
|
3
7
|
Rails style structure for GraphQL API.
|
4
8
|
|
5
9
|
## Installation
|
@@ -18,12 +22,21 @@ Or install it yourself as:
|
|
18
22
|
|
19
23
|
$ gem install graphql_rails
|
20
24
|
|
25
|
+
## Getting started
|
26
|
+
|
27
|
+
Execute:
|
28
|
+
|
29
|
+
$ bundle exec rails g graphql_rails:install
|
30
|
+
|
31
|
+
This will generate code which will let you start your graphql faster
|
32
|
+
|
21
33
|
## Usage
|
22
34
|
|
23
35
|
### Define GraphQL schema as RoR routes
|
24
36
|
|
25
37
|
```ruby
|
26
|
-
|
38
|
+
# config/graphql/routes.rb
|
39
|
+
GraphqlRails::Router.draw do
|
27
40
|
# will create createUser, updateUser, deleteUser mutations and user, users queries.
|
28
41
|
# expects that UsersController class exist
|
29
42
|
resources :users
|
@@ -37,6 +50,7 @@ end
|
|
37
50
|
### Define your Graphql model
|
38
51
|
|
39
52
|
```ruby
|
53
|
+
# app/models/user.rb
|
40
54
|
class User # works with any class including ActiveRecord
|
41
55
|
include GraphqlRails::Model
|
42
56
|
|
@@ -53,10 +67,12 @@ end
|
|
53
67
|
### Define controller
|
54
68
|
|
55
69
|
```ruby
|
56
|
-
|
70
|
+
# app/controllers/graphql/users_controller.rb
|
71
|
+
class Graphql::UsersController < GraphqlApplicationController
|
57
72
|
# graphql requires to describe which attributes controller action accepts and which returns
|
58
73
|
action(:change_user_password)
|
59
74
|
.permit(:password!, :id!) # Bang (!) indicates that attribute is required
|
75
|
+
.returns('User!')
|
60
76
|
|
61
77
|
def change_user_password
|
62
78
|
user = User.find(params[:id])
|
@@ -66,7 +82,9 @@ class UsersController < GraphqlRails::Controller
|
|
66
82
|
user # or SomeDecorator.new(user)
|
67
83
|
end
|
68
84
|
|
69
|
-
action(:search)
|
85
|
+
action(:search)
|
86
|
+
.permit(search_fields!: SearchFieldsInput) # you can specify your own input fields
|
87
|
+
.returns('[User!]!')
|
70
88
|
def search
|
71
89
|
end
|
72
90
|
end
|
@@ -75,7 +93,7 @@ end
|
|
75
93
|
## Routes
|
76
94
|
|
77
95
|
```ruby
|
78
|
-
|
96
|
+
GraphqlRails::Router.draw do
|
79
97
|
# generates `friend`, `createFriend`, `updateFriend`, `destroyFriend`, `friends` routes
|
80
98
|
resources :friends
|
81
99
|
resources :shops, only: [:show, :index] # generates `shop` and `shops` routes only
|
@@ -91,10 +109,10 @@ MyGraphqlSchema = GraphqlRails::Router.draw do
|
|
91
109
|
|
92
110
|
# you can use namespaced controllers too:
|
93
111
|
scope module: 'admin' do
|
94
|
-
# `updateTranslations` route will be
|
112
|
+
# `updateTranslations` route will be handled by `Admin::TranslationsController`
|
95
113
|
mutation :updateTranslations, to: 'translations#update'
|
96
114
|
|
97
|
-
# all :groups routes will be
|
115
|
+
# all :groups routes will be handled by `Admin::GroupsController`
|
98
116
|
resources :groups
|
99
117
|
end
|
100
118
|
end
|
@@ -128,11 +146,13 @@ There are 3 helper methods:
|
|
128
146
|
|
129
147
|
```ruby
|
130
148
|
class MyGraphqlController
|
149
|
+
action(:create_user).permit(:full_name, :email).returns(User)
|
150
|
+
action(:index).returns('String')
|
151
|
+
|
131
152
|
def index
|
132
153
|
"Called from index: #{params[:message]}"
|
133
154
|
end
|
134
155
|
|
135
|
-
action(:create_user).permit(:full_name, :email)
|
136
156
|
def create_user
|
137
157
|
User.create!(params)
|
138
158
|
end
|
@@ -167,6 +187,25 @@ RSpec.describe MyGraphqlController, type: :graphql_controller do
|
|
167
187
|
end
|
168
188
|
```
|
169
189
|
|
190
|
+
### Integrating GraphqlRails with other tools
|
191
|
+
|
192
|
+
In order to make GraphqlRails work with tools such as lograge or sentry, you need to enable them. In Ruby on Rails, you can add initializer:
|
193
|
+
|
194
|
+
```ruby
|
195
|
+
# config/initializers/graphql_rails.rb
|
196
|
+
GraphqlRails::Integrations.enable(:lograge, :sentry)
|
197
|
+
```
|
198
|
+
|
199
|
+
At the moment, GraphqlRails supports following integrations:
|
200
|
+
|
201
|
+
* lograge
|
202
|
+
* sentry
|
203
|
+
|
204
|
+
If you need to build something custom, check [logging_and_monitoring documentation](logging_and_monitoring/logging_and_monitoring.md) for more details.
|
205
|
+
|
206
|
+
## Detailed documentation
|
207
|
+
|
208
|
+
Check https://samesystem.github.io/graphql_rails for more details
|
170
209
|
|
171
210
|
## Development
|
172
211
|
|
@@ -176,7 +215,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
176
215
|
|
177
216
|
## Contributing
|
178
217
|
|
179
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
218
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/samesystem/graphql_rails. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
180
219
|
|
181
220
|
## License
|
182
221
|
|
@@ -184,4 +223,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
184
223
|
|
185
224
|
## Code of Conduct
|
186
225
|
|
187
|
-
Everyone interacting in the GraphqlRails project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
226
|
+
Everyone interacting in the GraphqlRails project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/samesystem/graphql_rails/blob/master/CODE_OF_CONDUCT.md).
|