π Chrome extension to capture, edit, and mock GraphQL responses in real-time
- πΈ Capture GraphQL Responses - Automatically intercepts and captures all GraphQL requests and responses
- βοΈ Edit Responses - Intuitive JSON editor with tree view and inline editing
- π Mock Responses - Activate custom responses to test edge cases without backend changes
- β±οΈ Response Delay - Simulate network latency by adding custom delays (0ms~)
- π Boolean Dropdown - Edit boolean values easily with true/false dropdown selector
- ποΈ Global Toggle - Enable/disable all mocking with a single click
- π Search & Filter - Quickly find operations and search through JSON data
- πͺ Separate Window - Open a larger editor window for complex data editing
- πΎ Auto-Save & Activate - Save changes and automatically activate mocking in one click
Coming soon!
- Clone this repository
git clone https://github.com/wtdlee/graphql-mocker.git
cd graphql-mocker- Install dependencies
yarn install- Build the extension
yarn build- Load the extension in Chrome
- Open
chrome://extensions - Enable "Developer mode"
- Click "Load unpacked"
- Select the
distfolder
- Open
Mock error responses, empty states, or extreme data without touching your backend:
{
"data": {
"user": null
},
"errors": [
{
"message": "User not found",
"extensions": { "code": "NOT_FOUND" }
}
]
}Continue developing your frontend even when the backend API is not ready or unstable.
Quickly test different scenarios without setting up complex backend states:
- Empty lists
- Maximum items
- Various error states
- Loading states
- Permission denied scenarios
Show different states of your application during demos without complex setup.
βββββββββββββββ
β Web Page β
β (GraphQL) β
ββββββββ¬βββββββ
β 1. Intercept (fetch/XHR monkey patch)
βΌ
βββββββββββββββ
β appHook.js β β Injected into page context
ββββββββ¬βββββββ
β 2. window.postMessage
βΌ
βββββββββββββββ
β content.js β β Content script (bridge)
ββββββββ¬βββββββ
β 3. chrome.runtime.connect
βΌ
βββββββββββββββ
βbackground.jsβ β Service worker (state manager)
ββββββββ¬βββββββ
β 4. Storage & sync
βΌ
βββββββββββββββ
β Popup UI β β React UI
βββββββββββββββ
- Monkey Patching: Overrides native
window.fetchandXMLHttpRequestto intercept GraphQL requests - Message Passing: Uses
window.postMessageandchrome.runtime.connectto communicate between contexts - Response Mocking: Returns custom
Responseobjects or modifies XHR properties to simulate API responses - Conditional Override: Only mocks responses when explicitly activated by the user
- Node.js >= 16
- Yarn
# Install dependencies
yarn install
# Development build with watch mode
yarn dev
# Production build
yarn build
# Run linter
yarn lint
# Run tests
yarn testgraphql-mocker/
βββ src/
β βββ app/
β β βββ appHook.ts # GraphQL interception logic
β β βββ content.ts # Content script (bridge)
β β βββ background.ts # Background service worker
β β βββ store.ts # State management
β βββ ui/
β β βββ app.tsx # Root component
β β βββ popup.tsx # Popup entry point
β β βββ components/
β β βββ GraphQLList.tsx
β β βββ GraphQLEditorWindow.tsx
β β βββ JSONEditor.tsx
β βββ type/
β βββ type.ts # TypeScript definitions
βββ dist/ # Build output
βββ webpack.config.js
βββ manifest.json # Chrome extension manifest
- Open the extension - Click the GraphQL Mocker icon in your toolbar
- Navigate to your app - Visit any page that makes GraphQL requests
- View captured operations - Operations will appear automatically in the extension popup
- Edit a response:
- Click on an operation to expand it
- Click "Edit Custom" or "Open in Window" to modify the response
- Make your changes in the JSON editor (click values to edit inline)
- For boolean values, use the dropdown to select true/false
- Optionally set a response delay to simulate network latency
- Click "Save & Activate" - response is saved and automatically activated
- Reload the page - Your custom response will be returned instead of the real API response
- Global Toggle (ON/OFF) - Master switch to enable/disable all mocking at once
- Clear All - Remove all captured responses and custom mocks
For complex responses, click "Open in Window" to get a larger editing area with search functionality. Changes are saved and activated automatically when you click "Save & Activate".
Add custom delays to simulate slow network conditions or loading states:
- Set delay in milliseconds (e.g., 500ms, 2000ms)
- Even 0ms is displayed clearly for consistency
Boolean fields show a dropdown selector instead of text input:
- Click on any boolean value to see true/false options
- Changes are tracked and can be reset to original
In the separate window, use the search box to find specific keys or values in large responses.
Click the "Reset" button next to any modified field to restore its original value.
Click "Delete Custom" to remove your modifications and return to the original response.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by the need for better GraphQL testing tools
- Built with React, TypeScript, and Chrome Extension APIs
- π Report a bug
- π‘ Request a feature
- β Ask a question
Made with β€οΈ by wtdlee
