graphoid 0.0.5 → 0.0.6
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 +13 -3
- data/lib/graphoid/definitions/{orders.rb → sorter.rb} +5 -5
- data/lib/graphoid/definitions/types.rb +1 -1
- data/lib/graphoid/grapho.rb +1 -1
- data/lib/graphoid.rb +1 -1
- metadata +3 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f378f4073367b10933692401392122f489e280eba371c5d948e6b658f4a41681
|
4
|
+
data.tar.gz: b15c2a74576a089e7ac348db36064bee3c5a453c058ee49e1b2ade70ed31d767
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 198545eb295723959addc1cb94b7f875c75efade653454385cf2664467cd7d5e2a9b0bba144be72db3d3f77412008c90566f0bcde0fa38c9b99e291a2a0c8546
|
7
|
+
data.tar.gz: c5a940b62e3edb6e43caaf0f569a85652ee73ccbcbac037a1317fab0d77ac8b21c56f897e198de69bd4e3f24e7071e3f7f490d27b9d98a1856fe52f2e314b83e
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
<img src="https://d3a1eqpdtt5fg4.cloudfront.net/items/0T0M3O2R1q2W3i1p3e0A/graphoid.png" height="
|
2
|
+
<img src="https://d3a1eqpdtt5fg4.cloudfront.net/items/0T0M3O2R1q2W3i1p3e0A/graphoid.png" height="150" alt="graphoid"/>
|
3
3
|
|
4
4
|
[](https://travis-ci.org/maxiperezc/graphoid)
|
5
5
|
[](https://rubygems.org/gems/graphoid)
|
@@ -8,8 +8,9 @@ This gem is used to generate a full GraphQL API using introspection of Mongoid o
|
|
8
8
|
After installing it, you will have create, update, delete, and query actions on any rails models you want.
|
9
9
|
|
10
10
|
## Dependency
|
11
|
-
This gem depends on the
|
12
|
-
|
11
|
+
This gem depends on [the GraphQL gem](https://github.com/rmosolgo/graphql-ruby).
|
12
|
+
|
13
|
+
Please install that gem first before continuing
|
13
14
|
|
14
15
|
## Installation
|
15
16
|
Add this line to your Gemfile:
|
@@ -58,6 +59,9 @@ class Person
|
|
58
59
|
end
|
59
60
|
```
|
60
61
|
|
62
|
+
## Examples
|
63
|
+
You can find an example that uses ActiveRecord in the [Tester AR folder](https://github.com/maxiperezc/graphoid/tree/master/spec/tester_ar) and an example with Mongoid in the [Tester Mongo folder](https://github.com/maxiperezc/graphoid/tree/master/spec/tester_mongo) of this same repository.
|
64
|
+
|
61
65
|
## Contributing
|
62
66
|
- Install code climate
|
63
67
|
- Functionality to sort top level models by association values
|
@@ -76,5 +80,11 @@ end
|
|
76
80
|
- Embedded::Many filtering implementation
|
77
81
|
- Embedded::One filtering with OR/AND
|
78
82
|
|
83
|
+
## Testing
|
84
|
+
```bash
|
85
|
+
$ DRIVER=ar DEBUG=true bundle exec rspec
|
86
|
+
$ DRIVER=mongo DEBUG=true bundle exec rspec
|
87
|
+
```
|
88
|
+
|
79
89
|
## License
|
80
90
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
@@ -1,19 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Graphoid
|
4
|
-
module
|
4
|
+
module Sorter
|
5
5
|
LIST = {}
|
6
6
|
@@enum_type = nil
|
7
7
|
|
8
8
|
class << self
|
9
9
|
def generate(model)
|
10
10
|
LIST[model] ||= GraphQL::InputObjectType.define do
|
11
|
-
name("#{Utils.graphqlize(model.name)}
|
12
|
-
description("Generated model
|
11
|
+
name("#{Utils.graphqlize(model.name)}Sorter")
|
12
|
+
description("Generated model Sorter for #{model.name}")
|
13
13
|
|
14
14
|
Attribute.fields_of(model).each do |field|
|
15
15
|
name = Utils.camelize(field.name)
|
16
|
-
argument(name,
|
16
|
+
argument(name, Sorter.enum_type)
|
17
17
|
end
|
18
18
|
|
19
19
|
Relation.relations_of(model).each do |name, relation|
|
@@ -32,7 +32,7 @@ module Graphoid
|
|
32
32
|
|
33
33
|
def enum_type
|
34
34
|
@@enum_type ||= GraphQL::EnumType.define do
|
35
|
-
name '
|
35
|
+
name 'SorterType'
|
36
36
|
|
37
37
|
value 'ASC', 'Ascendent'
|
38
38
|
value 'DESC', 'Descendent'
|
@@ -61,7 +61,7 @@ module Graphoid
|
|
61
61
|
next unless relation_type
|
62
62
|
|
63
63
|
filter = Graphoid::Filters::LIST[relation_class]
|
64
|
-
order = Graphoid::
|
64
|
+
order = Graphoid::Sorter::LIST[relation_class]
|
65
65
|
|
66
66
|
if Relation.new(relation).many?
|
67
67
|
plural_name = name.pluralize
|
data/lib/graphoid/grapho.rb
CHANGED
@@ -9,7 +9,7 @@ module Graphoid
|
|
9
9
|
build_naming(model)
|
10
10
|
|
11
11
|
@type = Graphoid::Types.generate(model)
|
12
|
-
@order = Graphoid::
|
12
|
+
@order = Graphoid::Sorter.generate(model)
|
13
13
|
@input = Graphoid::Inputs.generate(model)
|
14
14
|
@filter = Graphoid::Filters.generate(model)
|
15
15
|
end
|
data/lib/graphoid.rb
CHANGED
@@ -31,7 +31,7 @@ require 'graphoid/drivers/mongoid'
|
|
31
31
|
require 'graphoid/drivers/active_record'
|
32
32
|
|
33
33
|
require 'graphoid/definitions/types'
|
34
|
-
require 'graphoid/definitions/
|
34
|
+
require 'graphoid/definitions/sorter'
|
35
35
|
require 'graphoid/definitions/filters'
|
36
36
|
require 'graphoid/definitions/inputs'
|
37
37
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphoid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maximiliano Perez Coto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-04-
|
11
|
+
date: 2019-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.8.17
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rails
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 5.1.6
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 5.1.6
|
41
27
|
description: A gem that helps you autogenerate a GraphQL API from Mongoid or ActiveRecord
|
42
28
|
models.
|
43
29
|
email:
|
@@ -54,7 +40,7 @@ files:
|
|
54
40
|
- lib/graphoid/config.rb
|
55
41
|
- lib/graphoid/definitions/filters.rb
|
56
42
|
- lib/graphoid/definitions/inputs.rb
|
57
|
-
- lib/graphoid/definitions/
|
43
|
+
- lib/graphoid/definitions/sorter.rb
|
58
44
|
- lib/graphoid/definitions/types.rb
|
59
45
|
- lib/graphoid/drivers/active_record.rb
|
60
46
|
- lib/graphoid/drivers/mongoid.rb
|