-
-
Notifications
You must be signed in to change notification settings - Fork 312
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
apollo-angular prevents Zone from becoming stable #2251
Comments
This is documented in https://the-guild.dev/graphql/apollo-angular/docs/performance/server-side-rendering#using-apollo-devtools, and the better solution is: // When providing options
{
provide: APOLLO_OPTIONS,
useFactory: () {
return {
connectToDevTools: false
// ...
};
},
},
// Or when creating the client
apollo.create({
connectToDevTools: false
// ...
}) |
But... does that not disable the Apollo Developer tools, which I want to use? |
It is not possible to use Apollo Developer tools on server side, but if you want to keep using it on the browser side, then you can do it conditionally, with something roughly like that: const platformId = inject(PLATFORM_ID);
const isBrowser = isPlatformBrowser(platformId);
return {
ssrMode: !isBrowser,
connectToDevTools: isBrowser,
}; |
Yes, I want to use the Developer tools on the client, not on the server. This issue is even relevant with no SSR at all, still preventing |
Create a minimal reproduction case that attempts that, probably in a dedicated repository, and then we can work on it
What is your use-case for a stable application in the browser ? |
https://github.com/diesieben07/apollo-angular-stable-repro To reproduce start the dev server ( The same can be observed in production ( This delay goes away if the
I do not have one, because this is a fairly niche feature of Angular. It is however used for SSR. My argument here was that this issue exists completely separate from and is not related to any kind of server side rendering. |
Otherwise, we might encounter a delay of 10 seconds, and this might lead to suboptimal experience as described in https://angular.io/errors/NG0506 Fixes #2251
Otherwise, we might encounter a delay of 10 seconds, and this might lead to suboptimal experience as described in https://angular.io/errors/NG0506 Fixes #2251
Otherwise, we might encounter a delay of 10 seconds, and this might lead to suboptimal experience as described in https://angular.io/errors/NG0506 Fixes #2251
Describe the bug
When apollo-angular is used with Angular SSR and a GraphQL query is made from an
APP_INITIALIZER
then Angular hydration is delayed by about 10 seconds.This happens, because
ApolloClient
usessetTimeout
when constructed to suggest you to use its devtools. ThissetTimeout
prevents Zone from becoming stable, delaying hydration.To Reproduce
Use apollo-angular from within an
APP_INITIALIZER
in an Angular App using Angular 17 SSR. Observe the "Angular hydrated ..." message being delayed.Expected behavior
apollo-angular should not delay hydration /
ApplicationRef#isStable
.Environment:
Additional context
To fix this, the call to the
ApolloClient
constructor should be wrapped inzone.runOutsideAngular
. I have worked around this problem like so:The text was updated successfully, but these errors were encountered: