Patch Changes
-
#13229
9a7f65aThanks @jerelmiller! - FixrefetchOnmerging whendefaultOptions.watchQuery.refetchOnis set to a non-object value (false,true, or a function) and the per-queryrefetchOnis an object. Previously the per-query object completely replaced the default so unspecified events fell back to "enabled" regardless of the default.The
defaultOptionsvalue now applies to any event the per-query object does not explicitly configure:false- unspecified events stay disabledtrue- unspecified events refetch- Callback function - the function is called for unspecified events to determine whether to refetch
const client = new ApolloClient({ // ... defaultOptions: { watchQuery: { refetchOn: false, }, }, }); // Only `windowFocus` refetches. Other events stay disabled per the default. useQuery(QUERY, { refetchOn: { windowFocus: true } });
-
#13230
b25b659Thanks @jerelmiller! - Add the ability to override the default event handler onRefetchEventManager. The default handler runs when no per-source handler is configured for an event. Provide a custom handler via thedefaultHandlerconstructor option or thesetDefaultEventHandlerinstance method.new RefetchEventManager({ defaultHandler: ({ client, matchesRefetchOn }) => { return client.refetchQueries({ include: "all", onQueryUpdated: matchesRefetchOn, }); }, });