hq-graphql 2.1.10 → 2.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -0
- data/lib/hq/graphql.rb +4 -0
- data/lib/hq/graphql/config.rb +1 -0
- data/lib/hq/graphql/input_object.rb +5 -3
- data/lib/hq/graphql/resource.rb +7 -1
- data/lib/hq/graphql/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2dc8a13aebd5bba09acb1b42fe2ece1bae74b7a19ee369f8ce225192f243bc56
|
4
|
+
data.tar.gz: ffbf49f7c59f4aa1bae28a04559c296ea16d6eeefab4cb904b4b3d3126a95176
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
|
data/lib/hq/graphql.rb
CHANGED
@@ -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 }
|
data/lib/hq/graphql/config.rb
CHANGED
@@ -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
|
data/lib/hq/graphql/resource.rb
CHANGED
@@ -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
|
data/lib/hq/graphql/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2020-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|