-
Notifications
You must be signed in to change notification settings - Fork 64
[v2] [12/X] ApolloClient Fetch APIs #684
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4794b49
WIP: Setting up FetchBehavior and RequestConfiguration
AnthonyMDev a3d8114
Add FetchBehavior back to GraphQLRequest
AnthonyMDev 311bcf9
Define new CachePolicy API
AnthonyMDev 1a62c2f
Refactor GraphQLQueryWatcher
AnthonyMDev c0e7a1d
Improve CachePolicy APIs
AnthonyMDev 4ce6838
Fix deprecated init recursion
AnthonyMDev d51f2d6
Mutation and Upload APIs
AnthonyMDev e274358
Update NetworkTransport for upload requests and minor fixes
AnthonyMDev 2dc7a6d
Reimagined SplitNetworkTransport
AnthonyMDev 00778e8
Cleanup and Documentation
AnthonyMDev be27f68
[v2] [14/X] NetworkTransport and Client Cleanup (#686)
AnthonyMDev 8a78118
[v2] [13/X] Refactor GraphQLQueryWatcher (#685)
AnthonyMDev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
apollo-ios/Sources/Apollo/AsyncThrowingStream+ExecutingInAsyncTask.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import Foundation | ||
|
||
extension AsyncThrowingStream where Failure == any Swift.Error { | ||
static func executingInAsyncTask( | ||
bufferingPolicy: AsyncThrowingStream<Element, Failure>.Continuation.BufferingPolicy = .unbounded, | ||
_ block: @escaping @Sendable (Continuation) async throws -> Void | ||
) -> Self { | ||
return AsyncThrowingStream(bufferingPolicy: bufferingPolicy) { continuation in | ||
let task = Task { | ||
do { | ||
try await block(continuation) | ||
continuation.finish() | ||
|
||
} catch { | ||
continuation.finish(throwing: error) | ||
} | ||
} | ||
|
||
continuation.onTermination = { _ in task.cancel() } | ||
} | ||
} | ||
} | ||
|
||
extension AsyncThrowingStream.Continuation { | ||
func passthroughResults( | ||
of stream: AsyncThrowingStream<Element, Failure> | ||
) async throws where Element: Sendable { | ||
for try await element in stream { | ||
self.yield(element) | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RequestConfiguration
seems like a good home for this based on the scope/behaviour we discussed yesterday.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way
RequestConfiguration
works, the values are just passed to theNetworkTransport
which then uses them when constructing theGraphQLRequest
. So if we added them there, they would still need to be here also. And I actually think it's vary unlikely right now that you would want a different apq config per request.Probably, you want the same apq config for all requests on the same
NetworkTransport
. So I actually think the current setup is correct.RequestChainNetworkTransport
is initialized with anapqConfig
, and it passes that to each request if constructs. But having it here allows the interceptors to modify the APQ behavior of requests. I think that's what we want.