nulogy_graphql_api 0.6.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4b83dfdf7475f2630a23b11b79d071783253eec60759d0b9011c36334413f298
4
- data.tar.gz: aef54c3d57c7b7e666758c041682660521e872ee509942d7c5549274836ea57b
3
+ metadata.gz: f8abde35aa513cd066444a4f67427ce59a53a4e0ecba57f6e404893b7364ff57
4
+ data.tar.gz: f779d84620bcd6945e9be210bf271aaf55ab33c7952eaea9eb9ed4f34d486857
5
5
  SHA512:
6
- metadata.gz: 12941fe223139d12da5e571ea7d320d7f55db4cdf53ffe0d0870e60bf1438b01c83c4dc04f91d08ba4aba91dbb617cfa67f873e102d5671a91d8449b0bbe4257
7
- data.tar.gz: c339bc9011ce92e493a7e83d4e0a295b10d663b2027933e6530e97be6407fcd2971d75e9b8e849c87671768e30ec07678e892484e0c6ec86f3519039182d8c3f
6
+ metadata.gz: 6932ab2af2b84d41567627f772a036ff3adb79a57cd8b0d55c897e45f3569c9b843419b49ea09978a307b93d8aa7abcec6dcbcd0ffa9b8e058563713c4fef479
7
+ data.tar.gz: 1b2588c7c65128f435b4ce474aaf89fe1d6937c90f55efa98758864ab847520867c6624aa26241b6de6728ab443e9b49d4d971fa733da4d432230b73742ba6e2
data/Appraisals CHANGED
@@ -1,4 +1,5 @@
1
1
  appraise "rails-5" do
2
+ gem "mimemagic", "0.3.10"
2
3
  gem "rails", "5.2.4"
3
4
  end
4
5
 
data/CHANGELOG.md CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
+ ## 1.0.0 (2021-05-17)
6
+
7
+ **Changes**
8
+
9
+ * **(Breaking)** Change argument to `SchemaGenerator`
10
+
11
+ The `SchemaGenerator` now takes the path to the `schema.graphql` and the schema class as required arguments.
12
+ See [the update in the README](README.md#Schema-Generation).
13
+
14
+ ## 0.6.0 (2021-02-24)
15
+
5
16
  **Changes**
6
17
 
7
18
  * **(Potentially Breaking)** Bump graphql gem version to 1.12.5
@@ -18,7 +29,7 @@
18
29
 
19
30
  **Changes**
20
31
 
21
- * **(Breaking)** Add `context` to the Rake task that generates the schema file.
32
+ * **(Breaking)** Add `context` to the Rake task that generates the schema file.
22
33
  This changes the way the schema is parsed. Please refer to the README file to see an example of how to use `context`.
23
34
 
24
35
  ## 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.5.3"
12
+ gem "nulogy_graphql_api", "1.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 `schema_definition_path` 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.
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
- schema_definition_path = MyApp::Engine.root.join("path/to/schema/root/schema.rb")
141
+ schema = MyApp::Namespace::To::Schema
142
142
 
143
143
  NulogyGraphqlApi::Tasks::SchemaGenerator
144
- .new(schema_file_path, schema_definition_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
 
@@ -4,6 +4,7 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "rake", "~> 13.0"
6
6
  gem "rspec", "~> 3.9"
7
+ gem "mimemagic", "0.3.10"
7
8
  gem "rails", "5.2.4"
8
9
 
9
- gemspec :path => "../"
10
+ gemspec path: "../"
@@ -6,4 +6,4 @@ gem "rake", "~> 13.0"
6
6
  gem "rspec", "~> 3.9"
7
7
  gem "rails", "6.0.0"
8
8
 
9
- gemspec :path => "../"
9
+ gemspec path: "../"
@@ -1,9 +1,9 @@
1
1
  module NulogyGraphqlApi
2
2
  module Tasks
3
3
  class SchemaGenerator
4
- def initialize(schema_output_path, schema_definition_path, context: {})
4
+ def initialize(schema_output_path, schema_definition, context: {})
5
5
  @schema_output_path = schema_output_path
6
- @schema_definition_path = schema_definition_path
6
+ @schema_definition = schema_definition
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, schema_definition)
22
+ SchemaChangesChecker.new.check_changes(old_schema, @schema_definition)
23
23
  end
24
24
 
25
25
  def old_schema
@@ -28,11 +28,6 @@ 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
@@ -1,3 +1,3 @@
1
1
  module NulogyGraphqlApi
2
- VERSION = "0.6.0"
2
+ VERSION = "1.0.0"
3
3
  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.6.0
4
+ version: 1.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-02-24 00:00:00.000000000 Z
11
+ date: 2021-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql