graphql-operations

Guide writing GraphQL queries, mutations, and fragments with best practices.

102|12|Updated Jan 23, 2026
One-click install
npx skills add https://github.com/apollographql/skills --skill graphql-operations-apollographql
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: graphql-operations
Source: https://github.com/apollographql/skills/tree/main/skills/graphql-operations
Command: npx skills add https://github.com/apollographql/skills --skill graphql-operations-apollographql

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers write efficient, type-safe, and maintainable GraphQL operations, improving data fetching performance and code quality.

Core Features & Use Cases

  • Operation Best Practices: Learn how to structure queries, mutations, and subscriptions effectively.
  • Fragment Management: Understand how to organize and reuse fragments for cleaner code.
  • Performance Optimization: Avoid over-fetching and optimize data retrieval patterns.
  • Use Case: When building a new feature that requires fetching user data and their recent posts, use this Skill to ensure your GraphQL query is optimized and follows best practices.

Quick Start

Use the graphql-operations skill to write a GraphQL query to fetch a user's name and email by their ID.

Frequently Asked Questions about graphql-operations

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

FAQPage Schema
How do I write a GraphQL query to fetch only the fields I need?

To write a GraphQL query that fetches only necessary fields, explicitly declare the required fields in the selection set. This prevents over-fetching data, optimizing retrieval patterns and improving overall client performance.

What is the best way to structure GraphQL fragments for code reuse?

The best way to structure GraphQL fragments is by extracting reusable field selections into independent, named fragment blocks. This approach organizes code efficiently, allowing you to maintain consistent data fetching logic across multiple queries.

How do I use variables in GraphQL mutations to ensure type safety?

To ensure type safety in GraphQL mutations, pass dynamic data using strongly typed variables declared in the operation signature. Variables validate input types on the server, preventing runtime errors and making mutation operations more maintainable.

Why should I name my GraphQL operations instead of using anonymous queries?

You should name GraphQL operations to improve type safety, server-side logging, and client-side caching. Named operations allow GraphQL clients to track and manage data fetching efficiency effectively during app development.

Does this GraphQL operations guidance work for different client libraries?

Yes, the guidance addresses data fetching efficiency and code maintainability for various GraphQL clients. Best practices like utilizing variables, fragments, and naming operations apply universally across different client implementations.