graphql-functions 0.3.2 → 0.4.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 -2
- data/lib/graphql/functions/element.rb +6 -2
- 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: 20280c76f7dbf2582658fc8f9275d80c978c6d83
|
4
|
+
data.tar.gz: 28421554b25956c14aa0e545b2b764b705caf82c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffe22e28a9b6bad6314e6ed35859c288706d48fe798506fa14f426b1a0c827afb19b253db39eb56abdf7ab4717069bd27a4635a2b61cb88ecfb989b536095584
|
7
|
+
data.tar.gz: ffc6de0028113649803170fc41fb69d2aa49e83d1faf18e781a09f4af91290ae35bd0ff55d5a64143bcbe48333735b8de0098eb89922fa8835fcbd9d1ce6f33a
|
data/README.md
CHANGED
@@ -113,8 +113,8 @@ module Types
|
|
113
113
|
QueryType = GraphQL::ObjectType.define do
|
114
114
|
name "Query"
|
115
115
|
|
116
|
-
field :person, function: Functions::Person
|
117
|
-
field :people, function: Functions::People
|
116
|
+
field :person, function: Functions::Person.create
|
117
|
+
field :people, function: Functions::People.create
|
118
118
|
end
|
119
119
|
end
|
120
120
|
```
|
@@ -137,6 +137,8 @@ Above changes will in addition to the base query capabilities from `graphql-func
|
|
137
137
|
Element function is intended to be used with a query with a single field output like `person` in the example: The only available argument is id:
|
138
138
|
- `id: Int` Filter by the specified id.
|
139
139
|
|
140
|
+
If `id` is not specified or if the subclass implements its own `query` method which does not return a single element, the first element of the model is returned.
|
141
|
+
|
140
142
|
### Array
|
141
143
|
Array function add filters-like arguments to the query:
|
142
144
|
- `offset: Int` Skip the specified argument of records.
|
@@ -5,8 +5,12 @@ module GraphQL
|
|
5
5
|
class Element < Base
|
6
6
|
argument :id, !types.ID
|
7
7
|
|
8
|
-
def call(
|
9
|
-
|
8
|
+
def call(*attrs)
|
9
|
+
_, args, = attrs
|
10
|
+
return @model_class.find(args[:id]) if args[:id]
|
11
|
+
return @model_class.first unless respond_to?(:query)
|
12
|
+
relation = query(@model_class, *attrs)
|
13
|
+
relation.is_a?(ActiveRecord::Relation) ? relation.first : relation
|
10
14
|
end
|
11
15
|
|
12
16
|
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.4.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-
|
12
|
+
date: 2017-09-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|