Unlike REST APIs, GraphQL APIs provide a flexible approach to querying and mutating data through a single endpoint. They allow clients to specify exactly what data is needed, reducing over-fetching and under-fetching issues common with REST APIs. GraphQL APIs can be modified to customize requests and responses for testing and debugging. This guide provides detailed steps to achieve this using Requestly.
Modifying GraphQL Responses
In GraphQL, client interactions are typically managed through a single HTTP endpoint. The specific operation to execute is often indicated by theoperationName field in the request payload.
Example Request
Steps to Modify API Response
Set GraphQL Operation Filter
In the GraphQL Operation (Request Payload Filter) section:
-
Enter Key as
operationName. -
Enter Value as the operation name you want to target (e.g.,
getUsers).

-
The Key represents the JSON key in the request payload and supports nested paths. For example:
-
If
operationNameis located atdata.operationName, specifydata.operationName. -
For array payloads, such as
[{"operationName": "value"}], use0.operationNameas the key.
-
If
-
If the request does not include
operationName, select Resource Type as “REST API” and use Dynamic (JavaScript) Mode to filter and modify the response.
Example Without operationName
In cases where the operation is specified within the query field:
Modifying GraphQL Requests
If you need to alter the GraphQL query or its variables, use the Modify Request Body rule to change the request payload dynamically.Steps to Modify Request Body
Set GraphQL Operation Filter
In the GraphQL Operation (Request Payload Filter) section:
-
Enter Key as
operationName. -
Enter Value as the operation name you want to target (e.g.,
getUsers).














