Intended outcome:
Attempting to use useLazyQuery and subscribeToMore with a potentially undefined variable should not lead to crashes. The intention here is only execute the GraphQL query when the identifier becomes defined.
Actual outcome:Cannot read property 'subscribeToMore' of undefined at QueryData._this.obsSubscribeToMore (QueryData.ts:476).
Potential fix:
If you check the code in QueryData.ts, you will see that Apollo Client uses non-null assertion for something that can actually be null. Perhaps simply using optional chaining instead could fix the issue.
@mstykow Thanks a lot man!! This is definitely a bug, however thanks to your workaround I was able to solve my problem for now. Hope they fix this as soon as possible.
NOTE: RE-OPENING A REACT-APOLLO ISSUE WHICH STILL OCCURS ON APOLLO-CLIENT. See: https://github.com/apollographql/react-apollo/issues/3860
Intended outcome: Attempting to use
useLazyQuery
andsubscribeToMore
with a potentially undefined variable should not lead to crashes. The intention here is only execute the GraphQL query when the identifier becomes defined.Actual outcome:
Cannot read property 'subscribeToMore' of undefined at QueryData._this.obsSubscribeToMore (QueryData.ts:476)
.Potential fix: If you check the code in
QueryData.ts
, you will see that Apollo Client uses non-null assertion for something that can actually be null. Perhaps simply using optional chaining instead could fix the issue.How to reproduce the issue:
Versions
Known Workaround