Przejdź do treści
Biblioteka skilli
Programowanie · Przegląd i audyt

graphql-inspector-audit

/graphql-inspector-audit

Audytuje operacje GraphQL pod kątem metryk złożoności, głębokości zapytań, użycia dyrektyw i problemów z wydajnością zapytań.

Repozytorium
han ↗
Licencja
Apache-2.0
Ostatnia zmiana repozytorium
08.09.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 08.09.2026, bez odwołań do wycofanych modeli i API.

Licencja

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

Co robi i kiedy

Audytuje operacje GraphQL pod kątem metryk złożoności, głębokości zapytań, użycia dyrektyw i problemów z wydajnością zapytań.

Oryginalny opis (EN)

Use when auditing GraphQL operations for complexity metrics, depth analysis, directive usage, or query performance concerns.

Jak działa

  1. Overview
  2. Core Commands
  3. Metrics Analyzed
  4. Audit Output
  5. Configuration
  6. CI/CD Integration
  7. Use Cases
  8. Best Practices
  9. Common Patterns
  10. Troubleshooting
Sekcje z nagłówków SKILL.md, w oryginale · 351 linii, 906 słów
Podgląd SKILL.md
---
name: graphql-inspector-audit
user-invocable: false
description: Use when auditing GraphQL operations for complexity metrics, depth analysis, directive usage, or query performance concerns.
allowed-tools: [Read, Write, Edit, Bash, Glob, Grep]
---

# 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

```bash
# 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

```bash
# 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:

```graphql
# 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:

```graphql
# 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:

```graphql
# 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:

```graphql
# 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`:

```yaml
audit:
  documents: './src/**/*.graphql'

  # Thresholds for warnings
  thresholds:
    depth: 10
    aliases: 5
    directives: 10
    tokens: 500
    complexity: 100
```

## CI/CD Integration

### GitHub Actions

```yaml
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:

```bash
# 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:

```bash
# 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:

```yaml
# 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:

```yaml
# Custom thresholds by operation type
audit:
  thresholds:
    queries:
      depth: 10
      complexity: 100
    mutations:
      depth: 5
      complexity: 50
    subscriptions:
      depth: 3
      complexity: 25
```

## Best Practices

1. **Regular audits** - Run weekly to catch complexity creep
2. **Set thresholds** - Define acceptable limits for your API
3. **Track trends** - Monitor metrics over time
4. **Review outliers** - Investigate operations with high metrics
5. **Optimize hot paths** - Focus on frequently-used operations
6. **Document exceptions** - Explain why complex operations are needed
7. **Educate team** - Share audit results and best practices
8. **Automate alerts** - Notify when thresholds are exceeded

## Common Patterns

### Reducing Query Depth

Before (depth 6):

```graphql
query DeepQuery {
  user {
    posts {
      comments {
        author {
          profile {
            avatar
          }
        }
      }
    }
  }
}
```

After (depth 3):

```graphql
query FlattenedQuery {
  user {
    posts {
      comments {
        authorName
        authorAvatar  # Denormalized field
      }
    }
  }
}
```

### Reducing Alias Count

Before (5 aliases):

```graphql
query MultipleUsers {
  user1: user(id: "1") { ...UserFields }
  user2: user(id: "2") { ...UserFields }
  user3: user(id: "3") { ...UserFields }
  user4: user(id: "4") { ...UserFields }
  user5: user(id: "5") { ...UserFields }
}
```

After (batch query):

```graphql
query BatchUsers {
  users(ids: ["1", "2", "3", "4", "5"]) {
    ...UserFields
  }
}
```

## Troubleshooting

### No operations found

- Check glob pattern matches files
- Verify files contain valid GraphQL operations
- Ensure file extensions are included

### Metrics seem wrong

- Verify operation is complete
- Check for fragment definitions
- Review inline fragment usage

### Audit is slow

- Limit scope with specific globs
- Exclude generated files
- Use `--parallel` if available

## When to Use This Skill

- Performance analysis of GraphQL operations
- Identifying complex queries before production
- Setting up complexity budgets
- Regular codebase health checks
- Training developers on query optimization
- Pre-release quality gates

Wersje

W bazie nie ma innych skilli o nazwie graphql-inspector-audit.

Migawka bazy z 13.11.2026 · wersja paczki da0b7dd57f91 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 1 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100graphql-inspector-validate
    Waliduje operacje i dokumenty GraphQL względem schematu oraz sprawdza głębokość zapytań, złożoność i użycie fragmentów.
  • 91graphql-performance
    Optymalizuje wydajność API GraphQL: analiza złożoności zapytań, batching, cache, limity głębokości, monitoring i optymalizacja bazy danych.
  • 92write-script-graphql
    Prowadzi przez pisanie zapytań GraphQL zgodnie z konwencjami tej platformy.
  • 100graphql-security-query-depth-cost-analysis
    Chroni serwer GraphQL przed przeciążeniem przez limity głębokości i kosztu zapytań oraz ustawienia timeoutów.
  • 95backend-graphql-optimization
    Diagnozuje i naprawia wydajność serwera GraphQL: zapytania N+1, DataLoader, limity złożoności, zapytania utrwalone i cache odpowiedzi.
  • 100graphql-schema-regression
    Porównuje dwa schematy GraphQL przez graphql-inspector diff, klasyfikuje zmiany jako BREAKING, DANGEROUS lub NON_BREAKING i bramkuje CI na regresjach schematu.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.