pggraphql 0.0.9 → 0.0.10
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 +10 -3
- data/test/test_pggraphql.rb +2 -2
- 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: 60ab99d71efd2955788a1616ec4c8a3ebcbe971a
|
4
|
+
data.tar.gz: ec9403901a2fa867d64e08954ff2a69a181df330
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79b377023aa0b3df1297fce755f8a7139ea41055f053099f2d30e1949789e8b7ea34f62fcb68a2b540d63d547d92baef62e8830134ece865f47863f08793c7f2
|
7
|
+
data.tar.gz: 07f8413aaf1fc7ea03c7f82db48330d7bd18f561c41f7e1f8985e2f373a4b13d8526064045967245b2c4cc9854db20684766744f70f5aaef19265bf02d050dae
|
data/lib/pggraphql/version.rb
CHANGED
data/lib/pggraphql.rb
CHANGED
@@ -37,7 +37,11 @@ module PgGraphQl
|
|
37
37
|
raise "#{type.name.inspect} is not a root type" if level == 1 && !@roots.include?(type)
|
38
38
|
raise "missing :fk on link #{link.name.inspect}" if link && !link.fk
|
39
39
|
|
40
|
-
|
40
|
+
requested_fields = {id: nil} # always add :id field
|
41
|
+
requested_fields = requested_fields.merge(type: nil) unless type.subtypes.empty? # always add :subtype
|
42
|
+
requested_fields = requested_fields.merge(e[1])
|
43
|
+
|
44
|
+
columns = requested_fields.map do |f|
|
41
45
|
nested_link_name = f[0]
|
42
46
|
field_name = f[0]
|
43
47
|
|
@@ -108,7 +112,7 @@ module PgGraphQl
|
|
108
112
|
@schema = schema
|
109
113
|
@name = name
|
110
114
|
@table = name.to_s.pluralize.to_sym
|
111
|
-
@fields = [
|
115
|
+
@fields = []
|
112
116
|
@filter = nil
|
113
117
|
@order_by = nil
|
114
118
|
@links = {}
|
@@ -125,7 +129,10 @@ module PgGraphQl
|
|
125
129
|
end
|
126
130
|
end
|
127
131
|
def fields=(fields)
|
128
|
-
@fields =
|
132
|
+
@fields = fields
|
133
|
+
end
|
134
|
+
def fields
|
135
|
+
@fields + [:id] + (@subtypes.empty? ? [] : [:type])
|
129
136
|
end
|
130
137
|
def map(field, column_expr)
|
131
138
|
@mappings[field] = column_expr
|
data/test/test_pggraphql.rb
CHANGED
@@ -314,7 +314,7 @@ module PgGraphQl
|
|
314
314
|
}
|
315
315
|
}) do |s|
|
316
316
|
s.root :product
|
317
|
-
s.type :product, null_pk: :array, fields: [:
|
317
|
+
s.type :product, null_pk: :array, fields: [:clickout__destination_url, :download__download_url] do |t|
|
318
318
|
t.map :id, "products.id"
|
319
319
|
t.subtype :clickout, table: :product_clickouts, fk: "clickout.id = products.id and products.type = 'clickout'"
|
320
320
|
end
|
@@ -323,7 +323,7 @@ module PgGraphQl
|
|
323
323
|
assert_equal token(<<-SQL
|
324
324
|
select 'products'::text as key,
|
325
325
|
(select to_json(x.*)
|
326
|
-
from (select products.id as id,
|
326
|
+
from (select products.id as id, type,
|
327
327
|
clickout.destination_url as clickout__destination_url
|
328
328
|
from products
|
329
329
|
left join product_clickouts as clickout on (clickout.id = products.id
|
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.10
|
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-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|