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

Improve types in Query component. Make data be undefined in initial load #1581

Merged

Conversation

leoasis
Copy link
Contributor

@leoasis leoasis commented Jan 25, 2018

This PR improves the types of Query for Typescript a bit. It adds variables as a parameter type, defaulting to an object of whatever. Also makes the data reflect the fact that it may not have information yet (in the initial load for example). Since it's better to check for null than for an empty object, I figured I'd change the API a bit and make data be either TData or undefined. Typescript works better in this case since it will refine the type after checking for its truthiness. Also I think it makes more sense than returning an empty object, since the null exception is going to be delayed until you try to access any nested property.

Anyway this is subject to improvement and discussion.

@jbaxleyiii jbaxleyiii merged commit 12821cf into apollographql:master Jan 25, 2018
@leoasis leoasis deleted the query_component_ts_improvements branch January 25, 2018 19:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants