nulogy_graphql_api 0.6.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/Appraisals +4 -4
- data/CHANGELOG.md +32 -1
- data/README.md +17 -17
- data/gemfiles/rails_6.gemfile +2 -2
- data/gemfiles/{rails_5.gemfile → rails_6_1.gemfile} +2 -2
- data/lib/nulogy_graphql_api/tasks/schema_generator.rb +7 -8
- data/lib/nulogy_graphql_api/version.rb +1 -1
- data/nulogy_graphql_api.gemspec +9 -9
- metadata +22 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9464bd32ae78ced30336a35b4c18033e044d859004ba4735f85659de5c0d2420
|
4
|
+
data.tar.gz: aa3b0be5dd2f2579a790751de9f28a0c386aa8e0408bc2109ef7a2d7a5a0138d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ec675b6b042f4ab85ce8ab49f3dae7d9d2fa0a2fa7e09f923344c65e66dca0fe36b0ec192a6bee7a60e7241516a117a0674db2d1bf4c44474409ea592c6adf8
|
7
|
+
data.tar.gz: 9fbe169d33b1758e79f20d6fe68d10458907488db48d067c6bb40c9511668d948c2f49cabaa536652ad19ed861aabd4a937f91fe0445293a4ef8f8691ee5942b
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.7.3
|
data/Appraisals
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,37 @@
|
|
2
2
|
|
3
3
|
## master (unreleased)
|
4
4
|
|
5
|
+
_none_
|
6
|
+
|
7
|
+
## 2.0.0 (2021-11-29)
|
8
|
+
|
9
|
+
**Changes**
|
10
|
+
|
11
|
+
* **(Breaking)** Bump graphql version from 1.12.5 to 1.13
|
12
|
+
|
13
|
+
## 1.1.1 (2021-07-26)
|
14
|
+
|
15
|
+
**Changes**
|
16
|
+
* Bug Fix: Schema generator always errored when generating new schema file
|
17
|
+
|
18
|
+
## 1.1.0 (2021-07-12)
|
19
|
+
|
20
|
+
**Changes**
|
21
|
+
|
22
|
+
* Support Rails 6.1
|
23
|
+
* **(Breaking)** Drop support for Rails 5
|
24
|
+
|
25
|
+
## 1.0.0 (2021-05-17)
|
26
|
+
|
27
|
+
**Changes**
|
28
|
+
|
29
|
+
* **(Breaking)** Change argument to `SchemaGenerator`
|
30
|
+
|
31
|
+
The `SchemaGenerator` now takes the path to the `schema.graphql` and the schema class as required arguments.
|
32
|
+
See [the update in the README](README.md#Schema-Generation).
|
33
|
+
|
34
|
+
## 0.6.0 (2021-02-24)
|
35
|
+
|
5
36
|
**Changes**
|
6
37
|
|
7
38
|
* **(Potentially Breaking)** Bump graphql gem version to 1.12.5
|
@@ -18,7 +49,7 @@
|
|
18
49
|
|
19
50
|
**Changes**
|
20
51
|
|
21
|
-
* **(Breaking)** Add `context` to the Rake task that generates the schema file.
|
52
|
+
* **(Breaking)** Add `context` to the Rake task that generates the schema file.
|
22
53
|
This changes the way the schema is parsed. Please refer to the README file to see an example of how to use `context`.
|
23
54
|
|
24
55
|
## 0.4.0 (2020-07-06)
|
data/README.md
CHANGED
@@ -9,7 +9,7 @@ Help Nulogy applications be compliant with the [Standard on Error-handling in Gr
|
|
9
9
|
Add this line to your application's Gemfile:
|
10
10
|
|
11
11
|
```ruby
|
12
|
-
gem "nulogy_graphql_api", "0.
|
12
|
+
gem "nulogy_graphql_api", "2.0.0"
|
13
13
|
```
|
14
14
|
|
15
15
|
And then execute:
|
@@ -41,9 +41,9 @@ Or install it yourself as:
|
|
41
41
|
|
42
42
|
#### Receiving Requests
|
43
43
|
|
44
|
-
Given that you have already defined your GraphQL `Schema` you can receive requests by defining a controller action and execute the params by calling the `NulogyGraphqlApi::GraphqlExecutor`.
|
44
|
+
Given that you have already defined your GraphQL `Schema` you can receive requests by defining a controller action and execute the params by calling the `NulogyGraphqlApi::GraphqlExecutor`.
|
45
45
|
|
46
|
-
- Remember to configure your routes to include the controller action.
|
46
|
+
- Remember to configure your routes to include the controller action.
|
47
47
|
- We called the action `execute` in the example below, but you can call it whatever makes more sense for your app.
|
48
48
|
|
49
49
|
```ruby
|
@@ -53,9 +53,9 @@ module MyApp
|
|
53
53
|
|
54
54
|
def execute
|
55
55
|
NulogyGraphqlApi::GraphqlExecutor.execute(
|
56
|
-
params,
|
57
|
-
context,
|
58
|
-
Schema,
|
56
|
+
params,
|
57
|
+
context,
|
58
|
+
Schema,
|
59
59
|
NulogyGraphqlApi::TransactionService.new
|
60
60
|
)
|
61
61
|
end
|
@@ -74,7 +74,7 @@ module MyApp
|
|
74
74
|
|
75
75
|
def render_error(exception)
|
76
76
|
MyApp::ExceptionNotifier.notify(exception)
|
77
|
-
|
77
|
+
|
78
78
|
super
|
79
79
|
end
|
80
80
|
end
|
@@ -92,10 +92,10 @@ module MyApp
|
|
92
92
|
class CreateEntity < GraphQL::Schema::Mutation
|
93
93
|
field :entity, MyApp::EntityType, null: false
|
94
94
|
field :errors, [NulogyGraphqlApi::Types::UserErrorType], null: false
|
95
|
-
|
95
|
+
|
96
96
|
def resolve(args)
|
97
97
|
entity = create_entity(args)
|
98
|
-
|
98
|
+
|
99
99
|
{
|
100
100
|
entity: entity,
|
101
101
|
errors: extract_errors(entity)
|
@@ -103,7 +103,7 @@ module MyApp
|
|
103
103
|
end
|
104
104
|
|
105
105
|
def extract_errors(entity)
|
106
|
-
entity.errors.map do |attribute, message|
|
106
|
+
entity.errors.map do |attribute, message|
|
107
107
|
{
|
108
108
|
path: path_for(attribute),
|
109
109
|
message: entity.errors.full_message(attribute, message)
|
@@ -128,7 +128,7 @@ end
|
|
128
128
|
|
129
129
|
### Schema Generation
|
130
130
|
|
131
|
-
There is a Rake task to generate the `schema.graphql` file. You need to provide the `schema_file_path` and the
|
131
|
+
There is a Rake task to generate the `schema.graphql` file. You need to provide the `schema_file_path` and the schema class so that the task can detect breaking changes and generate the file. If you don't have a schema file because it's your first time generating it then the rake task will just create one for you in the path provided.
|
132
132
|
|
133
133
|
There is also a third argument `context`. You'll have to configure it to be able to generate the SDL of fields or types that are only visible for more privileged users.
|
134
134
|
|
@@ -138,10 +138,10 @@ namespace :graphql_api do
|
|
138
138
|
|
139
139
|
task :generate_schema => :environment do
|
140
140
|
schema_file_path = MyApp::Engine.root.join("schema.graphql")
|
141
|
-
|
141
|
+
schema = MyApp::Namespace::To::Schema
|
142
142
|
|
143
143
|
NulogyGraphqlApi::Tasks::SchemaGenerator
|
144
|
-
.new(schema_file_path,
|
144
|
+
.new(schema_file_path, schema)
|
145
145
|
.generate_schema
|
146
146
|
end
|
147
147
|
end
|
@@ -149,7 +149,7 @@ end
|
|
149
149
|
|
150
150
|
### Node visibility
|
151
151
|
|
152
|
-
When you customize the visibility of parts of your graph you have to make sure that all nodes are visible when the schema is being generated by the rake task. You can do so by using the `schema_generation_context?` attribute that is added to the context by the `SchemaGenerator` mentioned in the previous section.
|
152
|
+
When you customize the visibility of parts of your graph you have to make sure that all nodes are visible when the schema is being generated by the rake task. You can do so by using the `schema_generation_context?` attribute that is added to the context by the `SchemaGenerator` mentioned in the previous section.
|
153
153
|
|
154
154
|
Here is how to use it:
|
155
155
|
|
@@ -175,7 +175,7 @@ module MyApp
|
|
175
175
|
class CreateEntity < NulogyGraphqlApi::Schema::BaseMutation
|
176
176
|
field :entity, MyApp::EntityType, null: false
|
177
177
|
field :errors, [NulogyGraphqlApi::Types::UserErrorType], null: false
|
178
|
-
|
178
|
+
|
179
179
|
def self.visible?(context)
|
180
180
|
super { context[:current_user].super_user? }
|
181
181
|
end
|
@@ -202,7 +202,7 @@ RSpec.configure do |config|
|
|
202
202
|
config.include NulogyGraphqlApi::GraphqlMatchers, graphql: true
|
203
203
|
config.include NulogyGraphqlApi::GraphqlHelpers, graphql: true
|
204
204
|
end
|
205
|
-
```
|
205
|
+
```
|
206
206
|
|
207
207
|
#### Test helpers
|
208
208
|
|
@@ -292,7 +292,7 @@ When you are happy with your changes:
|
|
292
292
|
- Bug Fixes
|
293
293
|
- Changes
|
294
294
|
- *prepend these with* **(Breaking)***,* **(Potentially Breaking)** *or just leave it blank in case neither applies*
|
295
|
-
|
295
|
+
|
296
296
|
1. Create a Pull Request.
|
297
297
|
1. Notify #nulogy-graphql-api Slack channel to get the DRI review and merge your changes.
|
298
298
|
|
data/gemfiles/rails_6.gemfile
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
module NulogyGraphqlApi
|
2
2
|
module Tasks
|
3
3
|
class SchemaGenerator
|
4
|
-
def initialize(schema_output_path,
|
4
|
+
def initialize(schema_output_path, schema, context: {})
|
5
5
|
@schema_output_path = schema_output_path
|
6
|
-
@
|
6
|
+
@schema = schema
|
7
7
|
@context = context.merge(
|
8
8
|
schema_generation_context?: true
|
9
9
|
)
|
@@ -19,7 +19,7 @@ module NulogyGraphqlApi
|
|
19
19
|
def check_changes
|
20
20
|
return if old_schema.blank?
|
21
21
|
|
22
|
-
SchemaChangesChecker.new.check_changes(old_schema,
|
22
|
+
SchemaChangesChecker.new.check_changes(old_schema, @schema)
|
23
23
|
end
|
24
24
|
|
25
25
|
def old_schema
|
@@ -28,15 +28,14 @@ module NulogyGraphqlApi
|
|
28
28
|
File.read(@schema_output_path)
|
29
29
|
end
|
30
30
|
|
31
|
-
def schema_definition
|
32
|
-
require @schema_definition_path
|
33
|
-
@schema_definition ||= GraphQL::Schema.descendants.first.to_definition(context: @context)
|
34
|
-
end
|
35
|
-
|
36
31
|
def write_schema_to_file
|
37
32
|
File.write(@schema_output_path, schema_definition)
|
38
33
|
puts Rainbow("\nSuccessfully updated #{@schema_output_path}").green
|
39
34
|
end
|
35
|
+
|
36
|
+
def schema_definition
|
37
|
+
GraphQL::Schema::Printer.print_schema(@schema, context: @context)
|
38
|
+
end
|
40
39
|
end
|
41
40
|
end
|
42
41
|
end
|
data/nulogy_graphql_api.gemspec
CHANGED
@@ -28,15 +28,15 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
29
|
spec.require_paths = ["lib"]
|
30
30
|
|
31
|
-
spec.add_dependency "graphql", "~> 1.
|
31
|
+
spec.add_dependency "graphql", "~> 1.13"
|
32
32
|
spec.add_dependency "graphql-schema_comparator", "~> 1.0.0"
|
33
|
-
spec.add_dependency "rails", ">= 5.2.4", "<
|
34
|
-
spec.add_dependency "rainbow", "~> 3.0
|
33
|
+
spec.add_dependency "rails", ">= 5.2.4", "< 7.0"
|
34
|
+
spec.add_dependency "rainbow", "~> 3.0"
|
35
35
|
|
36
|
-
spec.add_development_dependency "appraisal", "~> 2.
|
37
|
-
spec.add_development_dependency "rspec-rails", "~>
|
38
|
-
spec.add_development_dependency "rubocop", "~> 1.
|
39
|
-
spec.add_development_dependency "rubocop-performance", "~> 1.
|
40
|
-
spec.add_development_dependency "rubocop-rspec", "~> 2.
|
41
|
-
spec.add_development_dependency "sqlite3", "~> 1.4
|
36
|
+
spec.add_development_dependency "appraisal", "~> 2.4"
|
37
|
+
spec.add_development_dependency "rspec-rails", "~> 5.0"
|
38
|
+
spec.add_development_dependency "rubocop", "~> 1.18"
|
39
|
+
spec.add_development_dependency "rubocop-performance", "~> 1.11"
|
40
|
+
spec.add_development_dependency "rubocop-rspec", "~> 2.4"
|
41
|
+
spec.add_development_dependency "sqlite3", "~> 1.4"
|
42
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nulogy_graphql_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Silva
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: '1.13'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
26
|
+
version: '1.13'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: graphql-schema_comparator
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -47,7 +47,7 @@ dependencies:
|
|
47
47
|
version: 5.2.4
|
48
48
|
- - "<"
|
49
49
|
- !ruby/object:Gem::Version
|
50
|
-
version:
|
50
|
+
version: '7.0'
|
51
51
|
type: :runtime
|
52
52
|
prerelease: false
|
53
53
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -57,105 +57,105 @@ dependencies:
|
|
57
57
|
version: 5.2.4
|
58
58
|
- - "<"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
60
|
+
version: '7.0'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: rainbow
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
65
|
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version: 3.0
|
67
|
+
version: '3.0'
|
68
68
|
type: :runtime
|
69
69
|
prerelease: false
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
72
|
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: 3.0
|
74
|
+
version: '3.0'
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: appraisal
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
79
|
- - "~>"
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version: 2.
|
81
|
+
version: '2.4'
|
82
82
|
type: :development
|
83
83
|
prerelease: false
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
86
|
- - "~>"
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version: 2.
|
88
|
+
version: '2.4'
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
90
|
name: rspec-rails
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
93
|
- - "~>"
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version:
|
95
|
+
version: '5.0'
|
96
96
|
type: :development
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
100
|
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version:
|
102
|
+
version: '5.0'
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: rubocop
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|
106
106
|
requirements:
|
107
107
|
- - "~>"
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: 1.
|
109
|
+
version: '1.18'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
112
|
version_requirements: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
114
|
- - "~>"
|
115
115
|
- !ruby/object:Gem::Version
|
116
|
-
version: 1.
|
116
|
+
version: '1.18'
|
117
117
|
- !ruby/object:Gem::Dependency
|
118
118
|
name: rubocop-performance
|
119
119
|
requirement: !ruby/object:Gem::Requirement
|
120
120
|
requirements:
|
121
121
|
- - "~>"
|
122
122
|
- !ruby/object:Gem::Version
|
123
|
-
version: '1.
|
123
|
+
version: '1.11'
|
124
124
|
type: :development
|
125
125
|
prerelease: false
|
126
126
|
version_requirements: !ruby/object:Gem::Requirement
|
127
127
|
requirements:
|
128
128
|
- - "~>"
|
129
129
|
- !ruby/object:Gem::Version
|
130
|
-
version: '1.
|
130
|
+
version: '1.11'
|
131
131
|
- !ruby/object:Gem::Dependency
|
132
132
|
name: rubocop-rspec
|
133
133
|
requirement: !ruby/object:Gem::Requirement
|
134
134
|
requirements:
|
135
135
|
- - "~>"
|
136
136
|
- !ruby/object:Gem::Version
|
137
|
-
version: 2.
|
137
|
+
version: '2.4'
|
138
138
|
type: :development
|
139
139
|
prerelease: false
|
140
140
|
version_requirements: !ruby/object:Gem::Requirement
|
141
141
|
requirements:
|
142
142
|
- - "~>"
|
143
143
|
- !ruby/object:Gem::Version
|
144
|
-
version: 2.
|
144
|
+
version: '2.4'
|
145
145
|
- !ruby/object:Gem::Dependency
|
146
146
|
name: sqlite3
|
147
147
|
requirement: !ruby/object:Gem::Requirement
|
148
148
|
requirements:
|
149
149
|
- - "~>"
|
150
150
|
- !ruby/object:Gem::Version
|
151
|
-
version: 1.4
|
151
|
+
version: '1.4'
|
152
152
|
type: :development
|
153
153
|
prerelease: false
|
154
154
|
version_requirements: !ruby/object:Gem::Requirement
|
155
155
|
requirements:
|
156
156
|
- - "~>"
|
157
157
|
- !ruby/object:Gem::Version
|
158
|
-
version: 1.4
|
158
|
+
version: '1.4'
|
159
159
|
description:
|
160
160
|
email:
|
161
161
|
- danielsi@nulogy.com
|
@@ -178,8 +178,8 @@ files:
|
|
178
178
|
- Rakefile
|
179
179
|
- bin/console
|
180
180
|
- bin/setup
|
181
|
-
- gemfiles/rails_5.gemfile
|
182
181
|
- gemfiles/rails_6.gemfile
|
182
|
+
- gemfiles/rails_6_1.gemfile
|
183
183
|
- lib/nulogy_graphql_api.rb
|
184
184
|
- lib/nulogy_graphql_api/error_handling.rb
|
185
185
|
- lib/nulogy_graphql_api/graphql_error.rb
|
@@ -221,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
221
221
|
- !ruby/object:Gem::Version
|
222
222
|
version: '0'
|
223
223
|
requirements: []
|
224
|
-
rubygems_version: 3.
|
224
|
+
rubygems_version: 3.1.6
|
225
225
|
signing_key:
|
226
226
|
specification_version: 4
|
227
227
|
summary: Standard tooling for building GraphQL apis
|