Open zeuscronos opened 7 months ago
I'm also interested in an onConnect callback. If there's already a callback for this, or if you know of a workaround, please share it here.
Adding the two lines below resolves the issues I mentioned on the description:
However, these approaches have drawbacks that make them unsuitable for my requirements.
None of these issues happened when using Apollo Server + Apollo Link.
Additionally, I observed that if, instead of adding process.exit(0)
at the end, a message is sent using mutation: sendMessage(...)
from Yoga GraphiQL playground in the browser, then the test process completes. However, this isn't a viable option, as the process should finish without external intervention.
Regarding the second issue (the test process doesn't finish properly) If I add the following to the end of the test:
import whyIsNodeRunning from 'why-is-node-running';
...
...
...
setTimeout(() => {
console.log(whyIsNodeRunning());
}, 1000);
I get the following:
$ node src/test.js
All tests passed!
Test completed
There are 6 handle(s) keeping the process running
# TCPWRAP
C:\www\yoga-issue\node_modules\@whatwg-node\node-fetch\cjs\fetchNodeHttp.js:33 - const nodeRequest = requestFn(fetchRequ
est.url, {
# DNSCHANNEL
(unknown stack trace)
# HTTPCLIENTREQUEST
(unknown stack trace)
# TTYWRAP
C:\www\yoga-issue\node_modules\@whatwg-node\node-fetch\cjs\fetchNodeHttp.js:74 - responseBody = nodeResponse.pipe(new stream_1.PassThrough());
# TTYWRAP
C:\www\yoga-issue\node_modules\@whatwg-node\node-fetch\cjs\fetchNodeHttp.js:74 - responseBody = nodeResponse.pipe(new stream_1.PassThrough());
# Timeout
(unknown stack trace)
undefined
Describe the bug
I have a very simple dummy server with: Node.js + GraphQL + Apollo Server & Link that I'm migrating to Yoga Server & Link.
The Yoga version uses the same logic / idea as the Apollo version, just changed the necessary things.
You have the project repo here: https://github.com/zeuscronos/yoga-issue
On commit: "apollo server + test" you have the Apollo version while on commit: "yoga server + test" you have the Yoga version.
The Apollo version works as expected, i.e.:
In the other hand, the Yoga version has issues:
Additionally - Proposal
I would recommend the
YogaLink
to have an option to set anonConnected
callback similarly to what it is on the line below. That may be needed in some scenarios where we need to wait for the WS connection to be stablished before doing other operations:https://github.com/zeuscronos/yoga-issue/commit/bcd0bd38398a475707f92ad864e60a14425d5d9#diff-c7000107e5c2a5b190270c14f474e8538f6af25f052c8290bc0c3cddc2714c6aR86
Your Example Website or App
Apollo Server + Test
https://stackblitz.com/edit/github-hhdwqx-rk8lne?file=src%2Findex.js,src%2Ftest.js
All good with Apollo Server + Apollo Link...
Yoga Server + Test
https://stackblitz.com/edit/github-hhdwqx-owkeze?file=src%2Findex.js,src%2Ftest.js
Hanging when using Yoga Server + Yoga Link...
Steps to Reproduce the Bug or Issue
Platform