Closed diegonc closed 7 years ago
Hi @diegonc, thanks for reporting this. It would be great if you could write a failing test for it so I can fix it. Let me know if you have time for this or need any help getting the tests up and running. Cheers.
I'm not sure how to implement the test, as the behaviour depends on the Apollo Client implementation. When apollo dispatches the APOLLO_QUERY_INIT action, the store listeners are triggered and eventually blaze-apollo's next function is called. A portion of the stacktrace is below.
next @ result.js:50
...
QueryManager.broadcastQueries @ modules.js?hash=a07a784…:116521
...
QueryManager.fetchQuery @ modules.js?hash=a07a784…:115998
QueryManager.startQuery @ modules.js?hash=a07a784…:116303
ObservableQuery.setUpQuery @ modules.js?hash=a07a784…:115538
ObservableQuery.onSubscribe @ modules.js?hash=a07a784…:115490
subscriberFunction @ modules.js?hash=a07a784…:115264
Observable.subscribe @ modules.js?hash=a07a784…:115153
subscribe @ result.js:48
Result @ result.js:24
gqlQuery @ setup.js:31
...
next gets called with the following object:
{
"data": undefined,
"loading":true,
"networkStatus":1,
"stale":true
}
Ok, I think I can fake a call to next in the unit test. But it feels a bit dirty :stuck_out_tongue_closed_eyes:
What version of the Apollo client is this?
It's apollo-client version 1.8.0. I just created PR #10, adding the corresponding test.
Thanks for the help on this one. It should be fixed in 0.5.0.
Note that it will now return the original immutable data directly from the Apollo Client store. This could impact your code if you were modifying the returned data. Those modifications will either error or simply not show up.
I've just tripped into the exception below, triggered when the query result is still undefined.
It's happening because I'm doing a
this.gplQuery
and aget()
in the sameonCreated
callback. Strange though, I tried to overcome the problem usingisReady()
but that method returned true even when the result was still undefined.