Skip to content
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

add (TeeTo|ReadFrom)ReadableStreamLink links #387

Merged
merged 9 commits into from
Dec 18, 2024

Conversation

phryneas
Copy link
Member

No description provided.

Copy link

netlify bot commented Nov 11, 2024

Deploy Preview for apollo-client-nextjs-docmodel failed.

Name Link
🔨 Latest commit 400846a
🔍 Latest deploy log https://app.netlify.com/sites/apollo-client-nextjs-docmodel/deploys/6761ce80264fe70008975615

Copy link

pkg-pr-new bot commented Nov 11, 2024

npm i https://pkg.pr.new/apollographql/apollo-client-nextjs/@apollo/client-react-streaming@387
npm i https://pkg.pr.new/apollographql/apollo-client-nextjs/@apollo/experimental-nextjs-app-support@387

commit: 0cfc00a

Copy link
Contributor

github-actions bot commented Nov 11, 2024

size-limit report 📦

Path Size
{ ApolloNextAppProvider, ApolloClient, InMemoryCache } from '@apollo/experimental-nextjs-app-support' (Browser ESM) 7.63 KB (+3.73% 🔺)
{ WrapApolloProvider, ApolloClient, InMemoryCache } from '@apollo/client-react-streaming' (Browser ESM) 2.08 KB (+15.32% 🔺)
{ buildManualDataTransport } from '@apollo/client-react-streaming/manual-transport' (Browser ESM) 3.34 KB (+11.47% 🔺)
@apollo/client-react-streaming (Browser ESM) 2.87 KB (+14.19% 🔺)
@apollo/client-react-streaming (SSR ESM) 7.7 KB (+5.01% 🔺)
@apollo/client-react-streaming (RSC ESM) 7.49 KB (+4.36% 🔺)
@apollo/client-react-streaming/manual-transport (Browser ESM) 3.56 KB (+11.09% 🔺)
@apollo/client-react-streaming/manual-transport (SSR ESM) 8.65 KB (+4.36% 🔺)
@apollo/experimental-nextjs-app-support (Browser ESM) 8.22 KB (+3.4% 🔺)
@apollo/experimental-nextjs-app-support (SSR ESM) 13.33 KB (+2.08% 🔺)
@apollo/experimental-nextjs-app-support (RSC ESM) 7.46 KB (+3.63% 🔺)
@apollo/experimental-nextjs-app-support/rsc (RSC ESM) 6.65 KB (+4.38% 🔺)

Copy link

relativeci bot commented Nov 11, 2024

#339 Bundle Size — 1.25MiB (+0.06%).

0cfc00a(current) vs 9d0a77a main#331(baseline)

Warning

Bundle contains 1 duplicate package – View duplicate packages

Bundle metrics  Change 2 changes Regression 1 regression
                 Current
#339
     Baseline
#331
Regression  Initial JS 1017.58KiB(+0.08%) 1016.77KiB
No change  Initial CSS 70B 70B
Change  Cache Invalidation 22.06% 0.08%
No change  Chunks 34 34
No change  Assets 59 59
No change  Modules 636 636
No change  Duplicate Modules 106 106
No change  Duplicate Code 4.66% 4.66%
No change  Packages 26 26
No change  Duplicate Packages 1 1
Bundle size by type  Change 1 change Regression 1 regression
                 Current
#339
     Baseline
#331
Regression  JS 1.24MiB (+0.06%) 1.24MiB
No change  Other 9.09KiB 9.09KiB
No change  CSS 70B 70B

Bundle analysis reportBranch pr/framework-explorationsProject dashboard


Generated by RelativeCIDocumentationReport issue

Copy link
Member

@jerelmiller jerelmiller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code itself looks good. Most of my comments were in regards to naming.


if (controller) {
return new Observable((observer) => {
const subscription = forward(operation).subscribe(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we move to RxJS, this signature is deprecated. Can you use an observer object instead?

.subscribe({
  next: () => {...},
  error: () => {...},
  complete: () => {...}
})

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +49 to +53
/**
* A link that allows the request to be cloned into a readable stream, e.g. for
* transport of multipart responses from RSC or a server loader to the browser.
*/
export const TeeToReadableStreamLink = new ApolloLink((operation, forward) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at #389, it looks like these are used internally and not actually set by the user. If that is the case, should we mark these links as @internal? (same goes for the read link)

Suggested change
/**
* A link that allows the request to be cloned into a readable stream, e.g. for
* transport of multipart responses from RSC or a server loader to the browser.
*/
export const TeeToReadableStreamLink = new ApolloLink((operation, forward) => {
/**
* A link that allows the request to be cloned into a readable stream, e.g. for
* transport of multipart responses from RSC or a server loader to the browser.
*
* @internal
*/
export const TeeToReadableStreamLink = new ApolloLink((operation, forward) => {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say that everything in this package could be considered "internal" or as a building block for "build-your-own-framework". These links will e.g. be used outside of the ApolloClient implementations of this package in the React-Router implementation.

* @param context
* @returns
*/
export function readFromReadableStream<T extends Record<string, any>>(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question as the link. Should these be marked as @internal since they seem to be used internally in #389?

}

const teeToReadableStreamKey = Symbol.for(
"apollo.tee.readableStreamController"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"apollo.tee.readableStreamController"
"apollo.readableStreamController"

Is there anything else we'd consider putting on apollo.tee.*? If not, I'd simplify this to a single namespace (same goes for the read key)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are common enough that I see them colliding with something else in the future - it's so close to a web standard type that I would combine it with the method calling it: https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamDefaultController

@phryneas phryneas changed the base branch from main to next December 18, 2024 09:19
@phryneas phryneas marked this pull request as ready for review December 18, 2024 09:26
@phryneas phryneas requested a review from a team as a code owner December 18, 2024 09:26
Copy link

changeset-bot bot commented Dec 18, 2024

🦋 Changeset detected

Latest commit: 0cfc00a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@apollo/client-react-streaming Minor
@apollo/experimental-nextjs-app-support Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

This reverts commit 31b9d01.
@phryneas phryneas merged commit 20ce0c8 into next Dec 18, 2024
17 checks passed
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