filmov
tv
Modify API Response Rule | HTTP Rules | Modify GraphQL API Response

Показать описание
The Modify Response Rule enables you to modify the response body of an HTTP request. The rule is equally important for developers and testers. Frontend developers can reduce their dependence on the backend by mocking the response they want from an API. Testers can test different edge cases by directly modifying API responses.
Use Cases
---
Test Frontend without Backend API: Agile teams often face a situation where they have to develop front-end code while back-end development is also in progress. In these scenarios, developing with API Contracts is easier with a way to mock the API responses. Developers either hard-code these mocks or use an external mock server for the same, which comes with its challenges. Modify Response Rule comes in handy when you have to mock an API’s response & status code. Requestly works outside your code base, and hence no need to make any changes to the codebase; it easily overrides responses.
Simulate Errors: During testing and development you often face a situation where you want to test your feature in case of API Error, simulating some errors can be tricky on backends. Modify Response rule can help you simulate any kind of response you want for an API, such as a Bad Request, Unauthorized, Internal Server Error, Different Payload, etc.
Test Local API Changes on the Prod Frontend: It's a common requirement during development to keep the APIs backward compatible. In scenarios where backend developers have to make minor changes to the response body, the only way is to check the front-end code. With the Modify Response rule, you can easily modify the response of a production API to the new response and see if the production front-end can handle it.
GraphQL API Changes: GraphQL generally works with operations passed as a request body instead of using a different path for each resource on the server. Debugging tools created for REST APIs cannot generally target GraphQL APIs. Requestly comes with exclusive support for GraphQL APIs. In scenarios where you want to mock a change in the model of a GraphQL API, you can modify the response of that API by using an operations filter.
Important Links
---
Use Cases
---
Test Frontend without Backend API: Agile teams often face a situation where they have to develop front-end code while back-end development is also in progress. In these scenarios, developing with API Contracts is easier with a way to mock the API responses. Developers either hard-code these mocks or use an external mock server for the same, which comes with its challenges. Modify Response Rule comes in handy when you have to mock an API’s response & status code. Requestly works outside your code base, and hence no need to make any changes to the codebase; it easily overrides responses.
Simulate Errors: During testing and development you often face a situation where you want to test your feature in case of API Error, simulating some errors can be tricky on backends. Modify Response rule can help you simulate any kind of response you want for an API, such as a Bad Request, Unauthorized, Internal Server Error, Different Payload, etc.
Test Local API Changes on the Prod Frontend: It's a common requirement during development to keep the APIs backward compatible. In scenarios where backend developers have to make minor changes to the response body, the only way is to check the front-end code. With the Modify Response rule, you can easily modify the response of a production API to the new response and see if the production front-end can handle it.
GraphQL API Changes: GraphQL generally works with operations passed as a request body instead of using a different path for each resource on the server. Debugging tools created for REST APIs cannot generally target GraphQL APIs. Requestly comes with exclusive support for GraphQL APIs. In scenarios where you want to mock a change in the model of a GraphQL API, you can modify the response of that API by using an operations filter.
Important Links
---