-
-
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
new feature: SchemaLink for Angular Universal #452
Comments
wow, interesting, is that work with can I ask, what is: |
Yes, that's true. Angular bootstraps when it goes stable and it is stable where there are no more Tasks running. I was working hard with Zone.js and its Tasks while fixing SSR support for This is why I was soooo happy when ApolloClient 2.0 introduced ApolloLinks. This way I could use Angular's Angular side of Apollo Community could create an ApolloLink that schedules Zone.js's MacroTask and completes it after execution of Links like |
Long time, still no straight forward solution for this issue :) Here is the standalone gist which includes Basically it can be used like: In backend
And in
@hiepxanh, for line 3, you may look into gist above. As mentioned before it relays on adapted copy paste of For websockets... What is websocket? Connection established from client browser to server. Whole point of using |
Server side Angular allows to render on server. If angular
ServerAppModule
and GraphQL server are running in same process, it could be possible to shortcut GraphQL calls without additional HTTP round-trip, like this:Then at
ServerAppModule
bootstrap:Then without any change in Angular application we get local calls to GraphQL server.
However this does not work out of the box, because
SchemaLink
resolves toPromise
outside of angular zone, so that rendering ends before GrahpQLexecute
finished.In order to do it properly, one has to execute
execute
call as zone macro task, like explained here. Then you can't useSchemaLink
as provided by Apollo.Suggestion is to provide
AngularSchemaLink
byapollo-angular
for universal server which properly schedulesexecute
calls.For now, the following works:
Then you can use it in place of
SchemaLink
:Then your
ServerAppModule
will properly render without doing HTTP calls.The text was updated successfully, but these errors were encountered: