Graphql查询结果在服务器Ios上更新后得到相同的值

问题描述 投票:0回答:1

我有一个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)
        }

    }
} 
ios graphql
1个回答
1
投票

问题出在查询中的现金政策参数中,使其成为.fetchIgnoringCacheCompletely

 Network.shared.apollo.fetch(query: GetDriverLocationQuery(input: driverId),cachePolicy: .fetchIgnoringCacheCompletely) { [weak self] result in
© www.soinside.com 2019 - 2024. All rights reserved.