Skip to content
v1.0.0

Mocks

Creating a replace rule for MockMe in the Mocks view, then triggering requests on the page and seeing one mocked while another is not. Narrated, with sound. The dark and light versions follow the site's theme.

The Mocks view (DevTools only, Alt + 3) changes what the inspected page receives for its GraphQL HTTP requests. Rules are stored per origin and listed in priority order: the first enabled rule that matches wins. The Mocks enabled switch turns every rule off at once.

A rule matches on:

  • a URL pattern (empty = any URL, * matches any text, otherwise a substring),
  • an optional operation name,
  • an optional variable condition (user.id exists, or equals a JSON value).
Action What the page gets
Replace response Your JSON (and status). The request never leaves the page.
Patch response The real request runs and your JSON is merged into its response (JSON Merge Patch: objects merge, null removes a key, anything else replaces).
Delay request The real request, sent after N ms.
Fail with an error A GraphQL error response with your message and status, or with Network failure, a failed request as if the network were down.
Pass through Matching requests are left alone and no later rule is tried.
  • Mocks apply only while DevTools is open on that tab. Closing it stops every mock. Reload the page to mock requests it makes while loading.
  • Batches, multipart uploads, WebSockets and anything that isn’t GraphQL are never mocked.
  • While mocks are active, rules (including mocked response bodies) are handed to the page’s own hook through a window message, so scripts running on that page could read them. Keep mock data free of secrets.
  • A Mocks on · N chip shows next to the view switch whenever a rule can change a response. Mocked rows in Traffic carry a MOCKED chip and a banner naming the rule. The page’s console logs each mocked request.
  • Mock this response in a Traffic row’s detail starts a rule from that response. Nothing is active until you save it and the master switch is on.

Palette commands: Show Mocks, Toggle mocks on/off, New mock rule, Disable all mock rules.