Skip to content

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

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

Draft
wants to merge 27 commits into
base: Executor-async
Choose a base branch
from

Conversation

AnthonyMDev
Copy link
Contributor

  • 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.

This encapsulates all single response and multi-part response parsing into a single parser that takes in and returns an AsyncThrowingStream
This makes it possible to write a mock session for testing
Removes extra String serialization and deserialization and improves performance
Removes extra String serialization and deserialization and improves performance
Removes extra String serialization and deserialization and improves performance
Removes extra String serialization and deserialization and improves performance
Removes extra String serialization and deserialization and improves performance
Removes extra String serialization and deserialization and improves performance
@svc-apollo-docs
Copy link
Collaborator

svc-apollo-docs commented May 15, 2025

⚠️ 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: 021a9e583d9fe71d767f98ab

@AnthonyMDev AnthonyMDev changed the title [v2] RequestChain + Response Parsing Rewrite [v2] [3/X] RequestChain + Response Parsing Rewrite May 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants