我有一个getdriverLocation
查询以从服务器getdriverLocation query获取经纬度,并且我也有updateDriverLocation
变异updateDriverLoacation mutation。
问题是,当服务器上使用突变的updatedriverlocation
成功更新并出现在操场上时,但是当我从Xcode调用它时,查询在应用程序运行时获取了旧值,我应该重新启动应用程序以更新它以及此代码获取位置
func getDriver(driverId:String, completion: @escaping Generalcompletion){
Network.shared.apollo.fetch(query: GetDriverLocationQuery(input: driverId)) { [weak self] result in
guard self != nil else {
return
}
switch result {
case .success(let graphqlResult):
if let location = graphqlResult.data?.getDriverLocation{
let lat = (location.latitude as NSString).doubleValue
let lon = (location.longitude as NSString).doubleValue
self?.driverLocation = CLLocationCoordinate2D(latitude: lat, longitude: lon)
completion(true,nil)
}
if let errors = graphqlResult.errors {
let message = errors.map { $0.localizedDescription }.joined(separator: "\n")
completion(false,message)
}
case .failure(let error):
debugPrint("Error In get Driver Locations \(error)")
completion(false,nil)
}
}
}
问题出在查询中的现金政策参数中,使其成为.fetchIgnoringCacheCompletely
Network.shared.apollo.fetch(query: GetDriverLocationQuery(input: driverId),cachePolicy: .fetchIgnoringCacheCompletely) { [weak self] result in