Closed JonathanGafar closed 7 months ago
I quickly put together a test using the set up you described above, and it seems to be working as expected for me.
From the details above, I wonder if there's a race condition in your full code, where you're calling mockSubscription.next
before the subscribeToMore
function has been called? As that would explain the warning you're seeing - Mock subscription has no observer, this will have no effect
as apollo client hasn't subscribed yet.
If you think that's not the case, and there is an issue in the mock-apollo-client library, would be great if you could provide a full working sample to help diagnose the issue.
You were absolutely correct that it was a race condition in my code. I appreciate your time. I'll close this issue. Thanks.
Glad to hear you got it working.
I've got a component that makes a lazy query, takes the
subscribeToMore
function returned and calls it in auseEffect
. The GQL documents passed to the lazy query andsubscribeToMore
function are different. I keep getting this warning: "Warning: mock-apollo-client - Mock subscription has no observer, this will have no effect".Here is a quick example of what I mean:
My test looks something like this:
EDIT: I was able to test this by treating it as a query rather than following the strategy provided in the docs for subscriptions.