Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

In Query component, data can be undefined #2141

Closed
maxsalven opened this issue Jun 27, 2018 · 1 comment
Closed

In Query component, data can be undefined #2141

maxsalven opened this issue Jun 27, 2018 · 1 comment

Comments

@maxsalven
Copy link

In the Query component, the render prop function returns an object with a data field. I believe the intention is for this to always default to an empty object, rather than be undefined:
https://www.apollographql.com/docs/react/essentials/queries.html#render-prop

This allows checks like if (data.user) instead of if (data && data.user).

However, in case of an Error, this object can be undefined:

data: (this.queryObservable!.getLastResult() || {}).data,

Would it be better to return an empty data object in this case?
data: (this.queryObservable!.getLastResult() || {}).data || {},

@maxsalven
Copy link
Author

There's already a PR for this, apologies:
#1983

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant