apollo-ios
                                
                                 apollo-ios copied to clipboard
                                
                                    apollo-ios copied to clipboard
                            
                            
                            
                        Deprecated initialization of URLSessionTask
On URLSessionClient():122 we are initializing a dummy URLSessionTask using a deprecated initializer. This is only being used when a request fails pre-flight. Should we make this function throwing or return an optional to solve this?
 @discardableResult
  open func sendRequest(_ request: URLRequest,
                        rawTaskCompletionHandler: RawCompletion? = nil,
                        completion: @escaping Completion) -> URLSessionTask {
    guard self.hasNotBeenInvalidated else {
      completion(.failure(URLSessionClientError.sessionInvalidated))
      return URLSessionTask()
    }
    
    let task = self.session.dataTask(with: request)
    let taskData = TaskData(rawCompletion: rawTaskCompletionHandler,
                            completionBlock: completion)
    
    self.tasks.mutate { $0[task.taskIdentifier] = taskData }
    
    task.resume()
    
    return task
  }
@AnthonyMDev I believe we should be returning an optional with nil for the guard failure. This function is being asked to return a task and IMO an optional would be enough indication that it was successful or not, especially when you consider that the completion block is called on failure.
Yeah, I think the main reason I wanted to return a Task was not to need the optional, but realistically almost anyplace that's holding onto the task is going to be holding on to it optionally for cancellation purposes etc. so returning an optional task should be fine.