error-handling

Standardize GraphQL error messages and distinguish auth errors from internal failures.

27|2|Updated Oct 10, 2023
One-click install
npx skills add https://github.com/aexol-studio/axolotl --skill error-handling-aexol-studio
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: error-handling
Source: https://github.com/aexol-studio/axolotl/tree/main/examples/new/.opencode/skills/error-handling
Command: npx skills add https://github.com/aexol-studio/axolotl --skill error-handling-aexol-studio

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

GraphQL error handling is essential for user experience and reliability. It standardizes user-facing messages, differentiates auth errors from internal failures, and supports automated responses across frontend and backend layers.

Core Features & Use Cases

  • Extract user-friendly error messages from GraphQL responses using a centralized utility.
  • Distinguish unauthorized/forbidden errors and trigger global logout flows.
  • Implement global error handling via a QueryClient, while enabling per-hook success toasts for positive feedback.

Quick Start

Wire the GraphQL client to use the provided error utilities and enable the global QueryClient handlers for auth and error cases.

Frequently Asked Questions about error-handling

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

FAQPage Schema
How do I handle GraphQL errors globally instead of using per-hook onError?

To handle GraphQL errors globally, configure a global QueryClient to intercept errors and trigger automated responses, avoiding repetitive per-hook onError setups while allowing individual success toasts.

What is the best way to standardize user-facing GraphQL error messages?

Standardizing user-facing GraphQL errors involves using a centralized utility function to extract consistent messages from responses, distinguishing auth failures from internal errors.

How do I distinguish authentication errors from internal GraphQL failures?

Distinguishing auth errors from internal failures involves emitting GraphQLError objects with extensions.code on the backend and using a frontend utility to identify unauthorized cases for global logout flows.

How do I display GraphQL errors as toast notifications?

Displaying GraphQL errors as toasts requires wiring the GraphQL client to use error extraction utilities and triggering toast notifications from the global error strategy.

Does global GraphQL error handling support per-hook success toasts?

Yes, a global error strategy via QueryClient supports per-hook success toasts, allowing positive feedback for mutations while maintaining centralized error management.

How do I trigger a global logout flow when an auth error occurs in GraphQL?

Triggering a global logout flow for GraphQL auth errors uses a frontend utility function to identify unauthorized failures, which then executes the global logout strategy.