Skip to content

Commit 978d6b1

Browse files
gh-action-runnergh-action-runner
authored andcommitted
Squashed 'apollo-ios/' changes from 89e8b1af..899d297e
899d297e feature: Configure `URLRequest` timeout interval (#618) 5c98f56e Update ROADMAP.md git-subtree-dir: apollo-ios git-subtree-split: 899d297e4825b364e380d7007fa0904be9e50a50
1 parent 3ef7b42 commit 978d6b1

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

ROADMAP.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 🔮 Apollo iOS Roadmap
22

3-
**Last updated: 2025-03-04**
3+
**Last updated: 2025-03-18**
44

55
For up to date release notes, refer to the project's [Changelog](https://github.com/apollographql/apollo-ios/blob/main/CHANGELOG.md).
66

Sources/Apollo/HTTPRequest.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,14 @@ open class HTTPRequest<Operation: GraphQLOperation>: Hashable {
8585
/// - Throws: Any error in creating the request
8686
/// - Returns: The URL request, ready to send to your server.
8787
open func toURLRequest() throws -> URLRequest {
88-
var request = URLRequest(url: self.graphQLEndpoint)
89-
88+
var request: URLRequest
89+
90+
if let configContext = context as? any RequestContextTimeoutConfigurable {
91+
request = URLRequest(url: self.graphQLEndpoint, timeoutInterval: configContext.requestTimeout)
92+
} else {
93+
request = URLRequest(url: self.graphQLEndpoint)
94+
}
95+
9096
for (fieldName, value) in additionalHeaders {
9197
request.addValue(value, forHTTPHeaderField: fieldName)
9298
}

Sources/Apollo/RequestContext.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,15 @@ import ApolloAPI
1010
/// This allows the various interceptors to make modifications, or perform actions, with information
1111
/// that they cannot get just from the existing operation. It can be anything that conforms to this protocol.
1212
public protocol RequestContext {}
13+
14+
/// A request context specialization protocol that specifies options for configuring the timeout of a `URLRequest`.
15+
///
16+
/// A `RequestContext` object can conform to this protocol to provide a custom `requestTimeout` for an individual request.
17+
/// If the `RequestContext` for a request does not conform to this protocol, the default request timeout of `URLRequest` will be used.
18+
public protocol RequestContextTimeoutConfigurable: RequestContext {
19+
/// The timeout interval specifies the limit on the idle interval allotted to a request in the process of
20+
/// loading. This timeout interval is measured in seconds.
21+
///
22+
/// The value of this property will be set as the `timeoutInterval` on the `URLRequest` created for this GraphQL request.
23+
var requestTimeout: TimeInterval { get }
24+
}

0 commit comments

Comments
 (0)