graphql-functions 0.2.0 → 0.3.0
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 +4 -4
- data/README.md +4 -4
- data/lib/graphql/functions/array.rb +9 -10
- data/lib/graphql/functions/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02f0de4e3f1c59ce9d374aaf55ffcb2338ae199e
|
4
|
+
data.tar.gz: fef47b3fed57917796499afd266b6f96a38d6bba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aed01910118028ce08aaaddaa6286f3a1232457645da91dde93ccca3298caf5b55939bdc0d5bca2884c5da420c7231582d86b53f15100abd6777e22b244c6416
|
7
|
+
data.tar.gz: 31db237994aabaeff7923741224e1ebba1d25f8676d080565fac8f6d778d7610abff86a0f05c1ea03433a8e77dd87022c873af8fb3aa82ab0a73d478caf5371a
|
data/README.md
CHANGED
@@ -88,10 +88,10 @@ module Functions
|
|
88
88
|
model ::Person
|
89
89
|
argument :country_code, types.String
|
90
90
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
91
|
+
# optional custom logic code.
|
92
|
+
# 'relation' represent the data filtered by the built-in array arguments (limit, offset, etc)
|
93
|
+
def query(relation, obj, args, ctx)
|
94
|
+
relation.where(country_code: args[:countryCode]) if args[:countryCode]
|
95
95
|
end
|
96
96
|
end
|
97
97
|
end
|
@@ -7,17 +7,16 @@ module GraphQL
|
|
7
7
|
argument :limit, types.Int
|
8
8
|
argument :offset, types.Int
|
9
9
|
|
10
|
-
def call(
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
def call(*attrs)
|
11
|
+
_, args, = attrs
|
12
|
+
ids_filter = { id: args[:ids] } if args[:ids]
|
13
|
+
relation = @model_class
|
14
|
+
.all
|
15
|
+
.where(ids_filter)
|
16
|
+
.offset(args[:offset])
|
17
|
+
.limit(args[:limit])
|
16
18
|
|
17
|
-
|
18
|
-
relation = call(*args)
|
19
|
-
filtered_relation = yield(relation) if block_given?
|
20
|
-
filtered_relation || relation
|
19
|
+
(query(relation, *attrs) if respond_to?(:query)) || relation
|
21
20
|
end
|
22
21
|
|
23
22
|
def type
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql-functions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joaquín Moreira
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-06-
|
12
|
+
date: 2017-06-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|