Agent skill

Graphql Operations

by apollographql in apollographql/skills

Guide for writing GraphQL operations (queries, mutations, fragments) following best practices.

MITAuto-check passedBackend & APIs

Install Graphql Operations

skills CLI
$ npx skills add apollographql/skills --skill graphql-operations -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install apollographql/skills graphql-operations --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/apollographql/skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/graphql-operations .claude/skills/graphql-operations && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
graphql-operations
GitHub stars
117
Token cost
~1.3k tokens
SKILL.md length
288 words
Files
6 (incl. references)
Skills in repo
12
Repo updated
First seen
Licence
MIT

At a glance

Guide for writing GraphQL operations (queries, mutations, fragments) following best practices.

  • Works in 4 steps: Request Only What You Need → Name All Operations → Use Variables, Not Inline Values → …
  • Writing GraphQL queries
  • SKILL.md covers Start From the Schema, Operation Basics, Quick Reference and Key Principles, plus 2 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Graphql Operations is an agent skill from apollographql/skills. Guide for writing GraphQL operations (queries, mutations, fragments) following best practices. Use this skill when: (1) writing GraphQL queries or mutations, (2) organizing operations with fragments, (3) optimizing data fetching patterns, (4) setting up type generation or linting, (5) reviewing operations for efficiency.

Its SKILL.md is about 1.3k tokens, which your agent loads only when the skill is triggered. The skill folder holds 6 other files, including reference files (for example `references/fragments.md`, `references/mutations.md` and `references/queries.md`). Compatibility notes: Any GraphQL client (Apollo Client, urql, Relay, etc.)

It sits in Backend & APIs, covering GraphQL. It works with GraphQL. The repository describes itself as: Apollo GraphQL Agent Skills. The licence is MIT.

When your agent uses it

  • Writing GraphQL queries
  • Organizing operations with fragments
  • Optimizing data fetching patterns
  • Setting up type generation

Example prompts

  • “/graphql-operations”

Requirements

  • Compatibility (from SKILL.md): Any GraphQL client (Apollo Client, urql, Relay, etc.)
  • Pre-approved tools (allowed-tools): Bash(npm:*), Bash(npx:*), Read, Write, Edit, Glob, Grep

Workflow steps

4 steps, taken from the step headings in SKILL.md.

  1. Request Only What You Need
  2. Name All Operations
  3. Use Variables, Not Inline Values
  4. Colocate Fragments with Components

What it can do on your machine

Read from SKILL.md and the folder at commit 5f02fcf. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Bash(npm:*)
    • Bash(npx:*)
    • Read
    • Write
    • Edit
    • Glob
    • Grep

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are graphql and typescript).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

  • Compatibility

    Any GraphQL client (Apollo Client, urql, Relay, etc.)

    From compatibility in the SKILL.md frontmatter.

Context cost

Graphql Operations loads about 1.3k tokens when it runs, and up to ~11k if it reads all its reference files. Until then it costs about 85 tokens; SKILL.md has 288 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~85
When it runs · the whole SKILL.md, loaded when a task matches
~1.3k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~11k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from apollographql/skills at commit 5f02fcf, republished under its MIT licence (© apollographql). 288 words, ~1,313 tokens.

Download SKILL.mdSave it as .claude/skills/graphql-operations/SKILL.md (or your agent's skills folder). This skill also uses 5 other files; get the full folder from GitHub.
name
graphql-operations
description
Guide for writing GraphQL operations (queries, mutations, fragments) following best practices. Use this skill when: (1) writing GraphQL queries or mutations, (2) organizing operations with fragments, (3) optimizing data fetching patterns, (4) setting up type generation or linting, (5) reviewing operations for efficiency.
allowed-tools
Bash(npm:*), Bash(npx:*), Read, Write, Edit, Glob, Grep
compatibility
Any GraphQL client (Apollo Client, urql, Relay, etc.)
license
MIT
metadata.author
apollographql
metadata.version
1.0.1

GraphQL Operations Guide

This guide covers best practices for writing GraphQL operations (queries, mutations, subscriptions) as a client developer. Well-written operations are efficient, type-safe, and maintainable.

Start From the Schema

Write every operation against the project's schema, not against the examples in this guide.

  1. Find the schema before you write anything. Check the schema entry in codegen.ts, graphql.config.*, or apollo.config.*, then look for *.graphql SDL files.
  2. Use only the fields, arguments, and enum values that the schema defines. Field names in this guide, such as updatedAt or orderBy: { field: CREATED_AT, direction: DESC }, are illustrations.
  3. Save the operation as a document next to the client's existing operations. Leave the server schema unchanged unless the user asks for a schema change.

Operation Basics

Query Structure
graphql
query GetUser($id: ID!) {
  user(id: $id) {
    id
    name
    email
  }
}
Mutation Structure
graphql
mutation CreatePost($input: CreatePostInput!) {
  createPost(input: $input) {
    id
    title
    createdAt
  }
}
Subscription Structure
graphql
subscription OnMessageReceived($channelId: ID!) {
  messageReceived(channelId: $channelId) {
    id
    content
    sender {
      id
      name
    }
  }
}

Quick Reference

Operation Naming
PatternExample
QueryGetUser, ListPosts, SearchProducts
MutationCreateUser, UpdatePost, DeleteComment
SubscriptionOnMessageReceived, OnUserStatusChanged
Variable Syntax
graphql
# Required variable
query GetUser($id: ID!) { ... }

# Optional variable with default
query ListPosts($first: Int = 20) { ... }

# Multiple variables
query SearchPosts($query: String!, $status: PostStatus, $first: Int = 10) { ... }
Fragment Syntax
graphql
# Define fragment
fragment UserBasicInfo on User {
  id
  name
  avatarUrl
}

# Use fragment
query GetUser($id: ID!) {
  user(id: $id) {
    ...UserBasicInfo
    email
  }
}
Directives
graphql
query GetUser($id: ID!, $includeEmail: Boolean!) {
  user(id: $id) {
    id
    name
    email @include(if: $includeEmail)
  }
}

query GetPosts($skipDrafts: Boolean!) {
  posts {
    id
    title
    draft @skip(if: $skipDrafts)
  }
}

Key Principles

1. Request Only What You Need
graphql
# Good: Specific fields
query GetUserName($id: ID!) {
  user(id: $id) {
    id
    name
  }
}

# Avoid: Over-fetching
query GetUser($id: ID!) {
  user(id: $id) {
    id
    name
    email
    bio
    posts {
      id
      title
      content
      comments {
        id
      }
    }
    followers {
      id
      name
    }
    # ... many unused fields
  }
}
2. Name All Operations
graphql
# Good: Named operation
query GetUserPosts($userId: ID!) {
  user(id: $userId) {
    posts {
      id
      title
    }
  }
}

# Avoid: Anonymous operation
query {
  user(id: "123") {
    posts {
      id
      title
    }
  }
}
3. Use Variables, Not Inline Values
graphql
# Good: Variables
query GetUser($id: ID!) {
  user(id: $id) {
    id
    name
  }
}

# Avoid: Hardcoded values
query {
  user(id: "123") {
    id
    name
  }
}
4. Colocate Fragments with Components
tsx
// UserAvatar.tsx
export const USER_AVATAR_FRAGMENT = gql`
  fragment UserAvatar on User {
    id
    name
    avatarUrl
  }
`;

function UserAvatar({ user }) {
  return <img src={user.avatarUrl} alt={user.name} />;
}

Reference Files

Detailed documentation for specific topics:

  • Queries - Query patterns and optimization
  • Mutations - Mutation patterns and error handling
  • Fragments - Fragment organization and reuse
  • Variables - Variable usage and types
  • Tooling - Code generation and linting

Ground Rules

  • ALWAYS read the project's schema first, and use only the fields, arguments, and enum values it defines
  • ALWAYS name your operations (no anonymous queries/mutations)
  • ALWAYS use variables for dynamic values
  • ALWAYS request only the fields you need
  • ALWAYS include id field for cacheable types
  • NEVER hardcode values in operations
  • NEVER duplicate field selections across files
  • PREFER fragments for reusable field selections
  • PREFER colocating fragments with components
  • USE descriptive operation names that reflect purpose
  • USE @include/@skip for conditional fields

© apollographql, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 5 other files (references) in skills/graphql-operations of apollographql/skills.

  • SKILL.md
  • references/fragments.md
  • references/mutations.md
  • references/queries.md
  • references/tooling.md
  • references/variables.md

Open the folder on GitHubat commit 5f02fcf

Compare with similar skills

Graphql Operations next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Graphql Operations compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Graphql Operations this skillapollographql/skills117—~1.3kAutomated safety check: PassMIT
Nodejs Backend Patternsever-works/ever-works16218 repos~4kAutomated safety check: PassAGPL-3.0
API DesignerJeffallan/claude-skills12k1 repos~2kAutomated safety check: PassMIT
GraphQL Operations with CodegenChrisWiles/claude-code-showcase6.1k3 repos~1.5kAutomated safety check: PassNone
API Design Principlesjh941213/my-cc-harness12618 repos~3.4kAutomated safety check: PassNone
API And Interface Designdzhalaevd/Donatello1358 repos~2.6kAutomated safety check: PassApache-2.0

Similar skills

  • Nodejs Backend Patterns

    ever-works/ever-works

    Build production-ready Node.js backend services with Express/Fastify, implementing middleware patterns, error handling, authentication, database integration, and API design best practices.

    162 GitHub starsUsed in 18 repos~4k tokens
    Backend & APIsAuto-check passed
  • API Designer

    Jeffallan/claude-skills

    Designs REST and GraphQL APIs from resource modeling to an OpenAPI 3.1 contract, with versioning, pagination and RFC 7807 error handling.

    12k GitHub starsUsed in 1 repo~2k tokens
    Backend & APIsAuto-check passed
  • GraphQL Operations with Codegen

    ChrisWiles/claude-code-showcase

    Sets the rules for writing GraphQL queries and mutations in .gql files, running codegen, and using generated Apollo hooks with proper error and loading handling.

    6.1k GitHub starsUsed in 3 repos~1.5k tokens
    Backend & APIsAuto-check passed
  • API Design Principles

    jh941213/my-cc-harness

    REST 및 GraphQL API 설계 원칙 가이드. An agent skill from jh941213/my-cc-harness.

    126 GitHub starsUsed in 18 repos~3.4k tokens
    Backend & APIsAuto-check passed
  • API And Interface Design

    dzhalaevd/Donatello

    Guides stable API and interface design. An agent skill from dzhalaevd/Donatello.

    135 GitHub starsUsed in 8 repos~2.6k tokens
    Backend & APIsAuto-check passed
  • Registers a new syncable entity in three NestJS modules and adds its service and GraphQL resolver layers when contributing to the Twenty server.

    58k GitHub stars~2.9k tokensUpdated today
    Backend & APIsAuto-check passed

More from apollographql/skills

All 12 skills in this repo
  • Graphos Factory

    apollographql/skills

    Build and iterate on an Apollo Connectors subgraph for a GraphOS supergraph from a REST API, with or without an OpenAPI or Swagger spec, in a dedicated git workspace that records what the API…

    117 GitHub stars~15k tokensUpdated yesterday
    Auto-check passed
  • Apollo Client

    apollographql/skills

    Guide for building React applications with Apollo Client 4.x.

    117 GitHub stars~1.9k tokensUpdated yesterday
    Auto-check passed
  • Apollo Connectors

    apollographql/skills

    DEPRECATED: superseded by the graphos-factory skill (npx skills add apollographql/skills@graphos-factory), which builds and maintains a Connectors subgraph from a REST API with recorded decisions…

    117 GitHub stars~1.8k tokensUpdated yesterday
    Auto-check passed
  • Apollo Federation

    apollographql/skills

    Guide for authoring Apollo Federation subgraph schemas. An agent skill from apollographql/skills.

    117 GitHub stars~1k tokensUpdated yesterday
    Auto-check passed
  • Apollo iOS

    apollographql/skills

    Guide for building Apple-platform applications with Apollo iOS, the strongly-typed GraphQL client for Swift.

    117 GitHub stars~2k tokensUpdated yesterday
    Auto-check passed
  • Apollo Router Plugin Creator

    apollographql/skills

    Guide for writing Apollo Router native Rust plugins. An agent skill from apollographql/skills.

    117 GitHub stars~4.1k tokensUpdated yesterday
    Auto-check passed

Works with

Categories

Questions about Graphql Operations

What does Graphql Operations do?

Guide for writing GraphQL operations (queries, mutations, fragments) following best practices. Graphql Operations is an agent skill from apollographql/skills. Guide for writing GraphQL operations (queries, mutations, fragments) following best practices.

When should I use Graphql Operations?

Graphql Operations fits situations like: writing GraphQL queries; organizing operations with fragments; optimizing data fetching patterns; setting up type generation.

How do I install Graphql Operations in Claude Code?

Run `npx skills add apollographql/skills --skill graphql-operations -a claude-code`. Or copy the skill folder (skills/graphql-operations in apollographql/skills) into .claude/skills/graphql-operations in your project. Claude Code loads it when a task matches its description.

How do I install Graphql Operations in Codex?

Run `npx skills add apollographql/skills --skill graphql-operations -a codex`. Or copy the skill folder (skills/graphql-operations in apollographql/skills) into .agents/skills/graphql-operations in your project. Codex loads it when a task matches its description.

Can I use Graphql Operations in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add apollographql/skills --skill graphql-operations -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/graphql-operations, .gemini/skills/graphql-operations, .github/skills/graphql-operations and .opencode/skills/graphql-operations in your project.

What does Graphql Operations need to run?

SKILL.md names no scripts, command-line tools or credentials: Graphql Operations is instructions for the agent only. Its frontmatter pre-approves these tools: Bash(npm:*), Bash(npx:*), Read, Write, Edit, Glob, Grep. Compatibility (from SKILL.md): Any GraphQL client (Apollo Client, urql, Relay, etc.).

Does Graphql Operations access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Graphql Operations safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Graphql Operations use?

Graphql Operations is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Graphql Operations use?

About 1.3k tokens (SKILL.md is roughly 5.3k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 9.6k tokens, read only when the agent opens those files.

What are the alternatives to Graphql Operations?

Skills that share tags, products or a category with Graphql Operations: Nodejs Backend Patterns (ever-works/ever-works, 162 stars), API Designer (Jeffallan/claude-skills, 12k stars), GraphQL Operations with Codegen (ChrisWiles/claude-code-showcase, 6.1k stars) and API Design Principles (jh941213/my-cc-harness, 126 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Graphql Operations?

apollographql (a GitHub organization) maintains it in apollographql/skills, which has 117 GitHub stars. The repository holds 12 skills in this directory. The repository was last updated on October 7, 2026.

Source: apollographql/skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.