[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6CFJEE9ZA5BS8EYA1J6FXQB":3,"skill-same:01M6CFJEE9ZA5BS8EYA1J6FXQB":148},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":39,"linkOnly":40,"markdownContent":41,"markdownBody":42,"frontMatter":43,"refName":59,"commitSha":60,"skillDirectory":61,"forksCount":62,"repositoryHtmlUrl":63,"repositoryHomepageUrl":6,"ownerHtmlUrl":64,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":65,"install":66,"resources":79},"01M6CFJEE9ZA5BS8EYA1J6FXQB","golang-graphql",null,"Implements GraphQL APIs in Golang using gqlgen or graphql-go. Apply when building GraphQL servers, designing schemas, writing resolvers, handling subscriptions, or integrating GraphQL with existing Go HTTP services. Also apply when the codebase imports `github.com\u002F99designs\u002Fgqlgen` or `github.com\u002Fgraph-gophers\u002Fgraphql-go`.","rockcookies\u002Fskills","rockcookies","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F3498265?v=4","01M6CF9C16X3SDSKZX6ANH7HQM","Jacob He","01M6CF9C53JP821FCW6R9B00AJ",1,"MIT","https:\u002F\u002Fgithub.com\u002Frockcookies\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fsamber-golang\u002Fgolang-graphql\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"GraphQL","golang graphql","golang","Bash","writing","context7","subscriptions","webfetch","read","curl","projects","gopls","codex","MCP","services","github","harness","code","lint","http","2026-11-10 10:12:30",false,"---\nname: golang-graphql\ndescription: >-\n  Implements GraphQL APIs in Golang using gqlgen or graphql-go. Apply when\n  building GraphQL servers, designing schemas, writing resolvers, handling\n  subscriptions, or integrating GraphQL with existing Go HTTP services. Also\n  apply when the codebase imports `github.com\u002F99designs\u002Fgqlgen` or\n  `github.com\u002Fgraph-gophers\u002Fgraphql-go`.\nuser-invocable: false\nlicense: MIT\ncompatibility: >-\n  Designed for Claude Code, Codex or similar harness, and for projects using\n  Golang.\nmetadata:\n  author: samber\n  version: 0.2.0\n  openclaw:\n    emoji: ?\n    homepage: https:\u002F\u002Fgithub.com\u002Fsamber\u002Fcc-skills-golang\n    requires:\n      bins:\n        - go\n    install: []\n    skill-library-version: 0.17.89\nallowed-tools: >-\n  Read Edit Write Glob Grep Bash(go:*) Bash(golangci-lint:*) Bash(git:*) Agent\n  WebFetch mcp__context7__resolve-library-id mcp__context7__query-docs\n  Bash(curl:*) Bash(godig:*) Bash(gopls:*) LSP mcp__gopls__*\npaths:\n  - '**\u002F*.go'\n---\n\n**Persona:** You are a Go GraphQL engineer. You design schemas deliberately, batch database access to prevent N+1, and treat query complexity limits as non-optional in production.\n\n**Modes:**\n\n- **Build mode** — generating new schemas, resolvers, or server setup: follow the skill's sequential instructions; launch a background agent to grep for existing resolver patterns and naming conventions before generating new code.\n- **Review mode** — auditing a GraphQL codebase or PR: use a sub-agent to scan for N+1 resolver patterns, missing complexity caps, global DataLoaders, and introspection enabled in production, in parallel with reading the business logic.\n\n> **Community default.** A company skill that explicitly supersedes `golang-graphql` skill takes precedence.\n\n# Go GraphQL Best Practices\n\nBoth major libraries are schema-first: write SDL (`.graphql` files), bind Go resolvers. Choose based on project size and team preferences.\n\nThis skill is not exhaustive. Refer to each library's official documentation and code examples for current API signatures. For Go package docs, symbols, versions, importers, and known vulnerabilities, → See `golang-pkg-go-dev` skill (`godig`) — prefer it over Context7 for Go package facts. To navigate this library's usage in your own code (definitions, call sites, diagnostics), → See `golang-gopls` skill (`gopls`). Context7 remains a fallback for docs not indexed on pkg.go.dev.\n\n## Library Choice\n\n| Library | Approach | Type safety | Build step | Best for |\n| --- | --- | --- | --- | --- |\n| `github.com\u002F99designs\u002Fgqlgen` | Codegen | Compile-time | `go generate` | Large schemas, federation, strict types |\n| `github.com\u002Fgraph-gophers\u002Fgraphql-go` | Reflection | Parse-time | None | Simple schemas, fast iteration |\n| `github.com\u002Fgraphql-go\u002Fgraphql` | Code-first | Runtime | None | **Avoid** — verbose, no SDL |\n\nPick **gqlgen** when: Apollo Federation is required, schema is large (100+ types), or the team wants generated stubs and zero reflection overhead.\n\nPick **graph-gophers** when: schema is small\u002Fmedium, the build pipeline should stay simple, or a dynamic schema is needed.\n\nFor deep-dive on each library, see [gqlgen reference](.\u002Freferences\u002Fgqlgen.md) and [graphql-go reference](.\u002Freferences\u002Fgraphql-go.md).\n\n## Schema Design\n\n```graphql\n# ✓ Good — explicit nullability; ID scalar for opaque identifiers\ntype User {\n  id: ID!\n  email: String! # non-null: the server can always return this\n  bio: String # nullable: may be unset\n  posts(first: Int = 10, after: String): PostConnection!\n}\n\n# ✗ Bad — Int ID leaks implementation details, breaks client caching\ntype Post {\n  id: Int!\n}\n```\n\n**Nullability rule:** mark a field `!` only when the server can _always_ return a value. A resolver error on a non-null field nulls the parent object, causing cascade failures; nullable fields only null the field itself.\n\n**Pagination:** use Relay cursor connections (`Connection`\u002F`Edge`\u002F`PageInfo`) for list fields. Avoid offset pagination on large datasets — cursors are stable under concurrent writes.\n\n**Mutations:** wrap results in an envelope type so clients receive business errors alongside partial results without polluting the GraphQL `errors` array:\n\n```graphql\ntype CreateUserPayload {\n  user: User\n  errors: [UserError!]!\n}\n```\n\n## Resolver Patterns\n\nKeep resolvers thin — they translate GraphQL inputs to domain calls and domain responses to GraphQL outputs.\n\n```go\n\u002F\u002F ✓ Good — resolver delegates to service layer\nfunc (r *mutationResolver) CreateUser(ctx context.Context, input model.CreateUserInput) (*model.CreateUserPayload, error) {\n    user, err := r.userService.Create(ctx, input.Email, input.Name)\n    if err != nil {\n        return nil, formatError(err)\n    }\n    return &model.CreateUserPayload{User: toGQLUser(user)}, nil\n}\n\n\u002F\u002F ✗ Bad — SQL in resolver, no separation of concerns\nfunc (r *queryResolver) User(ctx context.Context, id string) (*model.User, error) {\n    row := r.db.QueryRowContext(ctx, \"SELECT * FROM users WHERE id = $1\", id)\n    \u002F\u002F ...\n}\n```\n\nUse per-type resolver structs (`userResolver`, `postResolver`) rather than one monolithic resolver for all fields.\n\n## N+1 Prevention (DataLoaders)\n\nEach `User.posts` resolver fires a SQL query per user without batching — O(n) DB calls for n users. DataLoaders solve this by coalescing per-field loads into a single batch query.\n\n**Critical rule: DataLoaders MUST be created per-request in HTTP middleware, never globally.** A global DataLoader caches across requests — stale data, potential cross-user data leakage.\n\n```go\n\u002F\u002F ✓ Good — per-request DataLoader in middleware\nfunc DataLoaderMiddleware(db *sql.DB, next http.Handler) http.Handler {\n    return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n        loaders := &Loaders{\n            PostsByUserID: newPostsByUserIDLoader(r.Context(), db),\n        }\n        ctx := context.WithValue(r.Context(), loadersKey, loaders)\n        next.ServeHTTP(w, r.WithContext(ctx))\n    })\n}\n\n\u002F\u002F ✗ Bad — global DataLoader shared across all requests\nvar globalLoader = newPostsByUserIDLoader(context.Background(), db)\n```\n\nIn gqlgen, mark batched fields with `resolver: true` in `gqlgen.yml` to force a dedicated resolver method. See [gqlgen reference](.\u002Freferences\u002Fgqlgen.md) for full DataLoader wiring.\n\n## Authentication and Authorization\n\nTwo-layer model:\n\n1. **HTTP middleware** — extract and validate tokens, stash identity in `context.Context`.\n2. **Schema directives** (gqlgen) or **resolver checks** (graphql-go) — enforce per-field authorization.\n\n```go\n\u002F\u002F HTTP middleware layer (both libraries)\nfunc AuthMiddleware(next http.Handler) http.Handler {\n    return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n        token := r.Header.Get(\"Authorization\")\n        user, err := validateToken(token)\n        if err != nil {\n            http.Error(w, \"Unauthorized\", http.StatusUnauthorized)\n            return\n        }\n        ctx := context.WithValue(r.Context(), userKey, user)\n        next.ServeHTTP(w, r.WithContext(ctx))\n    })\n}\n```\n\nIn gqlgen, use `@hasRole` schema directives for field-level authorization — authorization policy lives in the schema, not scattered across resolvers. See [gqlgen reference](.\u002Freferences\u002Fgqlgen.md).\n\n## Error Handling\n\nNever return raw internal errors — they leak SQL messages, stack traces, or service internals to clients.\n\n```go\n\u002F\u002F gqlgen — custom ErrorPresenter strips internal details\nsrv.SetErrorPresenter(func(ctx context.Context, err error) *gqlerror.Error {\n    var gqlErr *gqlerror.Error\n    if errors.As(err, &gqlErr) {\n        return gqlErr \u002F\u002F already formatted\n    }\n    \u002F\u002F log internal err here\n    return gqlerror.Errorf(\"internal error\") \u002F\u002F safe client message\n})\n\n\u002F\u002F Add extension codes for client-side error handling\nreturn nil, &gqlerror.Error{\n    Message: \"user not found\",\n    Extensions: map[string]any{\"code\": \"NOT_FOUND\"},\n}\n```\n\nFor graph-gophers, implement the `ResolverError` interface to attach `Extensions()`. See [graphql-go reference](.\u002Freferences\u002Fgraphql-go.md).\n\nUse `graphql.AddError(ctx, err)` in gqlgen for non-fatal field errors where the resolver can still return partial data.\n\nFor error wrapping patterns, see the `golang-error-handling` skill.\n\n## Subscriptions\n\nSubscriptions use long-lived WebSocket connections. The critical discipline: **always respect context cancellation** — a leaked goroutine per disconnected client exhausts resources silently.\n\n```go\n\u002F\u002F ✓ Good — closes channel when client disconnects\nfunc (r *subscriptionResolver) MessageAdded(ctx context.Context, room string) (\u003C-chan *model.Message, error) {\n    ch := make(chan *model.Message, 1)\n    sub := r.pubsub.Subscribe(room) \u002F\u002F subscribe once before the goroutine\n    go func() {\n        defer close(ch) \u002F\u002F always close; signals iteration to stop\n        for {\n            select {\n            case \u003C-ctx.Done():\n                return \u002F\u002F client disconnected\n            case msg := \u003C-sub:\n                select {\n                case ch \u003C- msg:\n                case \u003C-ctx.Done():\n                    return\n                }\n            }\n        }\n    }()\n    return ch, nil\n}\n\n\u002F\u002F ✗ Bad — goroutine leaks forever when client disconnects\nfunc (r *subscriptionResolver) MessageAdded(ctx context.Context, room string) (\u003C-chan *model.Message, error) {\n    ch := make(chan *model.Message, 1)\n    go func() {\n        for msg := range r.pubsub.Subscribe(room) {\n            ch \u003C- msg \u002F\u002F blocks forever after client gone\n        }\n    }()\n    return ch, nil\n}\n```\n\n## Performance and Safety\n\nProduction GraphQL servers require explicit limits. Without them, a single deeply nested query exhausts CPU and memory.\n\n```go\n\u002F\u002F gqlgen — wire these into every production handler\nsrv := handler.NewDefaultServer(es)\nsrv.Use(extension.FixedComplexityLimit(200)) \u002F\u002F max cost per query\n\n\u002F\u002F Gate introspection — only in non-production environments\nif os.Getenv(\"ENV\") != \"production\" {\n    srv.Use(extension.Introspection{})\n}\n```\n\nFor graph-gophers: `graphql.MaxDepth(10)` and `graphql.MaxParallelism(10)` options at `ParseSchema` time.\n\n**Query allow-listing:** in production, consider persisted queries (gqlgen APQ extension) to reject arbitrary query strings.\n\n## Common Mistakes\n\n| Mistake | Why it matters | Fix |\n| --- | --- | --- |\n| N+1 queries in child resolvers | One SQL per parent row → O(n) DB calls | Use per-request DataLoader |\n| Global DataLoader | Cross-request cache — stale data, data leaks | Create DataLoader in request middleware |\n| Editing `models_gen.go` directly | Next `go generate` wipes hand edits | Use `autobind` or `models.\u003CT>.model` in `gqlgen.yml` |\n| Forgetting `go generate` after schema change | Resolver interface mismatch at compile time | Re-run `go tool gqlgen generate` |\n| `int` field in graph-gophers resolver | Library requires `int32` for `Int` scalar | Use `int32` (or `float64` for `Float`) |\n| Introspection enabled in production | Exposes full schema to attackers | Gate with `ENV` check |\n| No complexity cap | Deeply nested query → CPU\u002Fmemory DoS | `extension.FixedComplexityLimit(N)` |\n| Leaking DB errors from resolvers | Exposes SQL internals to clients | Wrap in `ErrorPresenter` \u002F `ResolverError` |\n| Subscription goroutine leak | Client disconnect → goroutine runs forever | `defer close(ch)` + `select ctx.Done()` |\n| Nullable field for always-required data | Clients must null-check everywhere | Mark `!` in schema; return error from resolver |\n\n## Deep Dives\n\n- **[gqlgen reference](.\u002Freferences\u002Fgqlgen.md)** — codegen workflow, `gqlgen.yml`, DataLoaders, Federation v2, directives\n- **[graphql-go reference](.\u002Freferences\u002Fgraphql-go.md)** — reflection resolver model, type mapping, tracing\n- **[Testing](.\u002Freferences\u002Ftesting.md)** — gqlgen client harness, gqltesting, httptest patterns\n\n## Cross-References\n\n- → See `golang-context` skill for context propagation in resolvers and subscriptions\n- → See `golang-error-handling` skill for error wrapping and sentinel patterns\n- → See `golang-testing` skill for table-driven and integration test patterns\n- → See `golang-observability` skill for tracing and metrics in resolvers\n- → See `golang-security` skill for input validation and injection prevention\n- → See `golang-database` skill for N+1 query patterns and DataLoader database batching\n\n## References\n\n- [gqlgen](https:\u002F\u002Fgithub.com\u002F99designs\u002Fgqlgen)\n- [graph-gophers\u002Fgraphql-go](https:\u002F\u002Fgithub.com\u002Fgraph-gophers\u002Fgraphql-go)\n- [Relay cursor connections spec](https:\u002F\u002Frelay.dev\u002Fgraphql\u002Fconnections.htm)\n\nIf you encounter a bug or unexpected behavior in gqlgen, open an issue at \u003Chttps:\u002F\u002Fgithub.com\u002F99designs\u002Fgqlgen\u002Fissues>.\n\nIf you encounter a bug or unexpected behavior in graph-gophers\u002Fgraphql-go, open an issue at \u003Chttps:\u002F\u002Fgithub.com\u002Fgraph-gophers\u002Fgraphql-go\u002Fissues>.\n","**Persona:** You are a Go GraphQL engineer. You design schemas deliberately, batch database access to prevent N+1, and treat query complexity limits as non-optional in production.\n\n**Modes:**\n\n- **Build mode** — generating new schemas, resolvers, or server setup: follow the skill's sequential instructions; launch a background agent to grep for existing resolver patterns and naming conventions before generating new code.\n- **Review mode** — auditing a GraphQL codebase or PR: use a sub-agent to scan for N+1 resolver patterns, missing complexity caps, global DataLoaders, and introspection enabled in production, in parallel with reading the business logic.\n\n> **Community default.** A company skill that explicitly supersedes `golang-graphql` skill takes precedence.\n\n# Go GraphQL Best Practices\n\nBoth major libraries are schema-first: write SDL (`.graphql` files), bind Go resolvers. Choose based on project size and team preferences.\n\nThis skill is not exhaustive. Refer to each library's official documentation and code examples for current API signatures. For Go package docs, symbols, versions, importers, and known vulnerabilities, → See `golang-pkg-go-dev` skill (`godig`) — prefer it over Context7 for Go package facts. To navigate this library's usage in your own code (definitions, call sites, diagnostics), → See `golang-gopls` skill (`gopls`). Context7 remains a fallback for docs not indexed on pkg.go.dev.\n\n## Library Choice\n\n| Library | Approach | Type safety | Build step | Best for |\n| --- | --- | --- | --- | --- |\n| `github.com\u002F99designs\u002Fgqlgen` | Codegen | Compile-time | `go generate` | Large schemas, federation, strict types |\n| `github.com\u002Fgraph-gophers\u002Fgraphql-go` | Reflection | Parse-time | None | Simple schemas, fast iteration |\n| `github.com\u002Fgraphql-go\u002Fgraphql` | Code-first | Runtime | None | **Avoid** — verbose, no SDL |\n\nPick **gqlgen** when: Apollo Federation is required, schema is large (100+ types), or the team wants generated stubs and zero reflection overhead.\n\nPick **graph-gophers** when: schema is small\u002Fmedium, the build pipeline should stay simple, or a dynamic schema is needed.\n\nFor deep-dive on each library, see [gqlgen reference](.\u002Freferences\u002Fgqlgen.md) and [graphql-go reference](.\u002Freferences\u002Fgraphql-go.md).\n\n## Schema Design\n\n```graphql\n# ✓ Good — explicit nullability; ID scalar for opaque identifiers\ntype User {\n  id: ID!\n  email: String! # non-null: the server can always return this\n  bio: String # nullable: may be unset\n  posts(first: Int = 10, after: String): PostConnection!\n}\n\n# ✗ Bad — Int ID leaks implementation details, breaks client caching\ntype Post {\n  id: Int!\n}\n```\n\n**Nullability rule:** mark a field `!` only when the server can _always_ return a value. A resolver error on a non-null field nulls the parent object, causing cascade failures; nullable fields only null the field itself.\n\n**Pagination:** use Relay cursor connections (`Connection`\u002F`Edge`\u002F`PageInfo`) for list fields. Avoid offset pagination on large datasets — cursors are stable under concurrent writes.\n\n**Mutations:** wrap results in an envelope type so clients receive business errors alongside partial results without polluting the GraphQL `errors` array:\n\n```graphql\ntype CreateUserPayload {\n  user: User\n  errors: [UserError!]!\n}\n```\n\n## Resolver Patterns\n\nKeep resolvers thin — they translate GraphQL inputs to domain calls and domain responses to GraphQL outputs.\n\n```go\n\u002F\u002F ✓ Good — resolver delegates to service layer\nfunc (r *mutationResolver) CreateUser(ctx context.Context, input model.CreateUserInput) (*model.CreateUserPayload, error) {\n    user, err := r.userService.Create(ctx, input.Email, input.Name)\n    if err != nil {\n        return nil, formatError(err)\n    }\n    return &model.CreateUserPayload{User: toGQLUser(user)}, nil\n}\n\n\u002F\u002F ✗ Bad — SQL in resolver, no separation of concerns\nfunc (r *queryResolver) User(ctx context.Context, id string) (*model.User, error) {\n    row := r.db.QueryRowContext(ctx, \"SELECT * FROM users WHERE id = $1\", id)\n    \u002F\u002F ...\n}\n```\n\nUse per-type resolver structs (`userResolver`, `postResolver`) rather than one monolithic resolver for all fields.\n\n## N+1 Prevention (DataLoaders)\n\nEach `User.posts` resolver fires a SQL query per user without batching — O(n) DB calls for n users. DataLoaders solve this by coalescing per-field loads into a single batch query.\n\n**Critical rule: DataLoaders MUST be created per-request in HTTP middleware, never globally.** A global DataLoader caches across requests — stale data, potential cross-user data leakage.\n\n```go\n\u002F\u002F ✓ Good — per-request DataLoader in middleware\nfunc DataLoaderMiddleware(db *sql.DB, next http.Handler) http.Handler {\n    return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n        loaders := &Loaders{\n            PostsByUserID: newPostsByUserIDLoader(r.Context(), db),\n        }\n        ctx := context.WithValue(r.Context(), loadersKey, loaders)\n        next.ServeHTTP(w, r.WithContext(ctx))\n    })\n}\n\n\u002F\u002F ✗ Bad — global DataLoader shared across all requests\nvar globalLoader = newPostsByUserIDLoader(context.Background(), db)\n```\n\nIn gqlgen, mark batched fields with `resolver: true` in `gqlgen.yml` to force a dedicated resolver method. See [gqlgen reference](.\u002Freferences\u002Fgqlgen.md) for full DataLoader wiring.\n\n## Authentication and Authorization\n\nTwo-layer model:\n\n1. **HTTP middleware** — extract and validate tokens, stash identity in `context.Context`.\n2. **Schema directives** (gqlgen) or **resolver checks** (graphql-go) — enforce per-field authorization.\n\n```go\n\u002F\u002F HTTP middleware layer (both libraries)\nfunc AuthMiddleware(next http.Handler) http.Handler {\n    return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n        token := r.Header.Get(\"Authorization\")\n        user, err := validateToken(token)\n        if err != nil {\n            http.Error(w, \"Unauthorized\", http.StatusUnauthorized)\n            return\n        }\n        ctx := context.WithValue(r.Context(), userKey, user)\n        next.ServeHTTP(w, r.WithContext(ctx))\n    })\n}\n```\n\nIn gqlgen, use `@hasRole` schema directives for field-level authorization — authorization policy lives in the schema, not scattered across resolvers. See [gqlgen reference](.\u002Freferences\u002Fgqlgen.md).\n\n## Error Handling\n\nNever return raw internal errors — they leak SQL messages, stack traces, or service internals to clients.\n\n```go\n\u002F\u002F gqlgen — custom ErrorPresenter strips internal details\nsrv.SetErrorPresenter(func(ctx context.Context, err error) *gqlerror.Error {\n    var gqlErr *gqlerror.Error\n    if errors.As(err, &gqlErr) {\n        return gqlErr \u002F\u002F already formatted\n    }\n    \u002F\u002F log internal err here\n    return gqlerror.Errorf(\"internal error\") \u002F\u002F safe client message\n})\n\n\u002F\u002F Add extension codes for client-side error handling\nreturn nil, &gqlerror.Error{\n    Message: \"user not found\",\n    Extensions: map[string]any{\"code\": \"NOT_FOUND\"},\n}\n```\n\nFor graph-gophers, implement the `ResolverError` interface to attach `Extensions()`. See [graphql-go reference](.\u002Freferences\u002Fgraphql-go.md).\n\nUse `graphql.AddError(ctx, err)` in gqlgen for non-fatal field errors where the resolver can still return partial data.\n\nFor error wrapping patterns, see the `golang-error-handling` skill.\n\n## Subscriptions\n\nSubscriptions use long-lived WebSocket connections. The critical discipline: **always respect context cancellation** — a leaked goroutine per disconnected client exhausts resources silently.\n\n```go\n\u002F\u002F ✓ Good — closes channel when client disconnects\nfunc (r *subscriptionResolver) MessageAdded(ctx context.Context, room string) (\u003C-chan *model.Message, error) {\n    ch := make(chan *model.Message, 1)\n    sub := r.pubsub.Subscribe(room) \u002F\u002F subscribe once before the goroutine\n    go func() {\n        defer close(ch) \u002F\u002F always close; signals iteration to stop\n        for {\n            select {\n            case \u003C-ctx.Done():\n                return \u002F\u002F client disconnected\n            case msg := \u003C-sub:\n                select {\n                case ch \u003C- msg:\n                case \u003C-ctx.Done():\n                    return\n                }\n            }\n        }\n    }()\n    return ch, nil\n}\n\n\u002F\u002F ✗ Bad — goroutine leaks forever when client disconnects\nfunc (r *subscriptionResolver) MessageAdded(ctx context.Context, room string) (\u003C-chan *model.Message, error) {\n    ch := make(chan *model.Message, 1)\n    go func() {\n        for msg := range r.pubsub.Subscribe(room) {\n            ch \u003C- msg \u002F\u002F blocks forever after client gone\n        }\n    }()\n    return ch, nil\n}\n```\n\n## Performance and Safety\n\nProduction GraphQL servers require explicit limits. Without them, a single deeply nested query exhausts CPU and memory.\n\n```go\n\u002F\u002F gqlgen — wire these into every production handler\nsrv := handler.NewDefaultServer(es)\nsrv.Use(extension.FixedComplexityLimit(200)) \u002F\u002F max cost per query\n\n\u002F\u002F Gate introspection — only in non-production environments\nif os.Getenv(\"ENV\") != \"production\" {\n    srv.Use(extension.Introspection{})\n}\n```\n\nFor graph-gophers: `graphql.MaxDepth(10)` and `graphql.MaxParallelism(10)` options at `ParseSchema` time.\n\n**Query allow-listing:** in production, consider persisted queries (gqlgen APQ extension) to reject arbitrary query strings.\n\n## Common Mistakes\n\n| Mistake | Why it matters | Fix |\n| --- | --- | --- |\n| N+1 queries in child resolvers | One SQL per parent row → O(n) DB calls | Use per-request DataLoader |\n| Global DataLoader | Cross-request cache — stale data, data leaks | Create DataLoader in request middleware |\n| Editing `models_gen.go` directly | Next `go generate` wipes hand edits | Use `autobind` or `models.\u003CT>.model` in `gqlgen.yml` |\n| Forgetting `go generate` after schema change | Resolver interface mismatch at compile time | Re-run `go tool gqlgen generate` |\n| `int` field in graph-gophers resolver | Library requires `int32` for `Int` scalar | Use `int32` (or `float64` for `Float`) |\n| Introspection enabled in production | Exposes full schema to attackers | Gate with `ENV` check |\n| No complexity cap | Deeply nested query → CPU\u002Fmemory DoS | `extension.FixedComplexityLimit(N)` |\n| Leaking DB errors from resolvers | Exposes SQL internals to clients | Wrap in `ErrorPresenter` \u002F `ResolverError` |\n| Subscription goroutine leak | Client disconnect → goroutine runs forever | `defer close(ch)` + `select ctx.Done()` |\n| Nullable field for always-required data | Clients must null-check everywhere | Mark `!` in schema; return error from resolver |\n\n## Deep Dives\n\n- **[gqlgen reference](.\u002Freferences\u002Fgqlgen.md)** — codegen workflow, `gqlgen.yml`, DataLoaders, Federation v2, directives\n- **[graphql-go reference](.\u002Freferences\u002Fgraphql-go.md)** — reflection resolver model, type mapping, tracing\n- **[Testing](.\u002Freferences\u002Ftesting.md)** — gqlgen client harness, gqltesting, httptest patterns\n\n## Cross-References\n\n- → See `golang-context` skill for context propagation in resolvers and subscriptions\n- → See `golang-error-handling` skill for error wrapping and sentinel patterns\n- → See `golang-testing` skill for table-driven and integration test patterns\n- → See `golang-observability` skill for tracing and metrics in resolvers\n- → See `golang-security` skill for input validation and injection prevention\n- → See `golang-database` skill for N+1 query patterns and DataLoader database batching\n\n## References\n\n- [gqlgen](https:\u002F\u002Fgithub.com\u002F99designs\u002Fgqlgen)\n- [graph-gophers\u002Fgraphql-go](https:\u002F\u002Fgithub.com\u002Fgraph-gophers\u002Fgraphql-go)\n- [Relay cursor connections spec](https:\u002F\u002Frelay.dev\u002Fgraphql\u002Fconnections.htm)\n\nIf you encounter a bug or unexpected behavior in gqlgen, open an issue at \u003Chttps:\u002F\u002Fgithub.com\u002F99designs\u002Fgqlgen\u002Fissues>.\n\nIf you encounter a bug or unexpected behavior in graph-gophers\u002Fgraphql-go, open an issue at \u003Chttps:\u002F\u002Fgithub.com\u002Fgraph-gophers\u002Fgraphql-go\u002Fissues>.\n",{"name":5,"paths":44,"license":15,"metadata":46,"description":7,"allowed-tools":57,"compatibility":58,"user-invocable":40},[45],"**\u002F*.go",{"author":47,"version":48,"openclaw":49},"samber","0.2.0",{"emoji":50,"install":51,"homepage":52,"requires":53,"skill-library-version":56},"?",[],"https:\u002F\u002Fgithub.com\u002Fsamber\u002Fcc-skills-golang",{"bins":54},[55],"go","0.17.89","Read Edit Write Glob Grep Bash(go:*) Bash(golangci-lint:*) Bash(git:*) Agent WebFetch mcp__context7__resolve-library-id mcp__context7__query-docs Bash(curl:*) Bash(godig:*) Bash(gopls:*) LSP mcp__gopls__*","Designed for Claude Code, Codex or similar harness, and for projects using Golang.","main","c349be0704bffe54a7191d1412faf564b08983ca","skills\u002Fsamber-golang\u002Fgolang-graphql",0,"https:\u002F\u002Fgithub.com\u002Frockcookies\u002Fskills","https:\u002F\u002Fgithub.com\u002Frockcookies","2026-11-12 14:42:52",{"source":8,"skillName":5,"commands":67,"prompt":77,"zipAvailable":78},[68,71,74],{"tool":69,"command":70},"npx","npx skills add rockcookies\u002Fskills --skill golang-graphql",{"tool":72,"command":73},"bunx","bunx skills add rockcookies\u002Fskills --skill golang-graphql",{"tool":75,"command":76},"pnpm","pnpm dlx skills add rockcookies\u002Fskills --skill golang-graphql","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Frockcookies\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fsamber-golang\u002Fgolang-graphql\u002FSKILL.md",true,[80,86,90,94,98,102,106,112,116,120,124,128,132,136,140,144],{"path":81,"resourceType":82,"resourceTypeDesc":83,"sizeBytes":84,"sourceHtmlUrl":85},"evals\u002Fevals.json","REFERENCE","参考文档",11727,"https:\u002F\u002Fgithub.com\u002Frockcookies\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fsamber-golang\u002Fgolang-graphql\u002Fevals\u002Fevals.json",{"path":87,"resourceType":82,"resourceTypeDesc":83,"sizeBytes":88,"sourceHtmlUrl":89},"references\u002Fcommon_tags.md",13364,"https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fkdense-pydicom\u002Freferences\u002Fcommon_tags.md",{"path":91,"resourceType":82,"resourceTypeDesc":83,"sizeBytes":92,"sourceHtmlUrl":93},"references\u002Fgqlgen.md",7477,"https:\u002F\u002Fgithub.com\u002Frockcookies\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fsamber-golang\u002Fgolang-graphql\u002Freferences\u002Fgqlgen.md",{"path":95,"resourceType":82,"resourceTypeDesc":83,"sizeBytes":96,"sourceHtmlUrl":97},"references\u002Fgraphql-go.md",7218,"https:\u002F\u002Fgithub.com\u002Frockcookies\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fsamber-golang\u002Fgolang-graphql\u002Freferences\u002Fgraphql-go.md",{"path":99,"resourceType":82,"resourceTypeDesc":83,"sizeBytes":100,"sourceHtmlUrl":101},"references\u002Ftesting.md",4999,"https:\u002F\u002Fgithub.com\u002Frockcookies\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fsamber-golang\u002Fgolang-graphql\u002Freferences\u002Ftesting.md",{"path":103,"resourceType":82,"resourceTypeDesc":83,"sizeBytes":104,"sourceHtmlUrl":105},"references\u002Ftransfer_syntaxes.md",15166,"https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fkdense-pydicom\u002Freferences\u002Ftransfer_syntaxes.md",{"path":107,"resourceType":108,"resourceTypeDesc":109,"sizeBytes":110,"sourceHtmlUrl":111},"scripts\u002F__init__.py","SCRIPT","脚本",60,"https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fkdense-pydicom\u002Fscripts\u002F__init__.py",{"path":113,"resourceType":108,"resourceTypeDesc":109,"sizeBytes":114,"sourceHtmlUrl":115},"scripts\u002F_common.py",29812,"https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fkdense-pydicom\u002Fscripts\u002F_common.py",{"path":117,"resourceType":108,"resourceTypeDesc":109,"sizeBytes":118,"sourceHtmlUrl":119},"scripts\u002Fanonymize_dicom.py",26110,"https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fkdense-pydicom\u002Fscripts\u002Fanonymize_dicom.py",{"path":121,"resourceType":108,"resourceTypeDesc":109,"sizeBytes":122,"sourceHtmlUrl":123},"scripts\u002Fdeidentification_audit.py",13090,"https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fkdense-pydicom\u002Fscripts\u002Fdeidentification_audit.py",{"path":125,"resourceType":108,"resourceTypeDesc":109,"sizeBytes":126,"sourceHtmlUrl":127},"scripts\u002Fdicom_inventory.py",13774,"https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fkdense-pydicom\u002Fscripts\u002Fdicom_inventory.py",{"path":129,"resourceType":108,"resourceTypeDesc":109,"sizeBytes":130,"sourceHtmlUrl":131},"scripts\u002Fdicom_to_image.py",16946,"https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fkdense-pydicom\u002Fscripts\u002Fdicom_to_image.py",{"path":133,"resourceType":108,"resourceTypeDesc":109,"sizeBytes":134,"sourceHtmlUrl":135},"scripts\u002Fextract_metadata.py",11846,"https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fkdense-pydicom\u002Fscripts\u002Fextract_metadata.py",{"path":137,"resourceType":108,"resourceTypeDesc":109,"sizeBytes":138,"sourceHtmlUrl":139},"scripts\u002Fpixel_frame_planner.py",10659,"https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fkdense-pydicom\u002Fscripts\u002Fpixel_frame_planner.py",{"path":141,"resourceType":108,"resourceTypeDesc":109,"sizeBytes":142,"sourceHtmlUrl":143},"scripts\u002Ftransfer_syntax_inspector.py",7881,"https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fkdense-pydicom\u002Fscripts\u002Ftransfer_syntax_inspector.py",{"path":145,"resourceType":108,"resourceTypeDesc":109,"sizeBytes":146,"sourceHtmlUrl":147},"scripts\u002Fuid_mapping_validator.py",8681,"https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fkdense-pydicom\u002Fscripts\u002Fuid_mapping_validator.py",[149,181,205,227,253,268],{"skillNo":150,"name":151,"nameZh":152,"description":153,"descriptionZh":154,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":155,"sourceHtmlUrl":156,"categories":157,"keywords":168,"publishedAt":180},"01M6CFPKHRH0GD3W2GTGWE9WGP","kami","Kami 专业文档排版","Typeset professional documents with Kami templates: resumes, one-pagers, white papers, letters, portfolios, and slide decks. Use when asked to 做 PDF \u002F 排版 \u002F 简历 \u002F 一页纸 \u002F PPT \u002F slides, or to create a Kami landing page. Not for auditing or restyling an existing product site.","使用 Kami 模板排版专业文档：简历、一页纸、白皮书、信件、作品集和幻灯片。当用户要求做 PDF \u002F 排版 \u002F 简历 \u002F 一页纸 \u002F PPT \u002F slides，或创建 Kami 落地页时使用。不适用于审查或重新设计现有产品网站。","https:\u002F\u002Fgithub.com\u002Frockcookies\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Ftw93-kami\u002Fkami\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Frockcookies\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Ftw93-kami\u002Fkami\u002FSKILL.md",[158,163],{"categoryNo":159,"categoryName":160,"taxonomyType":161,"taxonomyTypeDesc":162},"01M8BQ6TK1MPB82068236GSXDE","文档处理","SCENARIO","使用场景",{"categoryNo":164,"categoryName":165,"taxonomyType":166,"taxonomyTypeDesc":167},"01M8C55A3R2M9C8CAKG3W16HTA","内容创作者","PROFESSION","适用职业",[151,169,170,171,172,173,174,175,176,177,178,179],"create","PDF","pptx","slides","product","page","landing","templates","site","use","documents","2026-11-12 13:55:43",{"skillNo":182,"name":183,"nameZh":6,"description":184,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":185,"categories":186,"keywords":187,"publishedAt":39},"01M6WMNKD3Y4H9FGM8Q901F507","hierarchical-agents-md","层级 AGENTS.md \u002F README.md：init、update、audit、reorganize、trim。 初始化 Agent 指令、代码改动后同步文档、检查文档漂移、重组仓库文档层级、精简规则与 Skills。 Not for 写业务代码或生成文档站点。","https:\u002F\u002Fgithub.com\u002Frockcookies\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fcustom\u002Fhierarchical-agents-md\u002FSKILL.md",[],[188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204],"hierarchical agents md","agents md","packages","change","maintenance","初始化","audit","for","README","update","python","init","git","true","party","third-party","文档",{"skillNo":206,"name":207,"nameZh":208,"description":209,"descriptionZh":210,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":211,"categories":212,"keywords":219,"publishedAt":39},"01M6CFS6BRTQPFZCDHQP97HYXR","vueuse-functions","VueUse 组合式函数应用","Apply VueUse composables where appropriate to build concise, maintainable Vue.js \u002F Nuxt features.","在合适的地方应用 VueUse 组合式函数（composables），以构建简洁、可维护的 Vue.js \u002F Nuxt 功能。","https:\u002F\u002Fgithub.com\u002Frockcookies\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fvueuse\u002Fvueuse-functions\u002FSKILL.md",[213,216],{"categoryNo":214,"categoryName":215,"taxonomyType":166,"taxonomyTypeDesc":167},"01M8BQ6TQZN6R52WBJ9H8NRMQM","软件开发工程师",{"categoryNo":217,"categoryName":218,"taxonomyType":161,"taxonomyTypeDesc":162},"01M8BRASNPVNJVQQJ4KZX8XM5D","前端开发与界面实现",[220,221,222,223,224,225,34,226],"vueuse functions","functions","nuxt","https","vue","build","js",{"skillNo":228,"name":229,"nameZh":230,"description":231,"descriptionZh":232,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":233,"categories":234,"keywords":241,"publishedAt":39},"01M6CFS34MDQXZPAWQFE5D7VGT","vue-testing-best-practices","Vue.js 测试最佳实践","Use for Vue.js testing. Covers Vitest, Vue Test Utils, component testing, mocking, testing patterns, and Playwright for E2E testing.","用于 Vue.js 测试。涵盖 Vitest、Vue Test Utils、组件测试、模拟（mocking）、测试模式，以及用于 E2E 测试的 Playwright。","https:\u002F\u002Fgithub.com\u002Frockcookies\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fvuejs-ai\u002Fvue-testing-best-practices\u002FSKILL.md",[235,238],{"categoryNo":236,"categoryName":237,"taxonomyType":166,"taxonomyTypeDesc":167},"01M8BQGD5WG86P4AQ5GPSSKBFR","测试工程师",{"categoryNo":239,"categoryName":240,"taxonomyType":161,"taxonomyTypeDesc":162},"01M8BQJH394GT47X57A9Q8G7HX","测试与质量保障",[242,243,244,224,245,226,246,247,178,248,249,250,34,251,252],"vue testing best practices","testing","testing best practices","best practices","e2e testing","playwright","test","testing patterns","component","vitest","e2e",{"skillNo":254,"name":255,"nameZh":256,"description":257,"descriptionZh":258,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":259,"categories":260,"keywords":263,"publishedAt":39},"01M6CFS0N19MSJNTVM9AEQ7Z73","vue-router-best-practices","Vue Router 路由最佳实践","Vue Router 4 patterns, navigation guards, route params, and route-component lifecycle interactions.","Vue Router 4 模式、导航守卫、路由参数以及路由与组件生命周期的交互。","https:\u002F\u002Fgithub.com\u002Frockcookies\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fvuejs-ai\u002Fvue-router-best-practices\u002FSKILL.md",[261,262],{"categoryNo":214,"categoryName":215,"taxonomyType":166,"taxonomyTypeDesc":167},{"categoryNo":217,"categoryName":218,"taxonomyType":161,"taxonomyTypeDesc":162},[245,264,224,265,250,34,266,267],"vue router best practices","router","navigation","lifecycle",{"skillNo":269,"name":270,"nameZh":271,"description":272,"descriptionZh":273,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":274,"categories":275,"keywords":278,"publishedAt":39},"01M6CFRYN31RFQFTE41Z6DCGKE","vue-pinia-best-practices","Pinia 状态管理最佳实践","Pinia stores, state management patterns, store setup, and reactivity with stores.","Pinia store、状态管理模式、store 配置以及 store 的响应式处理。","https:\u002F\u002Fgithub.com\u002Frockcookies\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fvuejs-ai\u002Fvue-pinia-best-practices\u002FSKILL.md",[276,277],{"categoryNo":214,"categoryName":215,"taxonomyType":166,"taxonomyTypeDesc":167},{"categoryNo":217,"categoryName":218,"taxonomyType":161,"taxonomyTypeDesc":162},[279,245,224,280,34,281,282,283,284],"vue pinia best practices","pinia","state","state management","management","setup"]