Query Key Factory screenshot

Query Key Factory

Author Avatar Theme by Lukemorales
Updated: 2 Sep 2024
1633 Stars

A library for creating typesafe standardized query keys, useful for cache management in @tanstack/query

Categories

Overview

InstallQuery Key Factory is designed to simplify the management of query keys in applications. By providing a standardized approach to defining and using query keys, it allows developers to maintain consistency and efficiency throughout their codebase. The tool not only aids in creating keys but also supports TypeScript integration for enhanced type safety and usability.

Features

  • Standardized Keys: All generated keys conform to the @tanstack/query convention, ensuring a uniform structure across your application, including support for optional queryKey when dynamic queries aren’t needed.

  • Query Options Generation: Easily declare both your queryKey and queryFn in one go, streamlining the process for running queries with all necessary access and options at your fingertips.

  • Contextual Queries: Create queries dependent on parent contexts effortlessly, making it easy to manage related data, such as retrieving all likes from a specific user.

  • Serializable Key Scope: Access and invalidate cache for specific contexts with a simple and effective mechanism, improving your cache management process.

  • Centralized Query Key Declaration: Maintain all your query keys in a single file, simplifying edits and maintenance for your store, ensuring consistency across your application.

  • Fine-grained Key Control: Customize your features’ keys with precision and merge them into a unified object, granting you comprehensive access to all query keys throughout your code.

  • Type Safety and Autocomplete: With TypeScript as a key player, enjoy effortless integration, smart autocompletion, and precise type inference for your queries, making development smoother and more intuitive.