Closed jansenignacio closed 7 years ago
It would be good to have add a test that fails prior to adding this fix.
@NeoPhi can you suggest a way to write a test for this? The steps to reproduce are outlined in this comment: https://github.com/apollographql/subscriptions-transport-ws/issues/189#issuecomment-310724774
@NeoPhi I updated the commit, added the tests first.
@maktouch and I have already signed the CLA but the CI still shows that it's failing :(
Confirmed - the CLA has been signed, status failed to update on this PR though.
This pr fix infinite loop bug. But expose another issus in withFilter
.
Sometime payload value is undefined in filterFn(payload.value, args, context, info)
. User need check rootValue
in every filter.
Subscription: {
serverUpdated: {
resolve: (rootValue, args, ctx, info) => rootValue,
subscribe: withFilter(
() => pubsub.asyncIterator(['serverUpdated']),
// Check rootValue before use it.
(rootValue, args, ctx, info) => !!rootValue && rootValue.id === ctx.user.id
)
}
}
Fixes #81 and related to apollographql/subscriptions-transport-ws#189