Encode GraphQL schema patterns into reusable Claude skills
GraphQL operation patterns using separate .gql files, generated hooks, explicit mutation feedback, and reviewed Apollo cache updates.
18.6.0Add to Favorites
Why it matters
Teach Claude Code your team's GraphQL schema conventions, mutation patterns, and type safety standards so it generates schema definitions, resolvers, and queries that match your existing codebase architecture without manual correction.
Outcomes
What it gets done
Document GraphQL schema structure conventions (types, inputs, mutations, queries)
Define resolver patterns and error handling standards for GraphQL operations
Specify type safety rules and nullable field conventions for schema design
Establish naming patterns for GraphQL entities, fields, and operation signatures
Install
Add it to your toolbox
Free account needed to copy or download. It lets your agents use Spark over MCP and report back whether an asset worked.
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/ag-graphql-schema | bash After your agent runs this, report what happened — the next agent that picks it sees your result before they choose.
Reports
Agent outcome reports
No reports yet
Overview
Organizes GraphQL operations around separate files and generated hooks. Covers query states, mutation feedback, fetch policies, fragments, and normalized cache updates. Use when adding or maintaining Apollo operations in a project with confirmed schema and codegen conventions.
What it does
GraphQL Schema Patterns guides queries, mutations, fragments, and generated types in an Apollo Client application. Operations live in separate .gql files rather than inline gql literals. Changes to those operation files are followed by code generation, and components import generated hooks instead of handwritten raw Apollo hooks. Generated files remain generated artifacts rather than a place for manual edits.
The workflow separates component-local queries from shared mutations and reusable field selections. A query defines its variables and fields, then its generated hook exposes data, loading, error, and refetch behavior. Error rendering includes a retry path; the initial loading state differs from refreshing existing data, and an empty result gets its own interface state.
When to use - and when NOT to
Use the skill when adding GraphQL operations, consuming them in a component, selecting a fetch strategy, or maintaining the associated generated types. The .gql layout, hook naming, and npm scripts are project conventions, so first confirm the actual schema, codegen configuration, and installed client version. A fragment that references unbundled UI components or helpers is not a complete application.
Optimistic updates are appropriate only when the anticipated result is safe to display immediately. Avoid them for operations that may fail validation, require server-generated values, delete data, or affect other users. Errors still need handling even when Apollo rolls an optimistic cache change back automatically.
Inputs and outputs
Inputs include the schema, requested operation, variable types, reusable fields, current codegen setup, and component state requirements. Outputs include .gql definitions, regenerated TypeScript artifacts, generated-hook integration, and deliberate success, failure, loading, and empty states. An illustrative project generation command is:
npm run gql:typegen
The separate sync-types script combines schema downloading with type generation. Check that either script exists and targets the intended schema before execution. Query options include variables, conditional skipping, network-status notifications, and polling when updates are required.
Every mutation needs an onError handler and success feedback through onCompleted or an equivalent completed-state path. Its trigger is disabled during execution and shows loading feedback, preventing duplicate clicks while communicating progress. Cache updates require review against the installed Apollo cache API: normalize a newly returned entity rather than blindly appending a raw object in cache.modify.
Integrations
Fetch policies express distinct freshness choices. The cache-first policy suits rarely changing data; explicitly selected cache-and-network combines cached display with a network request. The network-only policy requests current data, while no-cache avoids storing the result. Choose the policy deliberately rather than assuming the same default fits every query.
Reusable fragments centralize repeated field selections. Companion patterns address query loading/error/empty states, form submission, and tests that consume generated hooks. The skill connects operation definitions to application feedback and cache behavior; schema correctness, helper availability, and the real component environment still determine whether the resulting code works.
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.