graphoid 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/graphoid/mutations/create.rb +14 -10
- data/lib/graphoid/mutations/delete.rb +14 -10
- data/lib/graphoid/queries/queries.rb +15 -12
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e2f377db61ee5c9407c4b88815d73c50a40a2049fed6558f55c1691818b922c
|
4
|
+
data.tar.gz: 2b06c721c9421f7bcbebe789b0c6468b24a29eb6381f5c49bfbe095d4552058d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5eaf51f3fb5ee287831426af53fa32aac270c8f3246ea32a5475ddfe4eb10b9c95ef9a170893ffcb5e2006cce42e02fcf8f765fbf66f43789f65e1b75d5c4d74
|
7
|
+
data.tar.gz: 1486891029aeee089d9294194b547866ecf42e6c93e678ac111f2d8ac129c92dcaaeb18d2a83f08ac192482d7d3992a25d32be49d3c4edd0f7cab4458e0d4edd
|
@@ -24,21 +24,25 @@ module Graphoid
|
|
24
24
|
|
25
25
|
type.class_eval do
|
26
26
|
define_method :"#{name}" do |data: {}|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
begin
|
28
|
+
user = context[:current_user]
|
29
|
+
Graphoid::Mutations::Processor.execute(model, grapho, data, user)
|
30
|
+
rescue Exception => ex
|
31
|
+
GraphQL::ExecutionError.new(ex.message)
|
32
|
+
end
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
34
36
|
type.class_eval do
|
35
37
|
define_method :"#{plural_name}" do |data: []|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
begin
|
39
|
+
user = context[:current_user]
|
40
|
+
result = []
|
41
|
+
data.each { |d| result << Graphoid::Mutations::Processor.execute(model, grapho, d, user) }
|
42
|
+
result
|
43
|
+
rescue Exception => ex
|
44
|
+
GraphQL::ExecutionError.new(ex.message)
|
45
|
+
end
|
42
46
|
end
|
43
47
|
end
|
44
48
|
end
|
@@ -24,21 +24,25 @@ module Graphoid
|
|
24
24
|
|
25
25
|
type.class_eval do
|
26
26
|
define_method :"#{name}" do |id:|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
begin
|
28
|
+
result = model.find(id)
|
29
|
+
result.destroy!
|
30
|
+
result
|
31
|
+
rescue Exception => ex
|
32
|
+
GraphQL::ExecutionError.new(ex.message)
|
33
|
+
end
|
32
34
|
end
|
33
35
|
end
|
34
36
|
|
35
37
|
type.class_eval do
|
36
38
|
define_method :"#{plural}" do |where: {}|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
begin
|
40
|
+
objects = Graphoid::Queries::Processor.execute(model, where.to_h)
|
41
|
+
objects.destroy_all
|
42
|
+
objects.all.to_a
|
43
|
+
rescue Exception => ex
|
44
|
+
GraphQL::ExecutionError.new(ex.message)
|
45
|
+
end
|
42
46
|
end
|
43
47
|
end
|
44
48
|
end
|
@@ -25,23 +25,26 @@ module Graphoid
|
|
25
25
|
|
26
26
|
query_type.class_eval do
|
27
27
|
define_method :"#{grapho.name}" do |id: nil, where: nil|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
28
|
+
begin
|
29
|
+
return model.find(id) if id
|
30
|
+
Processor.execute(model, where.to_h).first
|
31
|
+
rescue Exception => ex
|
32
|
+
GraphQL::ExecutionError.new(ex.message)
|
33
|
+
end
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
36
37
|
query_type.class_eval do
|
37
38
|
define_method :"#{grapho.plural}" do |where: nil, order: nil, limit: nil, skip: nil|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
39
|
+
begin
|
40
|
+
model = Graphoid.driver.eager_load(context.irep_node, model)
|
41
|
+
result = Processor.execute(model, where.to_h)
|
42
|
+
order = Processor.parse_order(model, order.to_h)
|
43
|
+
result = result.order(order).limit(limit)
|
44
|
+
Graphoid.driver.skip(result, skip)
|
45
|
+
rescue Exception => ex
|
46
|
+
GraphQL::ExecutionError.new(ex.message)
|
47
|
+
end
|
45
48
|
end
|
46
49
|
|
47
50
|
alias_method :"_#{grapho.plural}_meta", :"#{grapho.plural}"
|
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.8
|
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-
|
11
|
+
date: 2019-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.8
|
19
|
+
version: '1.8'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.8
|
26
|
+
version: '1.8'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -99,7 +99,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
99
|
- !ruby/object:Gem::Version
|
100
100
|
version: '0'
|
101
101
|
requirements: []
|
102
|
-
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 2.7.9
|
103
104
|
signing_key:
|
104
105
|
specification_version: 4
|
105
106
|
summary: Generates a GraphQL API from Rails ActiveRecord or Mongoid
|