🎉 Requestly joins BrowserStack to build the future of application testing. Read more

How to Override GraphQL API Query & Mutations

Sagar Soni
Learn how to override GraphQL API queries and mutations using Requestly. Modify request bodies programmatically for testing and development. Read now!
Load Production GraphQL APIs on Local or Staging Frontends

Why Modify GraphQL Requests?

GraphQL is powerful but often tricky during debugging or testing because:

  • All operations hit a single endpoint via POST.

  • Query, variables, and operationName live in the request body—not in the URL.

Traditional URL-based interception fails here. Requestly solves this by allowing body-level interception with GraphQL-specific filtering.

You can:

  • Test pagination by changing first or limit values.

  • Toggle feature flags in queries.

  • Swap schemas or inject new fields for UI testing.

  • Simulate edge cases without redeploying.


Steps to Override GraphQL Requests in Requestly

1. Create a Modify Request Body Rule

  • Go to HTTP Rules in Requestly.

  • Click + New RuleModify Request Body.

2. Configure Source Conditions

  • Enter your GraphQL API endpoint, e.g., company.com/api/graphql.

  • Most GraphQL requests use POST, so include method filters if needed.

3. Select GraphQL As Resource Type

  • In Request Body options, choose GraphQL API as the resource type.

  • Use the operationName filter to target a specific query or mutation, e.g., ListArticles.

4. Customize the Request

  • For static changes: Paste the full modified payload.

  • For dynamic changes: Use Programmatic mode and write custom JS.


Video Tutorial

Test Your Rule

  • Save and enable the rule.

  • Reload your app and check DevTools → Network tab.

  • Confirm the modified payload in Live Traffic inside Requestly.


Bonus: Combine with Other Features

  • Use Redirect/Map Remote to hit staging or production APIs from local.

  • Pair with Modify Response Body for full request-response simulation.


Why This Matters

Modern apps rely heavily on GraphQL. Being able to intercept and modify GraphQL requests in-flight gives developers and QA teams flexibility without touching server code. Requestly makes this simple with GraphQL-specific capabilities.

Next Steps:

Written by
Sagar Soni
Sagar is the co-founder and CTO of Requestly (recently acquired by BrowserStack). With over 8 years of experience in software development and entrepreneurship, he’s passionate about building innovative tools that solve real-world problems. From architecting scalable web applications to leading cross-functional teams, Sagar has worn many hats throughout his journey from technical implementation to business strategy. Always looking for the next challenge to tackle.

Related posts