graphql-inspector-audit
БесплатноБез исполняемых скриптовНе проверенUse when auditing GraphQL operations for complexity metrics, depth analysis, directive usage, or query performance concerns.
от TheBushidoCollective★ 202 звезды на GitHubОб этом скилле
GraphQL Inspector - Audit
Expert knowledge of GraphQL Inspector's audit command for analyzing operation complexity and identifying potential performance issues.
Overview
The audit command analyzes GraphQL operations to provide metrics about query depth, directive count, alias count, and complexity. This helps identify operations that may cause performance issues before they reach production.
Core Commands
Basic Audit
# Audit all GraphQL operations
npx @graphql-inspector/cli audit './src/**/*.graphql'
# Audit operations from TypeScript files
npx @graphql-inspector/cli audit './src/**/*.tsx'
# Audit with multiple patterns
npx @graphql-inspector/cli audit './packages/**/*.graphql' './apps/**/*.tsx'
Audit with Schema
# Audit against a specific schema
npx @graphql-inspector/cli audit './src/**/*.graphql' --schema './schema.graphql'
Metrics Analyzed
Query Depth
Measures the maximum nesting level of a query:
# Depth: 4
query UserPosts {
user { # 1
posts { # 2
comments { # 3
author { # 4
name
}
}
}
}
}
High depth operations can cause:
- Slow database queries (N+1 problems)
- Memory pressure on resolvers
- Long response times
Alias Count
Counts the number of field aliases:
# Alias count: 3
query MultipleUsers {
admin: user(id: "1") { name }
moderator: user(id: "2") { name }
member: user(id: "3") { name }
}
High alias counts can:
- Multiply database queries
- Increase payload size
- Indicate query batching abuse
Directive Count
Counts directives used in the operation:
# Directive count: 4
query ConditionalData($includeEmail: Boolean!, $skipPhone: Boolean!) {
user {
name
email @include(if: $includeEmail)
phone @skip(if: $skipPhone)
avatar @cacheControl(maxAge: 3600)
bio @deprecated
}
}
Token Count
Counts the total tokens in the operation:
# Higher token count = more complex query
query ComplexQuery {
users(
filter: { status: ACTIVE, role: ADMIN }
orderBy: { field: NAME, direction: ASC }
pagination: { limit: 10, offset: 0 }
) {
id
name
email
role
createdAt
updatedAt
}
}
Audit Output
The audit command outputs detailed metrics for each operation:
┌──────────────────────────────────────────────────────────────┐
│ GetUser (./src/queries/user.graphql) │
├──────────────────────────────────────────────────────────────┤
│ Depth │ 5 │
│ Aliases │ 0 │
│ Directives │ 2 │
│ Tokens │ 45 │
│ Complexity │ 12 │
└──────────────────────────────────────────────────────────────┘
Configuration
Create .graphql-inspector.yaml:
audit:
documents: './src/**/*.graphql'
# Thresholds for warnings
thresholds:
depth: 10
aliases: 5
directives: 10
tokens: 500
complexity: 100
CI/CD Integration
GitHub Actions
name: Audit Operations
user-invocable: false
on:
pull_request:
paths:
- 'src/**/*.graphql'
- 'src/**/*.tsx'
jobs:
audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Inspector
run: npm install -g @graphql-inspector/cli
- name: Audit operations
run: |
graphql-inspector audit 'src/**/*.graphql'
Audit Report
Generate a detailed report:
# JSON output for processing
npx @graphql-inspector/cli audit './src/**/*.graphql' --json > audit-report.json
# Human-readable output
npx @graphql-inspector/cli audit './src/**/*.graphql' 2>&1 | tee audit-report.txt
Use Cases
Pre-PR Checks
Run before creating pull requests:
# Script to check operations before PR
#!/bin/bash
echo "Auditing GraphQL operations..."
npx @graphql-inspector/cli audit './src/**/*.graphql'
if [ $? -ne 0 ]; then
echo "Warning: Some operations may have performance issues"
fi
Periodic Analysis
Schedule regular audits:
# GitHub Action for weekly audit
name: Weekly GraphQL Audit
user-invocable: false
on:
schedule:
- cron: '0 9 * * 1' # Monday 9am
jobs:
audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm install -g @graphql-inspector/cli
- run: graphql-inspector audit './src/**/*.graphql' --json > audit.json
- name: Upload audit report
uses: actions/upload-artifact@v4
with:
name: graphql-audit
path: audit.json
Complexity Budgets
Set limits per operation type:
# Custom thresholds by operation type
audit:
thresholds:
queries:
depth: 10
complexity: 100
mutations:
dept
Установить graphql-inspector-audit в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadWriteEditBashGlobGrepFAQ
Что делает скилл graphql-inspector-audit?
Use when auditing GraphQL operations for complexity metrics, depth analysis, directive usage, or query performance concerns.
Как установить скилл graphql-inspector-audit?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл graphql-inspector-audit запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic