agentleFS
muon-m2muon-m2/magento2-tools/skills/graphql/SKILL.md

graphql

Skill4 starsChanged 57 days agoMITView on GitHub

Schema-first GraphQL generation. Produces: - etc/schema.graphqls with query/mutation/type definitions - Resolver classes implementing ResolverInterface - Batch loaders implementing BatchResolverInterface (to avoid N+1) - Auth and store-scope checks - Per-resolver unit tests via test-generate - Schema-first. Decide the schema before writing resolvers. - Batch over standard for list contexts. Any resolver returning data per element of a parent list MUST use BatchResolverInterface. Standard resolvers in a list cause N+1. - Auth check on every mutation. Anonymous mutations require explicit justification. -…

16 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use ssti, sqli and 2 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • 0xGhostCATSkill

    ssti

    Hunt Server-Side Template Injection (SSTI) in Jinja2, Twig, Freemarker, Velocity, Smarty, ERB, Handlebars, Mustache, and Spring (SpEL). Use when input is reflected in a way that suggests template rendering — error pages, email templates, PDF generators, dynamic content systems.

    Also in 4 projects that use this

  • 0xGhostCATSkill

    sqli

    Hunt SQL injection in REST/GraphQL/SOAP/raw parameters using sqlmap, ghauri, manual UNION/Time/Boolean techniques, and custom WAF-bypass tamper scripts. Use when an input flows into a database query or when the user has identified a parameter that might be vulnerable.

    Also in 3 projects that use this

  • blacklanternsecuritySkill

    ssrf

    Guide server-side request forgery (SSRF) exploitation during authorized penetration testing.

    Also in 4 projects that use this

  • +1 more from 0xGhostCAT

The file

We split this skill into the rules it gives an agent

2 rules. 0 are common, 0 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 13 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Append, don't replace: When etc/schema.graphqls exists, append new types/fields rather than rewriting.

    line 29
  2. Very specific:

    Apply the shared module-hygiene baseline (required): After generating or modifying PHP files, run …

    line 83

“Common” is measured: kept by at least 6 in 10 of the 13 edited versions of this file we could read. “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

Magento 2 GraphQL Create

Schema-first GraphQL generation. Produces:

  • etc/schema.graphqls with query/mutation/type definitions
  • Resolver classes implementing ResolverInterface
  • Batch loaders implementing BatchResolverInterface (to avoid N+1)
  • Auth and store-scope checks
  • Per-resolver unit tests via test-generate

Core Rules

  • Schema-first. Decide the schema before writing resolvers.
  • Batch over standard for list contexts. Any resolver returning data per element of a parent list MUST use BatchResolverInterface. Standard resolvers in a list cause N+1.
  • Auth check on every mutation. Anonymous mutations require explicit justification.
  • Store-scope aware. Resolvers querying store-scoped data must respect the Store header via ContextInterface.
  • Append, don't replace. When etc/schema.graphqls exists, append new types/fields rather than rewriting.
  • Coding style. Generated PHP follows PER-CS 3.0 as the baseline, with the Magento 2 coding standard taking precedence on any conflict; --standard=Magento2 PHPCS is the gate. See context/references/php-coding-style.md.
  • Source of truth. Generate from templates → shared references → baked-in Magento 2 knowledge → official Magento/Adobe docs (live-fetched only when uncertain). Do NOT read, grep, or "study" other modules under app/code/vendor/*/Magento core to infer conventions, entity shapes, naming, or wiring. Narrow exceptions: the target module/class of this operation, and the specific contract of a module this code explicitly depends on. Affirm sources in the final report. See context/references/source-of-truth.md.

Workflow

Phase 0 — Context Resolution

Invoke context.

Phase 1 — Schema Plan

Ask the user:

  • Operation: query | mutation
  • Entity: what is being queried/mutated
  • Return shape: single | list | paginated
  • Auth: customer | admin | anonymous (with justification)
  • Store scope: single | store-aware | global
  • Inputs: which fields the operation accepts
  • Backing service: existing service contract, or new

Produce the schema fragment. See references/schema-patterns.md.

Phase 2 — Resolver Plan

For each operation, decide:

  • Standard resolver — one entity at a time. Use when called once per request.
  • Batch resolver — collects N IDs, returns N results. Use in list contexts to avoid N+1 (e.g. products.reviews { ... } returning reviews per product).
  • Paginated resolver — getList with SearchCriteria + currentPage/pageSize.

Present the plan. Wait for approval.

Phase 3 — Generate

  • Append schema to existing etc/schema.graphqls (create file if absent).
  • Generate resolver class(es) under Model/Resolver/.
  • For batch: generate BatchResolverInterface implementation under Model/Resolver/Batch/.
  • Wire DI in area-specific etc/graphql/di.xml.
  • Generate Test/Unit/Model/Resolver/{Name}Test.php via test-generate.

Phase 4 — Verify

  • xmllint --noout on etc/graphql/di.xml.
  • php -l on each resolver.
  • Schema validity: parse via Magento's schema parser if CLI is available.
  • Apply the shared module-hygiene baseline (required). After generating or modifying PHP files, run ${CLAUDE_PLUGIN_ROOT}/skills/context/scripts/add-license-headers.sh {ctx.magento_root}/app/code/{Vendor}/{Module} {Vendor} to stamp the standard copyright header onto every new .php (idempotent — it skips files that already carry it). When adding a composer.json require entry, resolve a bounded constraint via ${CLAUDE_PLUGIN_ROOT}/skills/context/scripts/resolve-dep-constraint.sh <vendor/package> — never "*". See context/references/module-hygiene.md.

Phase 5 — Report

Brief Markdown:

  • Operations added
  • Resolvers added (standard / batch / paginated)
  • Auth/scope decisions
  • Test coverage delta

Docs may now be stale. This change modified module code. Run docs --module={Vendor}_{Module} to refresh the module's README, CHANGELOG, and docs/*.md (technical reference, guides, and API references as applicable).

Inputs

/graphql [--module=<Vendor>_<Module>] [--operation=query|mutation] [--auth=customer|admin|anonymous]

Interactive flow drives the rest.

Outputs

{ctx.magento_root}/app/code/{Vendor}/{Module}/etc/schema.graphqls          # appended or created
{ctx.magento_root}/app/code/{Vendor}/{Module}/etc/graphql/di.xml           # created or merged
{ctx.magento_root}/app/code/{Vendor}/{Module}/Model/Resolver/...           # new files
{ctx.magento_root}/app/code/{Vendor}/{Module}/Test/Unit/Resolver/...       # new tests

Reference Files

  • references/schema-patterns.md — query, mutation, input, interface, union patterns.
  • references/resolver-patterns.md — standard + batch + paginated resolver patterns.
  • references/auth-patterns.md — @doc(category="store"), auth-check helpers.
  • references/store-scope.md — per-store handling in resolvers.
  • references/schema-migration.md — non-breaking vs breaking schema changes.
  • references/n-plus-one-prevention.md — when to use batch resolver vs eager-load.
  • context/references/source-of-truth.md — source-of-truth hierarchy + the no-unrelated-module-scanning rule (allowed reads, live-doc fetch protocol, report affirmation).

Templates

  • templates/query-resolver.php
  • templates/mutation-resolver.php
  • templates/batch-resolver.php
  • templates/paginated-resolver.php
  • templates/schema-fragment.graphqls

Acceptance Criteria

  • Schema parses (when Magento CLI is available).
  • Resolvers implement the correct interface.
  • Mutations include auth check; anonymous mutations require explicit justification.
  • Batch resolvers process N inputs in O(1) DB roundtrips.
  • Generated resolvers have at least one unit test (happy + auth-fail + input-error).

Related Skills

PhaseSkill
0context
(after Phase 3)review --diff
(after Phase 3)test-generate --types=unit
(caller)feature Phase 5 (G* tasks)
(sibling)webapi (REST / Web-API surface for the same entity)

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.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

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.