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

0.9.0 (7) - Changes to Data Transport #223

Merged
merged 16 commits into from
Mar 12, 2024
Merged

Conversation

phryneas
Copy link
Member

@phryneas phryneas commented Mar 4, 2024

As I don't want to change the shape of the DataTransportAbstraction immediately after we released it for the first time, this one would also need to go into 0.9.0.

This switches from two very separate "request started" and "request finished" events to a stream of events with a shared identifier between queries.

This has the benefit that in the future we can easily track which events are still "unhandled", e.g. for keeping the connection open for longer.

Also, for the first time we detect & communicate errors that happened in SSR to the browser, to restart queries there immediately.

As a positive side-effect of having a "query identifier", the query document is sent only once, not twice over. That already plays a bit into #210.
(Technically, it's sent one more time per hook, so we're down from three times to two).

@phryneas phryneas changed the base branch from main to pr/integration-vitest March 4, 2024 14:28
@phryneas phryneas added this to the 0.10.0 milestone Mar 4, 2024
@phryneas phryneas modified the milestones: 0.10.0, 0.9.0 Mar 5, 2024
@phryneas phryneas marked this pull request as ready for review March 5, 2024 14:53
@phryneas phryneas requested a review from a team as a code owner March 5, 2024 14:53
@phryneas phryneas marked this pull request as draft March 5, 2024 14:54
Base automatically changed from pr/integration-vitest to pr/integration-jest March 6, 2024 10:19
@phryneas phryneas changed the base branch from pr/integration-jest to main March 6, 2024 10:43
@phryneas phryneas marked this pull request as ready for review March 6, 2024 11:29
@phryneas
Copy link
Member Author

phryneas commented Mar 6, 2024

I think this is ready for review now :)

Comment on lines 74 to 102
const streamObservable = new Observable<
Exclude<QueryEvent, { type: "started" }>
>((subscriber) => {
const { markResult, markError, markReady } = queryInfo;
queryInfo.markResult = function (result: FetchResult<any>) {
subscriber.next({
type: "data",
id,
result: result,
});
return markResult.apply(queryInfo, arguments as any);
};
queryInfo.markError = function () {
subscriber.next({
type: "error",
id,
});
subscriber.complete();
return markError.apply(queryInfo, arguments as any);
};
queryInfo.markReady = function () {
subscriber.next({
type: "complete",
id,
});
subscriber.complete();
return markReady.apply(queryInfo, arguments as any);
};
});
Copy link
Member Author

Choose a reason for hiding this comment

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

If someone has a better idea how to tap into link data events instead of wrapping queryInfo functions, I'm all ears. This is the best I could come up with.

Copy link
Member

Choose a reason for hiding this comment

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

I got nothin'

Copy link

relativeci bot commented Mar 6, 2024

Job #14: Bundle Size — 1MiB (+0.76%).

37a3647(current) vs f823d31 main#11(baseline)

Warning

Bundle contains 1 duplicate package – View duplicate packages

Warning

Bundle introduced one new package: react-error-boundary – View changed packages

Bundle metrics  Change 7 changes Regression 3 regressions
                 Current
Job #14
     Baseline
Job #11
Regression  Initial JS 889.61KiB(+0.36%) 886.43KiB
No change  Initial CSS 0B 0B
Change  Cache Invalidation 53.39% 5.35%
Change  Chunks 24(+4.35%) 23
Change  Assets 45(+4.65%) 43
Change  Modules 511(+0.59%) 508
No change  Duplicate Modules 30 30
Regression  Duplicate Code 1.3%(+2.36%) 1.27%
Regression  Packages 29(+3.57%) 28
No change  Duplicate Packages 1 1
Bundle size by type  Change 2 changes Regression 2 regressions
                 Current
Job #14
     Baseline
Job #11
Regression  JS 1022.87KiB (+0.73%) 1015.48KiB
Regression  Other 5.99KiB (+7.22%) 5.59KiB

View job #14 reportView pr/adjust-datatransport branch activityView project dashboard

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.

Had one extremely small nit but this is great! I like the refactoring into events.

Comment on lines 74 to 102
const streamObservable = new Observable<
Exclude<QueryEvent, { type: "started" }>
>((subscriber) => {
const { markResult, markError, markReady } = queryInfo;
queryInfo.markResult = function (result: FetchResult<any>) {
subscriber.next({
type: "data",
id,
result: result,
});
return markResult.apply(queryInfo, arguments as any);
};
queryInfo.markError = function () {
subscriber.next({
type: "error",
id,
});
subscriber.complete();
return markError.apply(queryInfo, arguments as any);
};
queryInfo.markReady = function () {
subscriber.next({
type: "complete",
id,
});
subscriber.complete();
return markReady.apply(queryInfo, arguments as any);
};
});
Copy link
Member

Choose a reason for hiding this comment

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

I got nothin'

…rappedApolloClient.tsx

Co-authored-by: Jerel Miller <jerelmiller@gmail.com>
@phryneas phryneas merged commit 37feeaa into main Mar 12, 2024
12 checks passed
@phryneas phryneas deleted the pr/adjust-datatransport branch March 12, 2024 13:55
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