agentleFS
igmarinigmarin/rails-agent-skills/skills/implement-graphql/SKILL.md

implement-graphql

Skill26 starsChanged 4 months agoMITView on GitHub

Use when building or reviewing a graphql-ruby schema, resolver, or mutation. Trigger words: GraphQL, graphql-ruby, resolver, mutation, dataloader, schema.

The file

We split this skill into the rules it gives an agent

7 rules. About 0 are common, 3 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Very specific:

    Use this skill when designing, implementing, or reviewing GraphQL APIs in a Rails application with the graphql-ruby gem.

    line 16
  2. Very specific:

    SPEC: Write failing spec (happy path + auth + validation error case) — see TESTING.md.

    line 22
  3. Distinctive:

    IMPLEMENT: Create resolver/mutation class delegating to a service object.

    line 26
  4. Very specific:

    N+1 CHECK: Use dataloader on every association load.

    line 28
  5. Very specific:

    FINAL CHECK: Verify every item in the HARD-GATE checklist below.

    line 43
  6. Distinctive:

    RUN: Ensure the full test suite is green before PR.

    line 49
  7. Distinctive:

    Before shipping a resolver/mutation slice, ALL of the following must be confirmed:

    line 53

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Implement GraphQL

Use this skill when designing, implementing, or reviewing GraphQL APIs in a Rails application with the graphql-ruby gem.

Core Process

DO NOT proceed to step 3 before step 1 is written and failing.

  1. SPEC: Write failing spec (happy path + auth + validation error case) — see TESTING.md. Use AppSchema.execute in spec/graphql/. Never use HTTP controller dispatch for GraphQL specs.
  2. TYPE: Define arguments and return types. Use connection_type for pagination shapes. Do not leak internal model names.
  3. IMPLEMENT: Create resolver/mutation class delegating to a service object. Use dedicated classes instead of inline field blocks.
  4. N+1 CHECK: Use dataloader on every association load. For list resolvers, prime the dataloader with the records returned by the relation before fields resolve associated objects. Use bullet and db-query-matchers in specs.
    # ✅ batches loads across all records
    def buyer
      dataloader.with(Sources::RecordById, Buyer).load(object.buyer_id)
    end
  5. AUTH CHECK: Apply field-level guards where data is sensitive using Pundit or custom context guards.
    field :internal_notes, String, null: true do
      guard -> (_obj, _args, ctx) { ctx[:current_user]&.admin? }
    end
  6. FINAL CHECK: Verify every item in the HARD-GATE checklist below. Ensure mutations return { result, errors } shapes on failure.
    rescue ActiveRecord::RecordInvalid => e
      { order: nil, errors: e.record.errors.full_messages }
  7. RUN: Ensure the full test suite is green before PR.

HARD-GATE Checklist

Before shipping a resolver/mutation slice, ALL of the following must be confirmed:

  • Specs — covers happy path, unauthenticated, unauthorized, validation errors, N+1 counts, and schema limits.
  • N+1 Prevention — dataloader.with(Source, Model).load(id) on every association; never object.association.
  • Dataloader Priming — collection resolvers prime records before association fields resolve.
  • Authorization — sensitive fields have field-level guards (not type-level alone).
  • Type Conventions — paginated collections use Types::*Type.connection_type, not plain arrays.
  • Schema Safeguards — introspection disabled in production; max_depth and max_complexity set.
  • Error Handling — mutations return { result, errors } with rescue blocks; no unhandled exceptions.
  • Documentation — description: on every field in every type.
  • Resolver Structure — dedicated resolver classes, not inline field blocks.

Extended Resources (Progressive Disclosure)

Load these files only when their specific content is needed:

  • TESTING.md — For the spec template, paths, and checklist.
  • EXAMPLES.md — For detailed code examples of dataloaders, mutations, and types.

Integration

SkillWhen to chain
define-domain-languageType and field naming must match business language
plan-testsChoose first failing spec (mutation vs query vs resolver unit)
write-testsFull TDD cycle for resolvers and mutations
security-checkAuth, introspection disable, query depth/complexity limits

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.