github apollographql/apollo-client @apollo/client@4.0.0-rc.2

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

Major Changes

  • #12742 575bf3e Thanks @jerelmiller! - The new SetContextLink flips the prevContext and operation arguments in the callback. The setContext function has remained unchanged.

    - new SetContextLink((operation, prevContext) => {
    + new SetContextLink((prevContext, operation) => {
      // ...
    })
  • #12742 575bf3e Thanks @jerelmiller! - The operation argument to the callback passed to SetContextLink is now of type SetContextLink.SetContextOperation which is an Operation without the getContext or setContext functions. Previously the type of operation was GraphQLRequest which had access to a context property. The context property was always undefined and could result in bugs when using it instead of the prevContext argument.

    This change means the operation argument now contains an accessible client property.

Minor Changes

  • #12740 1c6e03c Thanks @phryneas! - Overridable types for dataState: "complete", dataState: "streaming" and
    dataState: "partial" responses.

    This adds the DataValue namespace exported from Apollo Client with the three
    types DataValue.Complete, DataValue.Streaming and DataValue.Partial.

    These types will be used to mark TData in the respective states.

    • Complete defaults to TData
    • Streaming defaults to TData
    • Partial defaults to DeepPartial<TData>

    All three can be overwritten, e.g. to be DeepReadonly using higher kinded types
    by following this pattern:

    import { HKT, DeepPartial } from "@apollo/client/utilities";
    import { DeepReadonly } from "some-type-helper-library";
    
    interface CompleteOverride extends HKT {
      return: DeepReadonly<this["arg1"]>;
    }
    
    interface StreamingOverride extends HKT {
      return: DeepReadonly<this["arg1"]>;
    }
    
    interface PartialOverride extends HKT {
      return: DeepReadonly<DeepPartial<this["arg1"]>>;
    }
    
    declare module "@apollo/client" {
      export interface TypeOverrides {
        Complete: CompleteOverride;
        Streaming: StreamingOverride;
        Partial: PartialOverride;
      }
    }

Patch Changes

Don't miss a new apollo-client release

NewReleases is sending notifications on new releases.