query-layer

Implement TanStack Query patterns with error transformation and runtime dependency injection.

35|4|Updated Dec 18, 2024
One-click install
npx skills add https://github.com/wellcrafted-dev/wellcrafted --skill query-layer-wellcrafted-dev
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: query-layer
Source: https://github.com/wellcrafted-dev/wellcrafted/tree/main/.claude/skills/query-layer
Command: npx skills add https://github.com/wellcrafted-dev/wellcrafted --skill query-layer-wellcrafted-dev

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill streamlines the process of consuming services by providing robust patterns for data fetching, error transformation, and reactive state management, making application development more efficient and maintainable.

Core Features & Use Cases

  • Reactive Data Fetching: Integrates seamlessly with TanStack Query for efficient caching and real-time updates.
  • Error Transformation: Converts raw service errors into user-friendly formats for display.
  • Runtime Dependency Injection: Allows dynamic selection of service implementations based on configuration.
  • Use Case: When building a dashboard that displays user data fetched from an API, this Skill ensures that errors are presented clearly to the user and that data is updated reactively as it changes.

Quick Start

Use the query-layer skill to define a new query for fetching user data from the API.

Frequently Asked Questions about query-layer

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I handle errors when fetching data with TanStack Query?

To handle errors with TanStack Query, you can apply query layer patterns that intercept raw service errors and transform them into user-friendly formats suitable for UI display. This ensures your application presents clear error states instead of raw exceptions.

What is runtime dependency injection for reactive data fetching?

Runtime dependency injection for reactive data fetching allows dynamic selection of service implementations based on configuration. This pattern decouples data consumption from concrete implementations, letting you swap services dynamically while maintaining reactive updates.

How do I implement optimistic updates and caching using TanStack Query?

You implement optimistic updates and caching using TanStack Query by defining a query layer that manages service consumption reactively. This layer handles cache synchronization and applies optimistic mutations to keep the UI responsive during data operations.

Can I expose both reactive and imperative interfaces for the same service?

Yes, you can expose dual interface patterns for the same service by building a query layer that supports both reactive data management and imperative calls. This allows flexible consumption depending on whether you need real-time UI updates or one-time fetches.

What's the best way to structure a service consumption layer for React dashboards?

The best way to structure a service consumption layer for React dashboards is to use a query layer pattern with TanStack Query. This provides reactive data fetching, transforms errors for clear UI display, and ensures data updates automatically as it changes.