pggraphql 0.0.8 → 0.0.9
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/lib/pggraphql/version.rb +1 -1
- data/lib/pggraphql.rb +2 -2
- data/test/test_pggraphql.rb +17 -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: c0b33e3078467161a88af120f37b4de4fc10e127
|
|
4
|
+
data.tar.gz: eb9f61d5aa769cab705f3d1194227278fbbe585f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bf40ede2fc8a855cf762dfe9052ba58565696cdbf539a446ad7554c2517389feb1292b089aca5bba7454b6c8eec4fec05e8cb15a2ead57fc69751e2692c55bc7
|
|
7
|
+
data.tar.gz: d970827a05f6af6e537390062ea00fe5443f4e64cf5ce802e2fd06106a5a0227836cb3fe50e4dde05602b7d91d8e5ebd1fe10cf8caa37350cf54de97c0d51fc4
|
data/lib/pggraphql/version.rb
CHANGED
data/lib/pggraphql.rb
CHANGED
|
@@ -59,7 +59,7 @@ module PgGraphQl
|
|
|
59
59
|
|
|
60
60
|
raise "missing :id for root type #{type.name.inspect}" if !ids && level == 1 && !type.null_pk
|
|
61
61
|
|
|
62
|
-
wheres << type.pk.call(ids) if ids && type.pk.call(ids)
|
|
62
|
+
wheres << type.pk.call(ids, level) if ids && type.pk.call(ids, level)
|
|
63
63
|
|
|
64
64
|
wheres << ("(" + type.filter + ")") if type.filter
|
|
65
65
|
|
|
@@ -115,7 +115,7 @@ module PgGraphQl
|
|
|
115
115
|
@subtypes = {}
|
|
116
116
|
@mappings = {}
|
|
117
117
|
@null_pk = false
|
|
118
|
-
@pk = ->(ids) do
|
|
118
|
+
@pk = ->(ids, level) do
|
|
119
119
|
id_column = @mappings[:id] || "id"
|
|
120
120
|
if ids.is_a?(Array)
|
|
121
121
|
"#{id_column} in (" + ids.map{|id| id.is_a?(String) ? "'#{id}'" : id.to_s}.join(',') + ")"
|
data/test/test_pggraphql.rb
CHANGED
|
@@ -97,7 +97,7 @@ module PgGraphQl
|
|
|
97
97
|
def test_simple_pk_custom
|
|
98
98
|
res = to_sql({user: {id: "1", email: "email"}}) do |s|
|
|
99
99
|
s.root :user
|
|
100
|
-
s.type :user, fields: [:email], pk: ->(id){ "access_token = '#{id}'" }
|
|
100
|
+
s.type :user, fields: [:email], pk: ->(id, level){ "access_token = '#{id}'" }
|
|
101
101
|
end
|
|
102
102
|
|
|
103
103
|
assert_equal token(<<-SQL
|
|
@@ -110,6 +110,22 @@ module PgGraphQl
|
|
|
110
110
|
), token(res)
|
|
111
111
|
end
|
|
112
112
|
|
|
113
|
+
def test_simple_pk_with_level
|
|
114
|
+
res = to_sql({user: {id: "99", email: "email"}}) do |s|
|
|
115
|
+
s.root :user
|
|
116
|
+
s.type :user, fields: [:email], pk: ->(id, level){ "level#{level} = '#{id}'" }
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
assert_equal token(<<-SQL
|
|
120
|
+
select 'user'::text as key,
|
|
121
|
+
(select to_json(x.*)
|
|
122
|
+
from (select id,
|
|
123
|
+
email
|
|
124
|
+
from users where level1 = '99' limit 1) x) as value
|
|
125
|
+
SQL
|
|
126
|
+
), token(res)
|
|
127
|
+
end
|
|
128
|
+
|
|
113
129
|
def test_simple_pk_type_handling
|
|
114
130
|
res = to_sql({user: {id: ["1"], email: "email"}}) do |s|
|
|
115
131
|
s.root :user
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pggraphql
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jan Zimmek
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-03-
|
|
11
|
+
date: 2015-03-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: json
|