File tree Expand file tree Collapse file tree 1 file changed +25
-1
lines changed
apollo-ios/Sources/ApolloAPI Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -104,7 +104,15 @@ public extension SelectionSet {
104
104
func addData( for type: Selection . Field . OutputType , inList: Bool = false ) {
105
105
switch type {
106
106
case . scalar, . customScalar:
107
- fields [ field. responseKey] = fieldData
107
+ if inList {
108
+ guard let listData = fieldData as? [ AnyHashable ] else {
109
+ preconditionFailure ( " Expected list data for field: \( field) " )
110
+ }
111
+
112
+ fields [ field. responseKey] = unwrapAnyHashable ( list: listData) as FieldValue
113
+ } else {
114
+ fields [ field. responseKey] = fieldData
115
+ }
108
116
109
117
case let . nonNull( innerType) :
110
118
addData ( for: innerType, inList: inList)
@@ -146,6 +154,22 @@ public extension SelectionSet {
146
154
preconditionFailure ( " Expected list data to contain objects. " )
147
155
}
148
156
157
+ private func unwrapAnyHashable(
158
+ list: [ AnyHashable ]
159
+ ) -> [ FieldValue ] {
160
+ if let nestedList = list as? [ [ AnyHashable ] ] {
161
+ return nestedList. map { self . unwrapAnyHashable ( list: $0) as FieldValue }
162
+ }
163
+
164
+ return list. map {
165
+ guard let base = $0. base as? FieldValue else {
166
+ preconditionFailure ( " Expected list data to contain objects. " )
167
+ }
168
+ return base
169
+ }
170
+
171
+ }
172
+
149
173
private func addConditionalSelections(
150
174
_ selections: [ Selection ] ,
151
175
to fields: inout [ String : FieldValue ]
You can’t perform that action at this time.
0 commit comments