REST to GraphQL

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

Bi-Direct endpoint for REST to SOAP: https://tri-way.vercel.app/resttographql

Just like a REST to SOAP API call if you want to pass any data and the required data in the request body, you need to include a JSON object with the following keys:

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

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

Example of a Query request

Normally this is how a GraphQL query looks like

You can try to make the same query to the given GraphQL server:

https://rickandmortyapi.graphcdn.app/

{
  characters(page: 1) {
    results {
      name
      id
    }
  }
}
Output for the above-given GraphQL query will look something like this
{
  "data": {
    "characters": {
      "results": [
        {
          "name": "Rick Sanchez",
          "id": "1"
        },
        {
          "name": "Morty Smith",
          "id": "2"
        },
        {
          "name": "Summer Smith",
          "id": "3"
        },
        {
          "name": "Beth Smith",
          "id": "4"
        },
        {
          "name": "Jerry Smith",
          "id": "5"
        },
        {
          "name": "Abadango Cluster Princess",
          "id": "6"
        },
        {
          "name": "Abradolf Lincler",
          "id": "7"
        },
        {
          "name": "Adjudicator Rick",
          "id": "8"
        },
        {
          "name": "Agency Director",
          "id": "9"
        },
        {
          "name": "Alan Rails",
          "id": "10"
        },
        {
          "name": "Albert Einstein",
          "id": "11"
        },
        {
          "name": "Alexander",
          "id": "12"
        },
        {
          "name": "Alien Googah",
          "id": "13"
        },
        {
          "name": "Alien Morty",
          "id": "14"
        },
        {
          "name": "Alien Rick",
          "id": "15"
        },
        {
          "name": "Amish Cyborg",
          "id": "16"
        },
        {
          "name": "Annie",
          "id": "17"
        },
        {
          "name": "Antenna Morty",
          "id": "18"
        },
        {
          "name": "Antenna Rick",
          "id": "19"
        },
        {
          "name": "Ants in my Eyes Johnson",
          "id": "20"
        }
      ]
    }
  }
}

Example of a query made using Bi-Direct

Headers

Request Body

Generated output for the given query
Javascript code (Axios)

Last updated