Hasura x MEWS

shankarasubramani

Shankar

Posted on June 24, 2023

Hasura x MEWS

Hasura gives you instant GraphQL / Rest API on top of SQL databases like Postgres and MySQL. You can also use Hasura Remote Joins to join data from your Postgres database with MEWS API in GraphQL. 

Step 1: Setup Hasura Instance

Step 2: Configure & Deploy Custom Resolver

  • I've created a project in Glitch so you can remix and spin up your own project. Remix on Glitch
  • MEWS has a demo environment which you can use to test the integration. Get the environment's credentials here
  • Now head over to .env file in Glitch and add these
    • MEWS_BASE_URL
    • MEWS_CLIENT_TOKEN
    • MEWS_ACCESS_TOKEN
    • MEWS_CLIENT
  • Click on Share at the top of the Glitch UI and copy the 'Live Site' URL.

Step 3: Add Remote Schema

In Hasura Console, go to the Remote Schemas tab.
Image description

Step 4: Start querying reservations

query getReservationsFromMEWS($startUTC: String!, $endUTC: String!) {
  getReservations(startUTC: $startUTC, endUTC: $endUTC) {
    Reservations {
      Id
      CustomerId
      AssignedResourceId
      Customer {
        Id
        FirstName
      }
      Room {
        Id
        State
      }
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Add variables to the query

{
  "startUTC": "2023-06-01T00:00:00Z",
  "endUTC": "2023-06-02T00:00:00Z"
}
Enter fullscreen mode Exit fullscreen mode

Voila!
Image description

💖 💪 🙅 🚩
shankarasubramani
Shankar

Posted on June 24, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Hasura x MEWS
hasura Hasura x MEWS

June 24, 2023