Override GraphQL API Responses using Modify Response Rule

Requestly
Requestly
Published in
1 min readMar 14, 2024

--

Frontend developers frequently need to test their code with variations in responses. To override the response, you can use the Modify Response Rule. For example, assume you have a GraphQL query to fetch a list of articles for a blogging website like medium.com. You may need to modify the response of ListArticles GraphQL API to test features like displaying only two categories at a time and handling large title lengths or small excerpts.

Video Guide

Step by Step Guide

Follow the steps below to override the GraphQL API response.

  1. Start by creating a new Modify API Response Rule.
  2. Select the Resource Type as GraphQL API.
  3. Use your API’s hostname and path as source conditions like — company.com/api/graphql
  4. GraphQL enables an additional filter to identify queries by operation name or query. In the Key field, enter the operation name’s path, such as 0.operationName. Choose Equals for exact matches or Contains for broader searches. Enter the operation name in the value field.
  5. In the status code, select the status codes like 4xx, 5xx, etc.
  6. In Response Body, you can select from Static or Dynamic response body as per your requirement.
  7. Save the Rule & Test.

--

--

Requestly
Requestly

Setup redirects, modify headers, switch hosts, insert user scripts and much more. Install it on Chrome & Firefox and join our family of more than 100,000 devs!