
Portion of code:
public final class ViewerUserDataQuery: GraphQLQuery {
public static let operationDefinition =
"query viewerUserData($keys: [String!]) {" +
" viewer {" +
" user {" +
" data(keys: $keys) {" +
" key" +
" value" +
" }" +
" }" +
" }" +
"}"
public let keys: [String]?
public init(keys: [String]? = nil) {
self.keys = keys
}
public var variables: GraphQLMap? {
return ["keys": keys] // Error here
}
The autosuggestion corrects the issue, but re building reruns the script...
public var variables: GraphQLMap? {
return ["keys": keys as! Optional<JSONEncodable>]
}
Thanks for reporting this. It turns out variables of list types are currently not supported by the mechanism we use to convert a dictionary literal into a GraphQLMap. I'm actually in the process of revising this whole approach as part of adding caching support, so I'll see if I can get the relevant code merged sooner.
I just released version 0.4.0 of Apollo iOS, which should fix this issue. (You'll also have to update apollo-codegen to 0.9, but it will warn you if you don't.)
Please give it a try and let me know if it works for you!
Most helpful comment
Thanks for reporting this. It turns out variables of list types are currently not supported by the mechanism we use to convert a dictionary literal into a
GraphQLMap. I'm actually in the process of revising this whole approach as part of adding caching support, so I'll see if I can get the relevant code merged sooner.