Type: Exclude "partial" from data state union when fetchPolicy resolves to "no-cache"

Author: coderabbitai[bot]Created May 5, 2026Updated May 5, 2026

Summary

When using hooks/APIs that return a typed data state union (e.g. useQuery, useSuspenseQuery, useBackgroundQuery, useLoadableQuery, preloadQuery from createQueryPreloader), the "partial" state is currently only excluded when returnPartialData resolves to false. However, "partial" should also be excluded when fetchPolicy resolves to "no-cache", since partial data requires cache reads and is unreachable in a no-cache scenario.

Affected Types

  • ResultForOptions.States in src/react/query-preloader/createQueryPreloader.ts
  • Equivalent conditional type logic used by useQuery, useSuspenseQuery, useBackgroundQuery, useLoadableQuery

Example

typescript
// Currently incorrectly includes "partial" in the return type
const queryRef = preloadQuery(query, { fetchPolicy: "no-cache", returnPartialData: true });
// queryRef is PreloadedQueryRef<TData, TVariables, "complete" | "streaming" | "partial" | "empty">
// but "partial" is unreachable at runtime with fetchPolicy: "no-cache"

Expected Behavior

When fetchPolicy resolves to "no-cache", the "partial" member should be never regardless of returnPartialData, since partial data is only meaningful with cache reads.

The fix should be applied consistently across all affected hooks/APIs.

References

Source: apollographql/apollo-client