graphql-client 0.8.1 → 0.8.2
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/graphql/client/query_result.rb +55 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f25cf31f15a80b4f310b6cbc8cba4f536ae6b8ef
|
4
|
+
data.tar.gz: 2481de14f0b278a24a17771de111d661589d004e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08cccc2e230f043b4460dcc2bc352ce5c0e6510709663971ac517da36f390668beed64c9bb702aef5d6e2bea8a5ba97a67cc5ae36715e2c49af3c124328226f7'
|
7
|
+
data.tar.gz: 8a311fdf37db44780cbc739e870b4ca706a2884d37f07647e152d4384d869d92051ea6d6513422376bcb77fdb7bda0cf51468f082cad93d5e342ce870215716a
|
@@ -30,7 +30,26 @@ module GraphQL
|
|
30
30
|
ListWrapper.new(wrap(source_definition, node, type.of_type, name: name))
|
31
31
|
when GraphQL::ScalarType
|
32
32
|
ScalarWrapper.new(type)
|
33
|
-
when GraphQL::
|
33
|
+
when GraphQL::EnumType
|
34
|
+
EnumWrapper.new(type)
|
35
|
+
when GraphQL::UnionType
|
36
|
+
types = {}
|
37
|
+
|
38
|
+
node.selections.each do |selection|
|
39
|
+
case selection
|
40
|
+
when Language::Nodes::InlineFragment
|
41
|
+
selection_type = source_definition.document_types[selection]
|
42
|
+
selection_wrapper = wrap(source_definition, selection, selection_type, name: name)
|
43
|
+
if types[selection_type]
|
44
|
+
types[selection_type.name] |= selection_wrapper
|
45
|
+
else
|
46
|
+
types[selection_type.name] = selection_wrapper
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
UnionWrapper.new(types)
|
52
|
+
when GraphQL::ObjectType, GraphQL::InterfaceType
|
34
53
|
fields = {}
|
35
54
|
|
36
55
|
node.selections.each do |selection|
|
@@ -57,6 +76,26 @@ module GraphQL
|
|
57
76
|
end
|
58
77
|
end
|
59
78
|
|
79
|
+
class UnionWrapper
|
80
|
+
def initialize(possible_types)
|
81
|
+
@possible_types = possible_types
|
82
|
+
end
|
83
|
+
|
84
|
+
def cast(value, errors = nil)
|
85
|
+
typename = value && value["__typename"]
|
86
|
+
if wrapper = @possible_types[typename]
|
87
|
+
wrapper.cast(value, errors)
|
88
|
+
else
|
89
|
+
raise TypeError, "expected union value to be #{@possible_types.keys.join(", ")}, but was #{typename}"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def |(_other)
|
94
|
+
# XXX: How would union merge?
|
95
|
+
self
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
60
99
|
class ListWrapper
|
61
100
|
def initialize(type)
|
62
101
|
@of_klass = type
|
@@ -109,6 +148,21 @@ module GraphQL
|
|
109
148
|
end
|
110
149
|
end
|
111
150
|
|
151
|
+
class EnumWrapper
|
152
|
+
def initialize(type)
|
153
|
+
@type = type
|
154
|
+
end
|
155
|
+
|
156
|
+
def cast(value, _errors = nil)
|
157
|
+
value
|
158
|
+
end
|
159
|
+
|
160
|
+
def |(_other)
|
161
|
+
# XXX: How would enums merge?
|
162
|
+
self
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
112
166
|
# :nodoc:
|
113
167
|
class ScalarWrapper
|
114
168
|
def initialize(type)
|