How to Override GraphQL API Responses

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 response can help.

Frontend developers frequently need to test their code with variations in API 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 excepts.

Video Tutorial

Steps to Create

Follow the steps below to override the response of this API.

  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. Under GraphQL Operations 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. You can also target other parts of the request body(JSON-based).
  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.

Further Reading

Learn How to override GraphQL API queries & mutations

Share this article:

Subscribe to our weekly newsletter !

Join 10k developers and QAs to get weekly updates with Requestly's newsletter.​

This article was written by:

Picture of Abhishek Sachan

Abhishek Sachan

Abhishek is Growth Engineer at Requestly and has profound love for programming.

Join 10k developers and get weekly updates with Requestly's newsletter.

Contents