Intellisense not working for Apollo-ios in AppCode Xcode is working.

Answered

Hello There,

I am playing around with AppCode to see weather it will be suitable for our organisation.  I have hit a road block and hoping someone can help me out.

We use graphQL in my organisation, Apollo has made an amazing open source client for graphQL called Apollo IOS. We use this client via cocoapod in xcode. We have no problem in XCode, but AppCode some of the Intellisense don't work.

Problem 

Before I jump into the problem, I have created a github project for this issue. You can find it : https://github.com/tony0011/appcodetest

The Apollo IOS pod exposes the following fetch function which allows you to send your query objects to the graphql Api and retrieve results from database. It's a generic function that expects any class that is driven from  GraphQLQuery.


---- Link to github class https://github.com/apollographql/apollo-ios/blob/master/Sources/Apollo/ApolloClient.swift

/// Fetches a query from the server or from the local cache, depending on the current contents of the cache and the specified cache policy.
///
/// - Parameters:
/// - query: The query to fetch.
/// - cachePolicy: A cache policy that specifies when results should be fetched from the server and when data should be loaded from the local cache.
/// - queue: A dispatch queue on which the result handler will be called. Defaults to the main queue.
/// - resultHandler: An optional closure that is called when query results are available or when an error occurs.
/// - Returns: An object that can be used to cancel an in progress fetch.
@discardableResult public func fetch<Query: GraphQLQuery>(query: Query, cachePolicy: CachePolicy = .returnCacheDataElseFetch, queue: DispatchQueue = DispatchQueue.main, resultHandler: OperationResultHandler<Query>? = nil) -> Cancellable {
return _fetch(query: query, cachePolicy: cachePolicy, queue: queue, resultHandler: resultHandler)
}

func _fetch<Query: GraphQLQuery>(query: Query, cachePolicy: CachePolicy, context: UnsafeMutableRawPointer? = nil, queue: DispatchQueue, resultHandler: OperationResultHandler<Query>?) -> Cancellable {
// If we don't have to go through the cache, there is no need to create an operation
// and we can return a network task directly
if cachePolicy == .fetchIgnoringCacheData {
return send(operation: query, context: context, handlerQueue: queue, resultHandler: resultHandler)
} else {
let operation = FetchQueryOperation(client: self, query: query, cachePolicy: cachePolicy, context: context, handlerQueue: queue, resultHandler: resultHandler)
operationQueue.addOperation(operation)
return operation
}
}

I am using the above function as following.

class ViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let apollo = ApolloClient(url: URL(string: "http://localhost:8080/graphql")!)

var userProfile = UserProfileQuery()
apollo.fetch(query: userProfile) { (result, error) in

print(result?.data?.me)

}
}
}

Issue

In Xcode the result?.data? shows the UserProfileQuery.data object as seen in screen show below. I am expecting UserProfileQuery?



However, in AppCode this is not the case. Following screenshot is taken from Appcode. It appears that Appcode cannot figure out that the result is UserProfile.Data I suspect issues with generics.

 

 

any help is appreciated 

0
2 comments
Avatar
Permanently deleted user
Official comment

Hi! Thank you for the detailed description and sample project! We've reproduced the problem and will investigate it. There is a corresponding issue in the tracker - https://youtrack.jetbrains.com/issue/OC-17682. Feel free to follow and upvote. Sorry for the inconvenience.

Avatar
Permanently deleted user

Thanks Olga, I will follow the issue tracker. 

 

 

0

Please sign in to leave a comment.