apollo-ios-dev icon indicating copy to clipboard operation
apollo-ios-dev copied to clipboard

[v2] [3/X] RequestChain + Response Parsing Rewrite

Open AnthonyMDev opened this issue 6 months ago • 2 comments

  • Reimagines the Request Chain for async/await usage. This is a very large and very impactful change. Users who are implementing custom interceptors will need to update their interceptors to this new pattern.
  • URLSessionClient has been replaced by ApolloURLSession protocol
    • URLSession automatically conforms to the protocol
    • Network calls now use URLSession.bytes(for: delegate:) to allow for multipart response to be handled incrementally without implementing URLSessionDelegate.
    • This allows users to provide their own URLSession and build custom delegate for their session.
    • AsyncHTTPResponseChunkSequence parses the data into chunks based on the multipart boundary and returns a stream of chunks.
  • Response parsing has been majorly refactored. JSONParser now handles all parsing, including incremental/multipart parsing for @defer and subscriptions.
    • JSON parsing now parses multipart chunks as Data instead of as String. This removes the step where we serialized response data into a string, parsed it into chunks, serialized it back into Data, so we could pass it to the JSONSerialization and re-serialize it into JSON. Now, serialization only occurs once.

AnthonyMDev avatar May 15 '25 22:05 AnthonyMDev

⚠️ Docs preview not attached to branch

The preview was not built because the PR's base branch Executor-async is not in the list of sources.

An Apollo team member can comment one of the following commands to dictate which branch to attach the preview to:

  • !docs set-base-branch main

Build ID: 920b30953e84bf50e6567903

svc-apollo-docs avatar May 15 '25 22:05 svc-apollo-docs

Going to slowly make our way through these during the week - there is a lot to review. 😓

calvincestari avatar May 19 '25 16:05 calvincestari