[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71N8DRMJF0567DN7AXS8JZF":3,"skill-same:01M71N8DRMJF0567DN7AXS8JZF":101},{"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":23,"publishedAt":44,"linkOnly":45,"markdownContent":46,"markdownBody":47,"frontMatter":48,"refName":62,"commitSha":63,"skillDirectory":64,"forksCount":14,"repositoryHtmlUrl":65,"repositoryHomepageUrl":66,"ownerHtmlUrl":67,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":68,"install":69,"resources":82},"01M71N8DRMJF0567DN7AXS8JZF","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`.","pattanation\u002FNorvik","pattanation","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F235419268?v=4","01M71M5THHYYB15ME8R2E4FCZG","Patta","01M71M5TJM1NDM992M8PDKYR2K",0,"MIT","https:\u002F\u002Fgithub.com\u002Fpattanation\u002FNorvik\u002Fblob\u002Fclaude\u002Finstall-gsd-build-foQdV\u002F.agents\u002Fskills\u002Fgolang-graphql\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43],"GraphQL","golang","golang graphql","cc","edit","write","read","context7","imports","gopls","code","Bash","query","when","false","writing","MCP","lsp","projects","ai coding agents","2026-11-10 10:56:23",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 or similar AI coding agents, and for projects using Golang.\nmetadata:\n  author: samber\n  version: \"0.1.1\"\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__*\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. For Go package docs, symbols, versions, importers, and known vulnerabilities, → See `samber\u002Fcc-skills-golang@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 `samber\u002Fcc-skills-golang@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 `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. For Go package docs, symbols, versions, importers, and known vulnerabilities, → See `samber\u002Fcc-skills-golang@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 `samber\u002Fcc-skills-golang@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 `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,"license":15,"metadata":49,"description":7,"allowed-tools":60,"compatibility":61,"user-invocable":45},{"author":50,"version":51,"openclaw":52},"samber","0.1.1",{"emoji":53,"install":54,"homepage":55,"requires":56,"skill-library-version":59},"🔮",[],"https:\u002F\u002Fgithub.com\u002Fsamber\u002Fcc-skills-golang",{"bins":57},[58],"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 or similar AI coding agents, and for projects using Golang.","claude\u002Finstall-gsd-build-foQdV","d86cd127f527124b5fd0fd0bc679a4d79b7d01d7",".agents\u002Fskills\u002Fgolang-graphql","https:\u002F\u002Fgithub.com\u002Fpattanation\u002FNorvik","https:\u002F\u002Fnorvik-orpin.vercel.app","https:\u002F\u002Fgithub.com\u002Fpattanation","2026-07-17 11:17:04",{"source":8,"skillName":5,"commands":70,"prompt":80,"zipAvailable":81},[71,74,77],{"tool":72,"command":73},"npx","npx skills add pattanation\u002FNorvik --skill golang-graphql",{"tool":75,"command":76},"bunx","bunx skills add pattanation\u002FNorvik --skill golang-graphql",{"tool":78,"command":79},"pnpm","pnpm dlx skills add pattanation\u002FNorvik --skill golang-graphql","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fpattanation\u002FNorvik\u002Fblob\u002Fclaude\u002Finstall-gsd-build-foQdV\u002F.agents\u002Fskills\u002Fgolang-graphql\u002FSKILL.md",true,[83,89,93,97],{"path":84,"resourceType":85,"resourceTypeDesc":86,"sizeBytes":87,"sourceHtmlUrl":88},"evals\u002Fevals.json","REFERENCE","参考文档",11727,"https:\u002F\u002Fgithub.com\u002Fpattanation\u002FNorvik\u002Fblob\u002Fclaude\u002Finstall-gsd-build-foQdV\u002F.agents\u002Fskills\u002Fgolang-graphql\u002Fevals\u002Fevals.json",{"path":90,"resourceType":85,"resourceTypeDesc":86,"sizeBytes":91,"sourceHtmlUrl":92},"references\u002Fgqlgen.md",7477,"https:\u002F\u002Fgithub.com\u002Fpattanation\u002FNorvik\u002Fblob\u002Fclaude\u002Finstall-gsd-build-foQdV\u002F.agents\u002Fskills\u002Fgolang-graphql\u002Freferences\u002Fgqlgen.md",{"path":94,"resourceType":85,"resourceTypeDesc":86,"sizeBytes":95,"sourceHtmlUrl":96},"references\u002Fgraphql-go.md",7218,"https:\u002F\u002Fgithub.com\u002Fpattanation\u002FNorvik\u002Fblob\u002Fclaude\u002Finstall-gsd-build-foQdV\u002F.agents\u002Fskills\u002Fgolang-graphql\u002Freferences\u002Fgraphql-go.md",{"path":98,"resourceType":85,"resourceTypeDesc":86,"sizeBytes":99,"sourceHtmlUrl":100},"references\u002Ftesting.md",5023,"https:\u002F\u002Fgithub.com\u002Fpattanation\u002FNorvik\u002Fblob\u002Fclaude\u002Finstall-gsd-build-foQdV\u002F.agents\u002Fskills\u002Fgolang-graphql\u002Freferences\u002Ftesting.md",[102,135,161,184,206,221],{"skillNo":103,"name":104,"nameZh":6,"description":105,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":106,"licenseFileUrl":107,"sourceHtmlUrl":108,"categories":109,"keywords":116,"publishedAt":134},"01M71QDV4DM8T19HEHWATEF1K4","webapp-testing","Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fpattanation\u002FNorvik\u002Fblob\u002Fclaude\u002Finstall-gsd-build-foQdV\u002F.agents\u002Fskills\u002Fwebapp-testing\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fpattanation\u002FNorvik\u002Fblob\u002Fclaude\u002Finstall-gsd-build-foQdV\u002F.agents\u002Fskills\u002Fwebapp-testing\u002FSKILL.md",[110,113],{"categoryNo":111,"categoryName":112,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000008","测试与质量",{"categoryNo":114,"categoryName":115,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000009","前端开发",[117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133],"webapp","testing","webapp testing","for","applications","local","frontend","debugging","toolkit","logs","browser","with","playwright","web","behavior","ui","screenshots","2026-11-10 13:02:02",{"skillNo":136,"name":137,"nameZh":6,"description":138,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":106,"licenseFileUrl":139,"sourceHtmlUrl":140,"categories":141,"keywords":143,"publishedAt":134},"01M71QDH2GGMXGA9105C9W1N7B","web-artifacts-builder","Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn\u002Fui). Use for complex artifacts requiring state management, routing, or shadcn\u002Fui components - not for simple single-file HTML\u002FJSX artifacts.","https:\u002F\u002Fgithub.com\u002Fpattanation\u002FNorvik\u002Fblob\u002Fclaude\u002Finstall-gsd-build-foQdV\u002F.agents\u002Fskills\u002Fweb-artifacts-builder\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fpattanation\u002FNorvik\u002Fblob\u002Fclaude\u002Finstall-gsd-build-foQdV\u002F.agents\u002Fskills\u002Fweb-artifacts-builder\u002FSKILL.md",[142],{"categoryNo":114,"categoryName":115,"taxonomyType":21,"taxonomyTypeDesc":22},[144,145,146,130,147,148,149,120,150,151,123,152,153,154,155,156,157,158,159,160],"builder","artifacts builder","artifacts","web artifacts builder","single-file","css","Tailwind","ui components","single","use","file","components","react","multi","state","routing","state management",{"skillNo":162,"name":163,"nameZh":6,"description":164,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":165,"sourceHtmlUrl":166,"categories":167,"keywords":169,"publishedAt":134},"01M71QD9T2XC3EWMQNN9ACNWQ1","vueuse-functions","Apply VueUse composables where appropriate to build concise, maintainable Vue.js \u002F Nuxt features.","https:\u002F\u002Fgithub.com\u002Fpattanation\u002FNorvik\u002Fblob\u002Fclaude\u002Finstall-gsd-build-foQdV\u002F.agents\u002Fskills\u002Fvueuse-functions\u002FLICENSE.md","https:\u002F\u002Fgithub.com\u002Fpattanation\u002FNorvik\u002Fblob\u002Fclaude\u002Finstall-gsd-build-foQdV\u002F.agents\u002Fskills\u002Fvueuse-functions\u002FSKILL.md",[168],{"categoryNo":114,"categoryName":115,"taxonomyType":21,"taxonomyTypeDesc":22},[170,171,172,173,174,175,176,177,178,179,180,181,182,183],"functions","vueuse","vueuse functions","project","nuxt","apply","github","concise","build","https","features","vue","js","composables",{"skillNo":185,"name":186,"nameZh":6,"description":187,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":188,"sourceHtmlUrl":189,"categories":190,"keywords":193,"publishedAt":134},"01M71QD51HWSGYMCMB7RW7PGK8","vue-testing-best-practices","Use for Vue.js testing. Covers Vitest, Vue Test Utils, component testing, mocking, testing patterns, and Playwright for E2E testing.","https:\u002F\u002Fgithub.com\u002Fpattanation\u002FNorvik\u002Fblob\u002Fclaude\u002Finstall-gsd-build-foQdV\u002F.agents\u002Fskills\u002Fvue-testing-best-practices\u002FLICENSE.md","https:\u002F\u002Fgithub.com\u002Fpattanation\u002FNorvik\u002Fblob\u002Fclaude\u002Finstall-gsd-build-foQdV\u002F.agents\u002Fskills\u002Fvue-testing-best-practices\u002FSKILL.md",[191,192],{"categoryNo":111,"categoryName":112,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":114,"categoryName":115,"taxonomyType":21,"taxonomyTypeDesc":22},[194,118,195,181,196,129,197,198,199,176,200,120,201,202,203,153,204,182,205],"vue testing best practices","testing best practices","best practices","test","testing patterns","component","vitest","mocking","e2e","utils","patterns","e2e testing",{"skillNo":207,"name":208,"nameZh":6,"description":209,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":210,"sourceHtmlUrl":211,"categories":212,"keywords":214,"publishedAt":134},"01M71QD358H2DJ9THJRBP77T3T","vue-router-best-practices","Vue Router 4 patterns, navigation guards, route params, and route-component lifecycle interactions.","https:\u002F\u002Fgithub.com\u002Fpattanation\u002FNorvik\u002Fblob\u002Fclaude\u002Finstall-gsd-build-foQdV\u002F.agents\u002Fskills\u002Fvue-router-best-practices\u002FLICENSE.md","https:\u002F\u002Fgithub.com\u002Fpattanation\u002FNorvik\u002Fblob\u002Fclaude\u002Finstall-gsd-build-foQdV\u002F.agents\u002Fskills\u002Fvue-router-best-practices\u002FSKILL.md",[213],{"categoryNo":114,"categoryName":115,"taxonomyType":21,"taxonomyTypeDesc":22},[215,181,216,196,217,199,218,176,204,219,220],"router","vue router best practices","route","guards","navigation","lifecycle",{"skillNo":222,"name":223,"nameZh":6,"description":224,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":225,"sourceHtmlUrl":226,"categories":227,"keywords":229,"publishedAt":134},"01M71QCYPNWDE2MQZ1TF3ED5S4","vue-best-practices","MUST be used for Vue.js tasks. Strongly recommends Composition API with `\u003Cscript setup>` and TypeScript as the standard approach. Covers Vue 3, SSR, Volar, vue-tsc. Load for any Vue, .vue files, Vue Router, Pinia, or Vite with Vue work. ALWAYS use Composition API unless the project explicitly requires Options API.","https:\u002F\u002Fgithub.com\u002Fpattanation\u002FNorvik\u002Fblob\u002Fclaude\u002Finstall-gsd-build-foQdV\u002F.agents\u002Fskills\u002Fvue-best-practices\u002FLICENSE.md","https:\u002F\u002Fgithub.com\u002Fpattanation\u002FNorvik\u002Fblob\u002Fclaude\u002Finstall-gsd-build-foQdV\u002F.agents\u002Fskills\u002Fvue-best-practices\u002FSKILL.md",[228],{"categoryNo":114,"categoryName":115,"taxonomyType":21,"taxonomyTypeDesc":22},[230,181,196,231,173,232,233,234,215,235,236,237,238,239,240,120,241,153,242,243],"vue best practices","Composition","files","tasks","api","pinia","work","options","ssr","typescript","as","vite","load","standard"]