GraphQL to REST

Examples of how to use Bi-direct to make REST API calls through a server/app that only supports GraphQL.

Bi-Direct endpoint for GraphQL to REST: https://tri-way.vercel.app/graphql

If you want to pass any data in the request body, you need to include it in the query with these keys:

  • Url: The endpoint URL of the REST API you want to use

  • Method: GET/POST

  • Data (not optional in this case): The query you want to make

Example of a GET request

Normally this is how a REST request looks like

You can try to make the same request to the given REST server:

https://jsonplaceholder.typicode.com/posts

Or you can use your desired API endpoint.

const {default:axios} = require("axios")
async function makeRequest(){
  const response = await axios.get("https://jsonplaceholder.typicode.com/posts")
console.log(response);
}
makeRequest()
Output for the above-given GET request will look something like this

Example of a GET request made using Bi-Direct

Headers

Query

Generated output for the given GET request made using Bi-Direct
Javascript code (Axios)

Example of a POST request

Normally this is how a REST request looks like

You can try to make the same request to the given REST server:

https://jsonplaceholder.typicode.com/posts

Or you can use your desired API endpoint.

Output for the above-given GET request will look something like this

Example of a POST request made using Bi-Direct

Headers

Query

Output for the above-given POST request will look something like this

Last updated