github apollographql/apollo-client @apollo/client@4.0.0-alpha.20

latest releases: @apollo/client@4.0.4, @apollo/client@4.0.3, @apollo/client@4.0.2...
pre-release3 months ago

Major Changes

  • #12675 8f1d974 Thanks @phryneas! - ObservableQuery no longer has a queryId property.
    ApolloClient.getObservableQueries no longer returns a Map<string, ObservableQuery>, but a Set<ObservableQuery>.

  • #12647 a70fac6 Thanks @phryneas! - ObservableQuerys will now only be registered with the ApolloClient while they
    have subscribers.

    That means that ApolloClient.getObservableQueries and ApolloClient.refetchQueries
    will only be able to return/refetch queries that have at least one subscriber.

    This changes the previous meaning of active and inactive queries:

    • inactive queries are queries with a subscriber that are skipped from a
      React hook or have a fetchPolicy of standby
    • active queries are queries with at least one subscriber that are not skipped or in standby.

    ObservableQuerys without subscribers but with an active ongoing network request
    (e.g. caused by calling reobserve) will be handled as if they had a subscriber
    for the duration of the query.

  • #12678 91a876b Thanks @jerelmiller! - queryRefs created by preloadQuery no longer have a .toPromise() function. Instead preloadQuery now has a toPromise function that accepts a queryRef and will resolve when the underlying promise has been resolved.

    const queryRef = preloadQuery(query, options);
    
    - await queryRef.toPromise();
    + await preloadQuery.toPromise(queryRef);
  • #12647 a70fac6 Thanks @phryneas! - ApolloClient.stop() now cleans up more agressively to prevent memory leaks:

    • It will now unsubscribe all active ObservableQuery instances by emitting a completed event.
    • It will now reject all currently running queries with "QueryManager stopped while query was in flight".
    • It will remove all queryRefs from the suspense cache.

Minor Changes

  • #12647 a70fac6 Thanks @phryneas! - Added a new .stop function on ObservableQuery.
    Calling this method will unsubscribe all current subscribers by sending a complete event from the observable and tear down the ObservableQuery.

Don't miss a new apollo-client release

NewReleases is sending notifications on new releases.