[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7DFH1TH0TY2ZHGW23J5TRHP":3,"skill-same:01M7DFH1TH0TY2ZHGW23J5TRHP":79},{"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":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":39,"commitSha":40,"skillDirectory":41,"forksCount":14,"repositoryHtmlUrl":42,"repositoryHomepageUrl":6,"ownerHtmlUrl":43,"ownerBlogUrl":44,"ownerDescription":45,"updatedAt":46,"install":47,"resources":60},"01M7DFH1TH0TY2ZHGW23J5TRHP","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`.","heynemann\u002Fomp-marketplace","heynemann","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F60965?v=4","01M7DFBD9ZDB2J2QE7R4AR0PES","Bernardo Heynemann","01M7DFBDAM3NXF540P210W3NYT",0,"MIT","https:\u002F\u002Fgithub.com\u002Fheynemann\u002Fomp-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fbase\u002Fskills\u002Fgolang-graphql\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: golang-graphql\ndescription: \"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`.\"\nuser-invocable: false\nlicense: MIT\ncompatibility: Designed for Claude Code, Codex or similar harness, and for projects using Golang.\nmetadata:\n  author: samber\n  version: \"0.2.2\"\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: 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__*\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 `samber\u002Fcc-skills-golang@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:\n\n- For Go package docs, symbols, versions, importers, and known vulnerabilities, → See `samber\u002Fcc-skills-golang@golang-pkg-go-dev` skill (`godig`), preferred over Context7 for Go package facts.\n- To navigate this library's usage in your own code (definitions, call sites, diagnostics), → See `samber\u002Fcc-skills-golang@golang-gopls` skill (`gopls`).\n- 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 `samber\u002Fcc-skills-golang@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 `samber\u002Fcc-skills-golang@golang-context` skill for context propagation in resolvers and subscriptions\n- → See `samber\u002Fcc-skills-golang@golang-error-handling` skill for error wrapping and sentinel patterns\n- → See `samber\u002Fcc-skills-golang@golang-testing` skill for table-driven and integration test patterns\n- → See `samber\u002Fcc-skills-golang@golang-observability` skill for tracing and metrics in resolvers\n- → See `samber\u002Fcc-skills-golang@golang-security` skill for input validation and injection prevention\n- → See `samber\u002Fcc-skills-golang@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 `samber\u002Fcc-skills-golang@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:\n\n- For Go package docs, symbols, versions, importers, and known vulnerabilities, → See `samber\u002Fcc-skills-golang@golang-pkg-go-dev` skill (`godig`), preferred over Context7 for Go package facts.\n- To navigate this library's usage in your own code (definitions, call sites, diagnostics), → See `samber\u002Fcc-skills-golang@golang-gopls` skill (`gopls`).\n- 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 `samber\u002Fcc-skills-golang@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 `samber\u002Fcc-skills-golang@golang-context` skill for context propagation in resolvers and subscriptions\n- → See `samber\u002Fcc-skills-golang@golang-error-handling` skill for error wrapping and sentinel patterns\n- → See `samber\u002Fcc-skills-golang@golang-testing` skill for table-driven and integration test patterns\n- → See `samber\u002Fcc-skills-golang@golang-observability` skill for tracing and metrics in resolvers\n- → See `samber\u002Fcc-skills-golang@golang-security` skill for input validation and injection prevention\n- → See `samber\u002Fcc-skills-golang@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":24,"license":15,"metadata":26,"description":7,"allowed-tools":37,"compatibility":38,"user-invocable":20},[25],"**\u002F*.go",{"author":27,"version":28,"openclaw":29},"samber","0.2.2",{"emoji":30,"install":31,"homepage":32,"requires":33,"skill-library-version":36},"🔮",[],"https:\u002F\u002Fgithub.com\u002Fsamber\u002Fcc-skills-golang",{"bins":34},[35],"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","2147d79c9cd764770418b462c29634bcdc710096","plugins\u002Fbase\u002Fskills\u002Fgolang-graphql","https:\u002F\u002Fgithub.com\u002Fheynemann\u002Fomp-marketplace","https:\u002F\u002Fgithub.com\u002Fheynemann","http:\u002F\u002Fwww.thumbor.org","CTO @ Flutter Brazil | Former Meta & Coinbase","2026-09-29 21:26:05",{"source":8,"skillName":5,"commands":48,"prompt":58,"zipAvailable":59},[49,52,55],{"tool":50,"command":51},"npx","npx skills add heynemann\u002Fomp-marketplace --skill golang-graphql",{"tool":53,"command":54},"bunx","bunx skills add heynemann\u002Fomp-marketplace --skill golang-graphql",{"tool":56,"command":57},"pnpm","pnpm dlx skills add heynemann\u002Fomp-marketplace --skill golang-graphql","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fheynemann\u002Fomp-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fbase\u002Fskills\u002Fgolang-graphql\u002FSKILL.md",true,[61,67,71,75],{"path":62,"resourceType":63,"resourceTypeDesc":64,"sizeBytes":65,"sourceHtmlUrl":66},"evals\u002Fevals.json","REFERENCE","参考文档",11727,"https:\u002F\u002Fgithub.com\u002Fheynemann\u002Fomp-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fbase\u002Fskills\u002Fgolang-graphql\u002Fevals\u002Fevals.json",{"path":68,"resourceType":63,"resourceTypeDesc":64,"sizeBytes":69,"sourceHtmlUrl":70},"references\u002Fgqlgen.md",7957,"https:\u002F\u002Fgithub.com\u002Fheynemann\u002Fomp-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fbase\u002Fskills\u002Fgolang-graphql\u002Freferences\u002Fgqlgen.md",{"path":72,"resourceType":63,"resourceTypeDesc":64,"sizeBytes":73,"sourceHtmlUrl":74},"references\u002Fgraphql-go.md",7783,"https:\u002F\u002Fgithub.com\u002Fheynemann\u002Fomp-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fbase\u002Fskills\u002Fgolang-graphql\u002Freferences\u002Fgraphql-go.md",{"path":76,"resourceType":63,"resourceTypeDesc":64,"sizeBytes":77,"sourceHtmlUrl":78},"references\u002Ftesting.md",5472,"https:\u002F\u002Fgithub.com\u002Fheynemann\u002Fomp-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fbase\u002Fskills\u002Fgolang-graphql\u002Freferences\u002Ftesting.md",[80,87,94,101,108,115],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":19},"01M7DFXDYP0N6P8KR0AF7C0TDK","writing-for-agents","Writing documents for agents. Use when creating or editing skills, or modifying AGENTS.md or CLAUDE.md.","https:\u002F\u002Fgithub.com\u002Fheynemann\u002Fomp-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fbase\u002Fskills\u002Fwriting-for-agents\u002FSKILL.md",[],[],{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":19},"01M7DFX9C5B0T1T0AVDCWNR5P2","write-skill","Use when creating, designing, or fixing an agent skill (SKILL.md pack) — triggers include \"write a skill\", \"make me a skill\", \"create a skill\", skill directories, and skills that fail to trigger or fire on the wrong tasks.","https:\u002F\u002Fgithub.com\u002Fheynemann\u002Fomp-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fbase\u002Fskills\u002Fwrite-skill\u002FSKILL.md",[],[],{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":100,"publishedAt":19},"01M7DFX64VSTQV0CSGYR76MPZF","write-agent","Use when creating, designing, or fixing an omp subagent (task agent) — triggers include \"write an agent\", \"make me an agent\", \"create a subagent\", agent `.md` definitions, and agents that misbehave when spawned via task.","https:\u002F\u002Fgithub.com\u002Fheynemann\u002Fomp-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fbase\u002Fskills\u002Fwrite-agent\u002FSKILL.md",[],[],{"skillNo":102,"name":103,"nameZh":6,"description":104,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":105,"categories":106,"keywords":107,"publishedAt":19},"01M7DFX22JEY7ZN9EDESM732K5","wizard","Generate an interactive bash wizard that walks a human through steps only they can perform. Use when provisioning infrastructure, setting up credentials or CI secrets, walking an unfamiliar third-party dashboard, or running a one-off migration or cutover. Don't invoke this for steps the agent can perform itself.","https:\u002F\u002Fgithub.com\u002Fheynemann\u002Fomp-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fbase\u002Fskills\u002Fwizard\u002FSKILL.md",[],[],{"skillNo":109,"name":110,"nameZh":6,"description":111,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":112,"categories":113,"keywords":114,"publishedAt":19},"01M7DFWYXR5V2CY2BPDAAS19R1","wayfinder","Plan a huge chunk of work (more than one agent session can hold) as a shared map of decision tickets on your issue tracker, and resolve them one at a time until the way to the destination is clear.","https:\u002F\u002Fgithub.com\u002Fheynemann\u002Fomp-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fbase\u002Fskills\u002Fwayfinder\u002FSKILL.md",[],[],{"skillNo":116,"name":117,"nameZh":6,"description":118,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":119,"categories":120,"keywords":121,"publishedAt":19},"01M7DFWXFFMBKV294WS66S475V","wait-what","Stop. That last message did not land: re-pitch it.","https:\u002F\u002Fgithub.com\u002Fheynemann\u002Fomp-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fbase\u002Fskills\u002Fwait-what\u002FSKILL.md",[],[]]