graphql-inspector-validate
БесплатноБез исполняемых скриптовНе проверенUse when validating GraphQL operations/documents against a schema, checking query depth, complexity, or fragment usage.
от TheBushidoCollective★ 202 звезды на GitHubОб этом скилле
GraphQL Inspector - Validate
Expert knowledge of GraphQL Inspector's validate command for checking operations and documents against a schema with configurable rules.
Overview
The validate command checks GraphQL operations (queries, mutations, subscriptions) and fragments against a schema. It catches errors like undefined fields, wrong argument types, and invalid fragment spreads before runtime.
Core Commands
Basic Validation
# Validate operations against schema
npx @graphql-inspector/cli validate './src/**/*.graphql' './schema.graphql'
# Validate operations from TypeScript files
npx @graphql-inspector/cli validate './src/**/*.tsx' './schema.graphql'
# Validate with glob patterns
npx @graphql-inspector/cli validate './**/*.{graphql,gql}' './schema.graphql'
Federation Support
# Apollo Federation V1
npx @graphql-inspector/cli validate './operations/**/*.graphql' './schema.graphql' \
--federation
# Apollo Federation V2
npx @graphql-inspector/cli validate './operations/**/*.graphql' './schema.graphql' \
--federationV2
# AWS AppSync directives
npx @graphql-inspector/cli validate './operations/**/*.graphql' './schema.graphql' \
--aws
Validation Rules
Depth Limiting
Prevent deeply nested queries that could cause performance issues:
# Fail if query depth exceeds 10
npx @graphql-inspector/cli validate './src/**/*.graphql' './schema.graphql' \
--maxDepth 10
Example violation:
# Depth of 8 - might exceed limit
query DeepQuery {
user { # 1
posts { # 2
author { # 3
followers { # 4
posts { # 5
comments { # 6
author { # 7
name # 8
}
}
}
}
}
}
}
}
Alias Count
Limit alias usage to prevent response explosion:
# Max 5 aliases per operation
npx @graphql-inspector/cli validate './src/**/*.graphql' './schema.graphql' \
--maxAliasCount 5
Example violation:
# 6 aliases - exceeds limit of 5
query TooManyAliases {
user1: user(id: "1") { name }
user2: user(id: "2") { name }
user3: user(id: "3") { name }
user4: user(id: "4") { name }
user5: user(id: "5") { name }
user6: user(id: "6") { name } # Exceeds limit
}
Directive Count
Limit directives to prevent abuse:
# Max 10 directives per operation
npx @graphql-inspector/cli validate './src/**/*.graphql' './schema.graphql' \
--maxDirectiveCount 10
Token Count
Limit query complexity by token count:
# Max 1000 tokens per operation
npx @graphql-inspector/cli validate './src/**/*.graphql' './schema.graphql' \
--maxTokenCount 1000
Complexity Score
Calculate and limit query complexity:
# Max complexity score of 100
npx @graphql-inspector/cli validate './src/**/*.graphql' './schema.graphql' \
--maxComplexityScore 100
Configuration File
Create .graphql-inspector.yaml:
validate:
schema: './schema.graphql'
documents: './src/**/*.graphql'
# Validation limits
maxDepth: 10
maxAliasCount: 5
maxDirectiveCount: 10
maxTokenCount: 1000
maxComplexityScore: 100
# Federation support
federation: false
federationV2: false
aws: false
Common Validation Errors
Unknown Field
Error: Cannot query field "unknownField" on type "User".
Fix: Check field name spelling or add field to schema.
Wrong Argument Type
Error: Argument "id" has invalid value "123".
Expected type "ID!", found "123" (String).
Fix: Use correct type for argument.
Missing Required Argument
Error: Field "user" argument "id" of type "ID!" is required.
Fix: Provide required argument.
Invalid Fragment Spread
Error: Fragment "UserFields" cannot be spread here as objects of
type "Post" can never be of type "User".
Fix: Ensure fragment type matches spread location.
Unused Fragment
Warning: Fragment "UnusedFragment" is never used.
Fix: Remove or use the fragment.
CI/CD Integration
GitHub Actions
name: Validate Operations
user-invocable: false
on:
pull_request:
paths:
- 'src/**/*.graphql'
- 'src/**/*.tsx'
- 'schema.graphql'
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Inspector
run: npm install -g @graphql-inspector/cli
- name: Validate operations
run: |
graphql-inspector validate \
'src/**/*.graphql' \
schema.graphql \
--maxDepth 10 \
--maxAliasCount 5
Pre-commit Hook
{
"husky": {
"hooks": {
"pre-commit": "graphql-inspector validate 'src/**/*.graphql' schema.graphql"
}
}
}
Extracting Operations from Code
GraphQL Inspector can extract operations from various file types:
TypeScri
Установить graphql-inspector-validate в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadWriteEditBashGlobGrepFAQ
Что делает скилл graphql-inspector-validate?
Use when validating GraphQL operations/documents against a schema, checking query depth, complexity, or fragment usage.
Как установить скилл graphql-inspector-validate?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл graphql-inspector-validate запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic