graphql-functions 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -18
- data/lib/graphql/functions/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a1dfb32a037ebb7d11b446b57e3b6229ec8f9bf
|
4
|
+
data.tar.gz: f83784441b42922be39979cd99740a22a19985c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9da1a49d576d6067296f1556fba9518186f8e492d5cf11e3381a1658221b59b547cd49fa97fa31df9fbeadbc66101e07741eadda5af364d62b5e081da5fb9ef3
|
7
|
+
data.tar.gz: 399783cf2ba88d93191831bac9446fa5c6b3eb102e11940d4b963e7e8639ee53aef7d0c5bd92f5f545f8a8413a0070d823cec0f9772cca3490cbc1aa2f24515d
|
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# graphql-functions
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/graphql-functions.svg)](https://badge.fury.io/rb/graphql-functions)
|
4
|
+
[![CircleCI](https://circleci.com/gh/comparaonline/graphql-ruby-functions.svg?style=svg)](https://circleci.com/gh/comparaonline/graphql-ruby-functions)
|
5
|
+
|
3
6
|
Ruby gem made to simplify the standard query creation of the [graphql](http://graphql-ruby.org) gem in your `Active Record` models with predefined **functions**.
|
4
7
|
|
5
8
|
Using the provided functions your graphql **types** will gain standard and generic **query arguments** to limit the amount of rows, use an offset, or filter by an specific id among others; supporting queries like the following:
|
@@ -76,21 +79,7 @@ app\
|
|
76
79
|
|
77
80
|
To help getting started is useful to use the `graphql` [generator](http://graphql-ruby.org/schema/generators#graphqlinstall).
|
78
81
|
|
79
|
-
Then you should
|
80
|
-
|
81
|
-
```ruby
|
82
|
-
# app/graphql/types/query_type.rb
|
83
|
-
module Types
|
84
|
-
QueryType = GraphQL::ObjectType.define do
|
85
|
-
name "Query"
|
86
|
-
|
87
|
-
field :person, function: GraphQL::Functions::Element
|
88
|
-
field :people, function: GraphQL::Functions::Array
|
89
|
-
end
|
90
|
-
end
|
91
|
-
```
|
92
|
-
|
93
|
-
If more specific logic is needed you may create a custom class with an inheritance from `GraphQL::Functions::Element` or `GraphQL::Functions::Array` like:
|
82
|
+
Then you should create a class inside the functions folder subclassing of the two provided functions to the `query type` definition:
|
94
83
|
|
95
84
|
```ruby
|
96
85
|
# app/graphql/functions/people.rb
|
@@ -108,23 +97,33 @@ module Functions
|
|
108
97
|
end
|
109
98
|
```
|
110
99
|
|
100
|
+
```ruby
|
101
|
+
# app/graphql/functions/person.rb
|
102
|
+
|
103
|
+
module Functions
|
104
|
+
class Person < GraphQL::Functions::Element
|
105
|
+
model ::Person
|
106
|
+
end
|
107
|
+
end
|
108
|
+
```
|
109
|
+
|
111
110
|
```ruby
|
112
111
|
# app/graphql/types/query_type.rb
|
113
112
|
module Types
|
114
113
|
QueryType = GraphQL::ObjectType.define do
|
115
114
|
name "Query"
|
116
115
|
|
117
|
-
field :person, function:
|
116
|
+
field :person, function: Functions::Person
|
118
117
|
field :people, function: Functions::People
|
119
118
|
end
|
120
119
|
end
|
121
120
|
```
|
122
121
|
|
123
|
-
Above changes will in addition to the base query capabilities from `graphql-functions` allow the query to filter by countryCode like:
|
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:
|
124
123
|
|
125
124
|
```
|
126
125
|
{
|
127
|
-
|
126
|
+
people(countryCode: 'us', limit: 2, offset: 5) {
|
128
127
|
id,
|
129
128
|
first_name,
|
130
129
|
last_name
|
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.
|
4
|
+
version: 0.1.1
|
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-12 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.
|
160
|
+
rubygems_version: 2.6.11
|
161
161
|
signing_key:
|
162
162
|
specification_version: 4
|
163
163
|
summary: Collection of GraphQL functions to give basic active record like support
|