graphql-functions 0.1.1 → 0.2.0

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
  SHA1:
3
- metadata.gz: 8a1dfb32a037ebb7d11b446b57e3b6229ec8f9bf
4
- data.tar.gz: f83784441b42922be39979cd99740a22a19985c8
3
+ metadata.gz: d70a9a955e8b947021e63139526424d70d3a44aa
4
+ data.tar.gz: 037b83d3f47e3f3438f598064471dd5d0d452f44
5
5
  SHA512:
6
- metadata.gz: 9da1a49d576d6067296f1556fba9518186f8e492d5cf11e3381a1658221b59b547cd49fa97fa31df9fbeadbc66101e07741eadda5af364d62b5e081da5fb9ef3
7
- data.tar.gz: 399783cf2ba88d93191831bac9446fa5c6b3eb102e11940d4b963e7e8639ee53aef7d0c5bd92f5f545f8a8413a0070d823cec0f9772cca3490cbc1aa2f24515d
6
+ metadata.gz: 0acd5f944532299b05d22786bf1df63b832110d136785e31131b6e51f1003f9b3704fbc242e5a764b2592b21259e3f48ab0be8772b61e509b78716aed926d879
7
+ data.tar.gz: c59f284286fd46a40e06d0f28b8fd624ef87e23b616d89e614da3d4049933c36278b4964f5310da0140387d68e2626d89eab05bd8adca003131d3239b2f83cb9
data/README.md CHANGED
@@ -89,9 +89,9 @@ module Functions
89
89
  argument :country_code, types.String
90
90
 
91
91
  def call(obj, args, ctx)
92
- query = super(obj, args, ctx)
93
- query.where(country_code: args[:countryCode]) if args[:countryCode]
94
- query
92
+ query(obj, args, ctx) do |relation|
93
+ relation.where(country_code: args[:countryCode]) if args[:countryCode]
94
+ end
95
95
  end
96
96
  end
97
97
  end
@@ -121,7 +121,7 @@ end
121
121
 
122
122
  Above changes will in addition to the base query capabilities from `graphql-functions` allow the query to filter by `countryCode` in the `people` field like:
123
123
 
124
- ```
124
+ ```graphql
125
125
  {
126
126
  people(countryCode: 'us', limit: 2, offset: 5) {
127
127
  id,
@@ -135,13 +135,13 @@ Above changes will in addition to the base query capabilities from `graphql-func
135
135
 
136
136
  ### Element
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
- - `id: Int`. Filter by the specified id.
138
+ - `id: Int` Filter by the specified id.
139
139
 
140
140
  ### Array
141
141
  Array function add filters-like arguments to the query:
142
- - `offset: Int`). Skip the specified argument of records.
143
- - `limit: Int`). Do not return more rows than the argument.
144
- - `ìds: [Int]`). Filter by the specified ids.
142
+ - `offset: Int` Skip the specified argument of records.
143
+ - `limit: Int` Do not return more rows than the argument.
144
+ - `ids: [Int]` Filter by the specified ids.
145
145
 
146
146
 
147
147
  ## Development
@@ -14,6 +14,12 @@ module GraphQL
14
14
  query
15
15
  end
16
16
 
17
+ def query(*args)
18
+ relation = call(*args)
19
+ filtered_relation = yield(relation) if block_given?
20
+ filtered_relation || relation
21
+ end
22
+
17
23
  def type
18
24
  @type ||= self.class.types[!type_class]
19
25
  end
@@ -1,5 +1,5 @@
1
1
  module GraphQL
2
2
  module Functions
3
- VERSION = '0.1.1'.freeze
3
+ VERSION = '0.2.0'.freeze
4
4
  end
5
5
  end
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.1.1
4
+ version: 0.2.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 00:00:00.000000000 Z
12
+ date: 2017-06-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -157,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
157
  version: '0'
158
158
  requirements: []
159
159
  rubyforge_project:
160
- rubygems_version: 2.6.11
160
+ rubygems_version: 2.6.12
161
161
  signing_key:
162
162
  specification_version: 4
163
163
  summary: Collection of GraphQL functions to give basic active record like support