Token导航 LogoToken导航TokenDH.com
研究检索敏感数据github未标认证来源可访问clear审计通过

writing-graphql-operationswriting GraphQL operations 搜索

Agent Skill

用于辅助 API 设计、接口文档、请求响应结构和服务集成说明。它适合让 Agent 梳理 endpoint、生成 OpenAPI 草稿、检查字段命名、整理错误码或辅助前后端联调。使用时需要确认真实业务语义、鉴权方式、分页和错误处理规则;涉及生成接口文档时,应避免凭空补字段,最好从现有代码、schema 或接口样例中提取事实。

总安装

449

周安装

18

GitHub Stars

28

下载量

145
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:writing-graphql-operations(writing GraphQL operations 搜索)
来源仓库:https://github.com/saleor/configurator
仓库路径:skills/writing-graphql-operations
安装命令:
npx skills add https://github.com/saleor/configurator --skill writing-graphql-operations
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/saleor/configurator --skill writing-graphql-operations

简介

用于辅助 GraphQL API 设计和接口文档编写。

  • 适合梳理 endpoint、生成请求响应示例。
  • 可检查字段命名一致性和错误处理规范。writing-graphql-operations 属于研究检索类 Skill,可作为该场景下的辅助能力补充。
  • 需确认真实业务语义和鉴权机制后再输出。
  • 建议从现有 schema 或代码中提取事实依据。

SKILL.md

GraphQL Operations Developer

Overview

Guide the creation and maintenance of GraphQL operations following project conventions for type safety, organization, error handling, and testing with gql.tada and urql.

When to Use

  • Creating new GraphQL queries or mutations
  • Integrating with Saleor API endpoints
  • Updating schema after Saleor changes
  • Working with urql client configuration
  • Creating MSW mocks for testing

Quick Reference

ToolPurpose
gql.tadaType-safe GraphQL with TypeScript inference
urqlGraphQL client with caching
@urql/exchange-authAuthentication (Bearer token)
@urql/exchange-retryRate limit retry (429, max 5 attempts)

File Organization

src/lib/graphql/
├── client.ts              # urql client configuration
├── operations/            # GraphQL operation definitions
├── fragments/             # Reusable GraphQL fragments
├── __mocks__/             # MSW test mocks
└── schema.graphql         # Saleor schema (generated)

src/modules/<entity>/
├── repository.ts          # Uses GraphQL operations
└── ...

Creating Operations

Use gql.tada for all operations. Types are inferred from schema automatically:

import { graphql } from 'gql.tada';

export const GetCategoriesQuery = graphql(`
  query GetCategories($first: Int!) {
    categories(first: $first) {
      edges {
        node { id, name, slug, description }
      }
    }
  }
`);

// Type inferred automatically
type GetCategoriesResult = ResultOf<typeof GetCategoriesQuery>;

For shared fields, extract fragments and pass as second argument to graphql().

Repository Pattern

Each entity has a repository class that encapsulates GraphQL operations and maps responses to domain models:

export class CategoryRepository {
  constructor(private readonly client: Client) {}

  async findAll(): Promise<Category[]> {
    const result = await this.client.query(GetCategoriesQuery, { first: 100 });
    if (result.error) {
      throw GraphQLError.fromCombinedError(result.error, 'GetCategories');
    }
    return this.mapCategories(result.data?.categories);
  }

  async create(input: CategoryInput): Promise<Category> {
    const result = await this.client.mutation(CreateCategoryMutation, { input });
    if (result.error) {
      throw GraphQLError.fromCombinedError(result.error, 'CreateCategory');
    }
    if (result.data?.categoryCreate?.errors?.length) {
      throw new GraphQLError('Category creation failed', result.data.categoryCreate.errors);
    }
    return this.mapCategory(result.data?.categoryCreate?.category);
  }
}

Key pattern: Always map GraphQL responses to domain models in the repository. Never expose GraphQL types to services.

Error Handling

Two error types to always check:

  1. Network/GraphQL errors (result.error): Wrap with GraphQLError.fromCombinedError(error, 'OperationName', {context})
  2. Mutation validation errors (result.data?.mutation?.errors): Check array length, throw with field details

See references/error-handling.md for complete error patterns, classification, and MSW error mocking.

Schema Management

pnpm fetch-schema  # Updates schema.graphql and graphql-env.d.ts

Update schema when: new Saleor features needed, after Saleor version upgrade, or when encountering schema drift errors. Always commit schema changes with the feature implementation.

Testing

Mock GraphQL operations with MSW using graphql.query() and graphql.mutation() handlers. See analyzing-test-coverage skill for full MSW setup patterns.

Client Configuration

The urql client is configured in src/lib/graphql/client.ts with: cacheExchange, authExchange (Bearer token), retryExchange (1s-15s backoff, 5 attempts, retries on 429 and network errors), and fetchExchange.

Best Practices

Do:

  • Use gql.tada for all operations (automatic type inference)
  • Keep operations close to their domain modules
  • Map GraphQL responses to domain models in repository
  • Include operation name in error context
  • Update mocks when schema changes
  • Extract shared fields to fragments

Don't:

  • Use raw string queries (no type safety)
  • Expose GraphQL types directly to services
  • Skip error handling for any operation
  • Hardcode pagination limits (use constants)

Validation Checkpoints

PhaseValidateCommand
Schema freshNo driftpnpm fetch-schema
Operations typedgql.tada inferenceCheck IDE types
Mocks matchMSW handlerspnpm test
Error handlingAll paths coveredCode review

Common Mistakes

MistakeFix
Not checking errors arrayAlways check result.data?.mutation?.errors
Exposing GraphQL typesMap to domain types in repository
Missing error contextInclude operation name in errors
Stale schemaRun pnpm fetch-schema after Saleor updates
Not using fragmentsExtract shared fields to fragments

External Documentation

For up-to-date library docs, use Context7 MCP:

  • urql: resolve-library-id with /urql-graphql/urql
  • gql.tada: resolve-library-id with "gql.tada"

References

Skill Reference Files

Project Resources

  • src/lib/graphql/client.ts - Client configuration
  • src/lib/graphql/operations/ - Existing operations
  • docs/CODE_QUALITY.md#graphql--external-integrations - Quality standards

Related Skills

  • Complete entity workflow: See adding-entity-types for full implementation including bulk mutations
  • Bulk operations: See adding-entity-types/references/bulk-mutations.md for chunking patterns
  • Testing GraphQL: See analyzing-test-coverage for MSW setup

Troubleshooting

Common Error Scenarios

ErrorCauseFix
CombinedError: [Network]API unreachable or URL malformedVerify --url ends with /graphql/ and instance is running
CombinedError: [GraphQL]Invalid query or variablesRun pnpm fetch-schema and check operation against schema
result.data?.mutation?.errors non-emptySaleor validation rejectionRead field and message from errors array for specifics
TypeError: Cannot read property of undefinedMissing null check on responseAlways check result.data before accessing nested properties
HTTP 429 (rate limited)Too many requestsBuilt-in retry exchange handles this; increase delay if persistent

Debugging Steps

  1. Check schema freshness: pnpm fetch-schema — ensures local schema matches remote
  2. Isolate the operation: Test the query/mutation in Saleor's GraphQL Playground first
  3. Add error context: Include operation name in all error wrapping calls
  4. Check MSW handlers: Ensure test mocks match updated operation signatures
  5. Verify type inference: Hover over ResultOf<typeof Query> in IDE to confirm types

Quick Reference Rule

For a condensed quick reference, see .claude/rules/graphql-patterns.md (automatically loaded when editing GraphQL operations and repository files).

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

26.02%
按下载量换算38

Antigravity

21.97%
按下载量换算32

Codex

17.95%
按下载量换算26

Gemini CLI

12.94%
按下载量换算19

OpenCode

8.04%
按下载量换算12

windsurf

3.84%
按下载量换算6

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills