How to Override GraphQL API Query & Mutations
Sagar Soni
February 18, 2025
Learn how to override GraphQL API queries and mutations using Requestly. Modify request bodies programmatically for testing and development. Read now!

Once you understand how to debug and override GraphQL API using Requestly. You might want to explore how you can use Requestly in different scenarios of your development cycle(SDLC). Let’s explore how modifying the request body can help.
If you need to override the request body for a GraphQL API. For scenarios where you need to switch models or modify fields in a query, use the programmatic option in the request body rule to selectively modify GraphQL requests.
Video Tutorial
Steps to Configure Rule
Follow the below steps to override API Requests.
- Create a new Modify Request Rule.
- Use your API hostname & path as source conditions like –
company.com/api/graphql
- Under Request Body select
Programmatic
- We can filter and modify the request using the below code. Make sure you replace
[modified query]
with your query. - Save the rule and test.
function modifyRequestBody(args) {
const { method, url, body, bodyAsJson } = args;
if(bodyAsJson[0].operationName = 'ListArticles'){
bodyAsJson[0].query = '[modified query]'
}
return body;
}
Further Reading
Written by
Sagar Soni
Sagar is the co-founder and CTO of Requestly. When he’s not busy architecting the next big thing in software development, you’ll likely find him behind the wheel, cruising the streets and enjoying the thrill of the drive. For Sagar, it’s all about the code by day and the open road by night.
Contents
Subscribe for latest updates
Share this article
Related posts

Four Years On, Requestly Still Drives OpenWeb’s QA Efficiency
OpenWeb boosts QA efficiency with Requestly Workspaces—enabling safe, fast testing across clusters, bundles, and environments without code changes.
Akanksha Bhadauria
June 9, 2025

Free HTTP Header Modification Tool in 2025
Discover the best free HTTP header modification tool in 2025. Easily add, remove, or override headers for debugging, testing, and development.
Kanishk Rawat
June 5, 2025

How to Change Your IP Address Using Requestly
Learn how to change or spoof your IP address using the X-Forwarded-For header with Requestly. Step-by-step guide for developers to simulate client IPs easily
Dinesh Thakur
June 1, 2025