react-apollo v2.2.0 Release Notes
Release Date: 2018-09-26 // over 5 years ago-
- ๐ Improved TypeScript Typings:
Deprecated
MutationFunc
in favor ofMutationFn
. Added missingonCompleted
andonError
callbacks toMutationOpts
. @danilobuerger in #2322 - โ Added an example app that shows how to test mutations. @excitement-engineer in #1998
- The
<Subscription />
component now allows the registration of a callback function, that will be triggered each time the component receives data. The callbackoptions
object param consists of the current Apollo Client instance inclient
, and the received subscription data insubscriptionData
. @jedwards1211 in #1966 - The
graphql
options
object is no longer mutated, when calculating variables from props. This now prevents an issue where components created withgraphql
were not having their query variables updated properly, when props changed. @ksmth in #1968 - When a query failed on the first result, the query result
data
was being returned asundefined
. This behavior has been changed so thatdata
is returned as an empty object. This makes checking for data (e.g. instead ofdata && data.user
you can just checkdata.user
) and destructring (e.g.{ data: { user } }
) easier. Note: this could potentially hurt applications that are relying on a falsey check ofdata
to see if any query errors have occurred. A better (and supported) way to check for errors is to use the resulterrors
property. @TLadd in #1983 - ๐ Allow a custom
cache
object to be passed into the test-utilsMockedProvider
. @palmfjord in #2254 - ๐คก Make the
MockedProvider
mocks
prop read only. @amacleay in #2284 - โ Remove duplicate
FetchMoreOptions
andFetchMoreQueryOptions
types, and instead import them from Apollo Client. @skovy in #2281 - Type changes for the
graphql
HOCoptions.skip
property. @jameslaneconkling in #2208 - Avoid importing
lodash
directly. @shahyar in #2045 - When the
Query
skip
prop is set totrue
, make sure the render proploading
param is set tofalse
, since we're not actually loading anything. @edorivai in #1916 - ๐ No longer building against Node 9 @hwillson in #2404
- ๐ Make sure
<Subscription />
,<Query />
&<Mutation />
all support using an Apollo Client instance configured in thecontext
or via props. @quentin- in #1956 - Typescript: use
Partial<TData>
instead ofTData | {}
, for theQueryResult
data
property. @tgriesser in #2313 - Adjust
<Query />
onCompleted
andonError
callbacks to be triggered via thecomponentDidUpdate
lifecycle method. This ensures these callbacks can be used when data is fetched over the network, and when data is fetched from the local store (previsouly these callbacks were only being triggered when data was fetched over the network). @olistic in #2190 - Import
lodash/flowRight
using ES import to allow for treeshaking. @Pajn in #2332 - ๐ Fixed a regression where
variables
passed ingraphql
HOCoptions
were not merged with mutationvariables
. @samginn in #2216 - โ Added a new
partialRefetch
prop (false
by default). When aQuery
component is mounted, and a mutation is executed that returns the same ID as the mountedQuery
, but has less fields in its result, Apollo Client'sQueryManager
returns the data as an empty Object since a hit can't be found in the cache. This can lead to application errors when the UI elements rendered by the originalQuery
component are expecting certain data values to exist, and they're all of a sudden stripped away. The recommended way to handle this is to use the mutationsupdate
prop to reconcile the mutation result with the data in the cache, getting everything into the expected state. This can definitely be a cumbersome process however, so to help address this thepartialRefetch
prop can be used to automaticallyrefetch
the original query and update the cache. @steelbrain in #2003
- ๐ Improved TypeScript Typings:
Deprecated