hq-graphql 2.1.10 → 2.1.11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9dd3d2f47411b616e76f20e118b4a959af58a13223b5d8e758bb35919c5b2b02
4
- data.tar.gz: 781c03507b71570f5e9c6b9dc34117f34649097d1e4026701fd740c78209acad
3
+ metadata.gz: 2dc8a13aebd5bba09acb1b42fe2ece1bae74b7a19ee369f8ce225192f243bc56
4
+ data.tar.gz: ffbf49f7c59f4aa1bae28a04559c296ea16d6eeefab4cb904b4b3d3126a95176
5
5
  SHA512:
6
- metadata.gz: f5be4f443b74567f67e082cec1ae52d83f3adb0b2ae7964afb2f49e74467ed0185c04f34f363f3a0bb153e97bf90c7d8eff2e831d9d137cb1ca7c669b9af2ac8
7
- data.tar.gz: aecd6fcaf3f269d0bf2d7504cdebf4e022fd5e4c670d9ad5153f1658d127ba12ca0661711d7cfd1863615d0b94b7ab2098dd5d8e22a8fbb7271a41f5f5a89da5
6
+ metadata.gz: fd94207679a00f9a67a72719cb8deccc0c489050a43aa6ba52ffc1daac9bde7380b47748db634de92d43751791d7597dffa136b1818b9577428c0799ac361eb4
7
+ data.tar.gz: a811ef46fcce2c00290fdc22e61e8775b6d5367fb3afcded30796f4e72778f793dac0c0fce79ada7527ddbd06404cad3f7cc918548de3e2420bd6522adc8306d
data/README.md CHANGED
@@ -18,6 +18,15 @@ Define a global default scope.
18
18
  end
19
19
  ```
20
20
 
21
+ ### Excluded Inputs
22
+ Define a global excluded input fields. Useful for excluding (autogenerated | auto set) fields like below.
23
+
24
+ ```ruby
25
+ ::HQ::GraphQL.configure do |config|
26
+ config.excluded_inputs = [:id, :created_at, :updated_at]
27
+ end
28
+ ```
29
+
21
30
  ## GraphQL Resource
22
31
  Connect to ActiveRecord to auto generate queries and mutations.
23
32
 
@@ -36,6 +36,10 @@ module HQ
36
36
  config.extract_class.call(klass)
37
37
  end
38
38
 
39
+ def self.excluded_inputs
40
+ config.excluded_inputs || []
41
+ end
42
+
39
43
  def self.lookup_resource(klass)
40
44
  [klass, klass.base_class, klass.superclass].lazy.map do |k|
41
45
  config.resource_lookup.call(k) || resources.detect { |r| r.model_klass == k }
@@ -10,6 +10,7 @@ module HQ
10
10
  :extract_class,
11
11
  :resource_lookup,
12
12
  :use_experimental_associations,
13
+ :excluded_inputs,
13
14
  keyword_init: true
14
15
  )
15
16
  def initialize(
@@ -32,19 +32,21 @@ module HQ
32
32
  end
33
33
 
34
34
  #### Class Methods ####
35
- def self.with_model(model_name, attributes: true, associations: false, enums: true)
35
+ def self.with_model(model_name, attributes: true, associations: false, enums: true, excluded_inputs: [])
36
36
  self.model_name = model_name
37
37
  self.auto_load_attributes = attributes
38
38
  self.auto_load_associations = associations
39
39
  self.auto_load_enums = enums
40
40
 
41
41
  lazy_load do
42
+ excluded_inputs += ::HQ::GraphQL.excluded_inputs
43
+
42
44
  model_columns.each do |column|
43
- argument_from_column(column)
45
+ argument_from_column(column) unless excluded_inputs.include?(column.name.to_sym)
44
46
  end
45
47
 
46
48
  model_associations.each do |association|
47
- argument_from_association association
49
+ argument_from_association(association) unless excluded_inputs.include?(association.name.to_sym)
48
50
  end
49
51
 
50
52
  argument :X, String, required: false
@@ -108,6 +108,10 @@ module HQ
108
108
  self.sort_fields_enum = fields
109
109
  end
110
110
 
111
+ def excluded_inputs(*fields)
112
+ @excluded_inputs = fields
113
+ end
114
+
111
115
  def def_root(field_name, is_array: false, null: true, &block)
112
116
  resource = self
113
117
  resolver = -> {
@@ -181,10 +185,12 @@ module HQ
181
185
  def build_input_object(**options, &block)
182
186
  scoped_graphql_name = graphql_name
183
187
  scoped_model_name = model_name
188
+ scoped_excluded_inputs = @excluded_inputs || []
189
+
184
190
  Class.new(::HQ::GraphQL::InputObject) do
185
191
  graphql_name "#{scoped_graphql_name}Input"
186
192
 
187
- with_model scoped_model_name, **options
193
+ with_model scoped_model_name, excluded_inputs: scoped_excluded_inputs, **options
188
194
 
189
195
  class_eval(&block) if block
190
196
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module HQ
4
4
  module GraphQL
5
- VERSION = "2.1.10"
5
+ VERSION = "2.1.11"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hq-graphql
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.10
4
+ version: 2.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Jones
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-01 00:00:00.000000000 Z
11
+ date: 2020-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails