nulogy_graphql_api 0.5.1 → 0.5.3

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: 443443223656dea1385697579f000561e8b141672b894dc14f2560c4f5bc7d48
4
- data.tar.gz: 4a8a1532e09704f36d7f5f7a6d8c7c93d87bf231705cf76979a406ffcfcc5b39
3
+ metadata.gz: 6625da7a3a2e9f0f68ded5321a5bc57b81fdf1ca00e1f85385f8551454a3ea70
4
+ data.tar.gz: 375182960778201a137f3b2dd96667f5eead6c82959e06e1be0f9c8de3e829a0
5
5
  SHA512:
6
- metadata.gz: a8d1956b33d02a884e43bd7441f00f8962a80435dbd25a9248ad7fc5c4ff2a5e73f904d3c7bc1548232dc1acebb7033149557828a09a370a0ac3194098b2d2f8
7
- data.tar.gz: acbc49d198bd424b44877a670c3a2847b5e2c5035982cc67b65558a2aaac06baf4a951b8a90d8905390dd7cee0f0c3b1193009db29d7764b5066aed1404fafee
6
+ metadata.gz: d83ccfd6856215e4965d9ca64a253447d2593d26c801547c0259a5024765193d1f4ef2e0bbcf865c58a95e11518ab544e0f0486eb95a77ade9f6f041bc3d54cf
7
+ data.tar.gz: c72a1471eb7dc8f4a63219d0494c7ba159d31009e18e36791455c984f5d01bc5299c639d4eadb42e3150f36db675656135df2001211e4ff4519dbba8134d8d65
@@ -2,11 +2,15 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
- ## 0.5.1
5
+ ## 0.5.3 (2020-08-11)
6
+
7
+ * Add `BaseMutation`.
8
+
9
+ ## 0.5.1 (2020-08-11)
6
10
 
7
11
  * Add the `schema_generation_context?` attribute to the GraphQL `context` when generating the schema.
8
12
 
9
- ## 0.5.0
13
+ ## 0.5.0 (2020-08-05)
10
14
 
11
15
  **Breaking Changes**
12
16
 
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  Add this line to your application's Gemfile:
6
6
 
7
7
  ```ruby
8
- gem "nulogy_graphql_api", "0.5.1"
8
+ gem "nulogy_graphql_api", "0.5.3"
9
9
  ```
10
10
 
11
11
  And then execute:
@@ -145,11 +145,11 @@ end
145
145
 
146
146
  ### Node visibility
147
147
 
148
- When you customize the visibility of parts of your graph you have to make sure that node will be visible when the schema is being generated. 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.
148
+ 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.
149
149
 
150
150
  Here is how to use it:
151
151
 
152
- ##### For fields
152
+ ##### On fields
153
153
  ```ruby
154
154
  field :entity, MyApp::EntityType, null: false do
155
155
  description "Find an entity by ID"
@@ -162,16 +162,19 @@ end
162
162
  ```
163
163
 
164
164
 
165
- ##### For classes
165
+ ##### On mutations
166
+
167
+ In this case the `schema_generation_context?` attribute is checked by the `BaseMutation` class. All you have to do is inheriting from it and override `visible?` passing a block to the base method.
168
+
166
169
  ```ruby
167
170
  module MyApp
168
- class CreateEntity < GraphQL::Schema::Mutation
171
+ class CreateEntity < NulogyGraphqlApi::Schema::BaseMutation
169
172
  field :entity, MyApp::EntityType, null: false
170
173
  field :errors, [NulogyGraphqlApi::Types::UserErrorType], null: false
171
174
 
172
- def self.visible(context)
173
- super && (context[:schema_generation_context?] || context[:current_user].superuser?)
174
- end
175
+ def self.visible?(context)
176
+ super { context[:current_user].super_user? }
177
+ end
175
178
 
176
179
  def resolve(args)
177
180
  # ...
@@ -3,6 +3,7 @@ require "graphql"
3
3
  require "nulogy_graphql_api/error_handling"
4
4
  require "nulogy_graphql_api/graphql_executor"
5
5
  require "nulogy_graphql_api/graphql_response"
6
+ require "nulogy_graphql_api/schema/base_mutation"
6
7
  require "nulogy_graphql_api/transaction_service"
7
8
  require "nulogy_graphql_api/tasks/schema_changes_checker"
8
9
  require "nulogy_graphql_api/tasks/schema_generator"
@@ -0,0 +1,12 @@
1
+ module NulogyGraphqlApi
2
+ module Schema
3
+ class BaseMutation < GraphQL::Schema::Mutation
4
+ def self.visible?(context)
5
+ return true if context[:schema_generation_context?]
6
+ return super && yield if block_given?
7
+
8
+ super
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1,3 +1,3 @@
1
1
  module NulogyGraphqlApi
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nulogy_graphql_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Silva
@@ -189,6 +189,7 @@ files:
189
189
  - lib/nulogy_graphql_api/rspec.rb
190
190
  - lib/nulogy_graphql_api/rspec/graphql_helpers.rb
191
191
  - lib/nulogy_graphql_api/rspec/graphql_matchers.rb
192
+ - lib/nulogy_graphql_api/schema/base_mutation.rb
192
193
  - lib/nulogy_graphql_api/tasks/schema_changes_checker.rb
193
194
  - lib/nulogy_graphql_api/tasks/schema_generator.rb
194
195
  - lib/nulogy_graphql_api/transaction_service.rb