Capítulo 74 de 80

Chapter 74: queryOptions

Core Idea

A type-preserving identity function — queryOptions({ queryKey, ...options }) accepts everything useQuery does and returns it essentially unchanged at runtime, existing purely so the same options object can be shared across useQuery, useSuspenseQuery, useQueries, and queryClient.query()/setQueryData() with inference intact.

Key Concepts

  • Required field: queryKey.
  • Everything else: any valid useQuery option is accepted and passed through.

Connects To

  • Query Options: the full conceptual guide (why/how to use this).
  • TypeScript: the inference mechanics this helper exists to preserve.