How to Override GraphQL API Query & Mutations
Abhishek Sachan
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
Abhishek Sachan
Abhishek is Growth Engineer at Requestly and has profound love for programming.
Contents
Subscribe for latest updates
Share this article
Related posts

How to use access token from another API response
Learn how to capture, store, and reuse API authentication tokens in Requestly. Simplify authentication by using environment variables and collection authorization.
Dinesh Thakur
February 24, 2025

Organized 125k APIs and improved productivity by 20% using the Requestly API Client: Cyrisma
Cyrisma improved API management with Requestly’s API client, boosting security, reducing errors, and accelerating development. Learn how they did it
Sagar Soni
February 19, 2025
How to Test FastAPI Efficiently with Requestly API Client
Learn how to test FastAPI APIs with Requestly API Client for easy debugging, request modifications, and automation. Take control over your API testing workflow!
Dinesh Thakur
February 13, 2025