Przejdź do treści
Biblioteka skilli
Programowanie · Budowanie i kod

graphql

/graphql

Pomaga projektować i utrzymywać API GraphQL: schemat, wydajność resolverów, DataLoader, limity kosztu zapytań, obsługa błędów i federacja, także przy wolnych zapytaniach i problemie N+1.

Licencja
MIT
Ostatnia zmiana repozytorium
24.10.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 24.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Pomaga projektować i utrzymywać API GraphQL: schemat, wydajność resolverów, DataLoader, limity kosztu zapytań, obsługa błędów i federacja, także przy wolnych zapytaniach i problemie N+1.

Wyzwalacze z opisu

graphql query is slown+1 in my resolversset up dataloaderlimit query depth on our graphql endpoint
Oryginalny opis (EN)

Use when designing or operating a GraphQL API. Covers schema design, resolver performance and DataLoader batching, query cost limiting, error handling, and federation. Trigger on "graphql query is slow", "n+1 in my resolvers", "set up dataloader", "limit query depth on our graphql endpoint". Do not use for REST endpoint design — see the api-design skill.

Jak działa

  1. Purpose
  2. When to Use
  3. Capabilities
  4. Inputs
  5. Outputs
  6. Workflow
  7. Best Practices
  8. Examples
  9. Notes
Sekcje z nagłówków SKILL.md, w oryginale · 93 linii, 621 słów
Podgląd SKILL.md
---
name: graphql
description: Use when designing or operating a GraphQL API. Covers schema design, resolver performance and DataLoader batching, query cost limiting, error handling, and federation. Trigger on "graphql query is slow", "n+1 in my resolvers", "set up dataloader", "limit query depth on our graphql endpoint". Do not use for REST endpoint design — see the api-design skill.
metadata:
  category: backend
  version: 1.0.0
  tags: [graphql, schema, dataloader, federation, performance]
---

# GraphQL

## Purpose

Design a GraphQL schema that models the domain rather than the database, and operate it without letting a single query take down the service.

## When to Use

- Designing a GraphQL schema from scratch.
- Diagnosing slow queries or N+1 resolver behavior.
- Protecting a public GraphQL endpoint from expensive queries.
- Splitting a schema across services with federation.

## Capabilities

- Schema design: types, interfaces, unions, connections, nullability.
- Resolver architecture and DataLoader batching.
- Query cost analysis, depth limiting, and persisted queries.
- Error handling that distinguishes partial failures from total ones.
- Federation and schema composition.

## Inputs

- The domain model and the client's actual query patterns.
- The data sources behind each field.
- Whether the endpoint is public (untrusted queries) or internal.

## Outputs

- A schema with deliberate nullability and stable field names.
- Resolvers that batch, with no N+1 on any documented query.
- Cost limits and a persisted-query allow-list for public endpoints.

## Workflow

1. **Design for the client, not the tables** — The schema is a product surface. If it mirrors your database, you have built a slower REST API with worse caching.
2. **Get nullability right early** — A nullable field is a permanent client burden; a non-null field that later fails takes down the whole parent object. Non-null for genuine invariants only.
3. **Batch every relation** — Every resolver that fetches by id gets a DataLoader. Without one, `orders { customer { name } }` issues one query per order.
4. **Bound the cost** — Depth limit, complexity limit, and pagination caps. Then persisted queries for first-party clients.
5. **Model errors explicitly** — Expected failures (validation, not found) belong in the schema as union results; unexpected failures go to `errors`.

## Best Practices

- Never expose an unbounded list field. Use the Connection pattern with a `first`/`after` cap.
- `DataLoader` instances are per-request. A shared loader is a cache-poisoning bug across users.
- Changing a field from nullable to non-null is a breaking change for clients that handle null; the reverse is breaking for clients that do not. Get it right before launch.
- Do not version a GraphQL schema. Add fields, deprecate old ones with `@deprecated(reason:)`, and remove them once usage reaches zero.
- Instrument per-field resolver latency. The slow field is never the one you would guess.
- Introspection on a public production endpoint is a reconnaissance gift. Disable it or restrict it.

## Examples

**DataLoader eliminating an N+1:**

```typescript
// Without a loader: 1 query for orders, then N queries for customers.
const resolvers = {
  Order: {
    customer: (order, _args, ctx) => ctx.loaders.customer.load(order.customerId),
  },
};

// The loader batches every customerId requested in the same tick into one query.
export function createLoaders(db: Db) {
  return {
    customer: new DataLoader<string, Customer>(async (ids) => {
      const rows = await db.customers.findMany({ where: { id: { in: [...ids] } } });
      const byId = new Map(rows.map((r) => [r.id, r]));
      return ids.map((id) => byId.get(id) ?? new Error(`Customer ${id} not found`));
    }),
  };
}
```

**Expected failures modeled in the schema:**

```graphql
union CreateOrderResult = Order | ValidationFailed | InsufficientInventory

type Mutation {
  createOrder(input: CreateOrderInput!): CreateOrderResult!
}
```

The client must handle each outcome. Business failures no longer masquerade as transport errors.

## Notes

- Query complexity limits must be tuned against real queries, not guessed. Log the complexity of every production query for a week before enforcing a ceiling.
- Federation solves an organizational problem (independent teams owning parts of the graph), not a technical one. If one team owns the whole schema, a single service is simpler.
- GraphQL over HTTP GET with persisted queries restores CDN caching, which naive POST-based GraphQL throws away.

Wersje

RepozytoriumWynikLicencja
Ta strona · nimadorostkar/Claude-Skills-collection100MIT
TerminalSkills/skills100Apache-2.0
crowdin/skills100MIT
claude-dev-suite/claude-dev-suite100MIT
muon-m2/magento2-tools100MIT
G1Joshi/Agent-Skills100MIT
chrishuffman5/domain-expert100MIT
arbazkhan971/godmode100MIT
Tyler-R-Kendrick/agent-skills100MIT

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

Pobrania w ostatnich 30 dniach: 0 · ranking

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

Podobne skille

  • 95graphql-resolvers
    Pomaga implementować resolvery GraphQL: funkcje resolverów, kontekst, batching DataLoader, obsługę błędów, uwierzytelnianie i strategie testowania.
  • 100graphql-n-plus-one-dataloader
    Diagnozuje i usuwa problem N+1 w resolverach GraphQL dzięki batchingowi DataLoader oraz zabezpieczeniom drugiego rzędu: persisted queries, limity głębokości i analiza kosztu.
  • 100graphql-api-design
    Projektuje API GraphQL z dobrze ułożonymi schematami, wydajnymi resolverami, paginacją oraz wzorcami wydajności takimi jak DataLoader i federacja.
  • 100go-graphql
    Buduje serwery GraphQL w Go z gqlgen: generowanie schema-first, struktura resolverów, problem N+1 i dataloadery, limity złożoności i głębokości, prezentacja błędów, autoryzacja pól i testy resolverów.
  • 100graphql-architect
    Wspiera projektowanie schematów GraphQL, wdrażanie Apollo Federation i subskrypcji czasu rzeczywistego, resolvery z DataLoader, optymalizację zapytań oraz dyrektywy federacji.
  • 100graphql-server-best-practices
    Pomaga projektować, pisać, przeglądać i debugować serwery GraphQL, szczególnie zagnieżdżone resolvery, problem N+1, DataLoader, autoryzację i koszt zapytań.

Uwagi i zgłoszenia

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