feat(apollo): subscription with initial data #3234
Closed
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.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Subscriptions created by utilizing the @nestjs/graphql related libs only serve updates triggered by the
PubSub.asyncIterator
while in some circumstances a subscription may serve initial data to avoid a Query + Subscription scenario resulting in complicated merges within the clients' business logic.Issue Number: N/A
What is the new behavior?
A utils function has been added which can be used to combine an
AsyncIterator
with an array of existing data returning anAsyncIterableIterator
which does satisfy theAsyncIterator
interface - meaning that existing code / frameworks will not be broken if employed - while serving the list of initial entries first, followed by all real-time updates triggered via the PubSub iterator.Does this PR introduce a breaking change?
Other information
The
apollo
package may not be the right place to store such utils, feedback would be highly appreciated!Furthermore, an update to linting related dependencies had to be made in order to run the husky pre-commit locally.