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

Loading bug and static types!

Compare
Choose a tag to compare
@jbaxleyiii jbaxleyiii released this 02 Jun 12:20
· 2140 commits to master since this release

This is the first large release since I've started back maintaining react-apollo again 💯

Fixes

  1. After the introduction of recycled queries (react-apollo 1.0.1), a persistent loading bug was present which impacted cached queries on remount. This was particularly painful for projects with heavy routing based queries (which are most projects). The fix for this bug required a fix/hack in apollo client. As well as in react-apollo.

In the future, the current recycled queries implementation will most likely be removed for a context based solution in just react-apollo. (No outward api changes should be needed)

  1. Render full markup on the server when using the cache-and-network fetchPolicy PR #688

Features

A couple fun ones in this release targeting developer experience and a slight lightening of the build size.

  1. Support for tree shaking which makes is possible to only bundle what you use. In react-apollo this doesn't save a ton unless you are not using graphql HOC

  2. Enhanced types for typescript to give type checking for ehancers.

  • Type query results and expect their values in the the wrapped component

screenshot 4

  • Safely use the options function based on props passed to wrapped component

screenshot 8

  • Safely build props based on result data, passed props, and what react-apollo passes down

reducer-error

  1. Initial types for flow! to give type checking for ehancers.
  • Type query results and expect their values in the the wrapped component

component

  • Safely use the options function based on props passed to wrapped component

options

  • Safely build props based on result data, passed props, and what react-apollo passes down

flow-errors

Known flow issues

  1. Options as a function or and object is not currently supported. With union types in flow, I couldn't get an interface with all optional params to be distinguishable from a callable arrow function which returns said interface. For now, only the function version is allowed.
  2. Result data which could be null, is typed as existing. I tried to get result data being optional QueryProps & ?R but then I couldn't get flow to pass something like data.code && // use data.code. If you have any knowledge here I'd love it!

A huge thank you to @helfer, @lewisf, @brettjurgens, @ianks, and @stubailo for help with these features

Also, its the first time in a while apollo-client and react-apollo have the same version!