I check this.props.data.loading, and if it's done (and no error) then I'd like to directly use this.props.data. However, TS tells me that it may be null b/c of the way Apollo types are implemented.
What's the best way to avoid needing to write something like this every time?
(this.props.data as any).myData.foobar
For example, I can throw if it's null (which it should never be). But this is an annoying solution because if I have many places that render differently based on whether data is loaded, then this code would be all over the place.
if (!this.props.data) { throw new Error("Data is null!"); }
Fairly new to Apollo and I think this is a fairly basic question.