Skip to content

shankara-subramani/hasura-mews

Repository files navigation

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
      }
    }
  }
}

Add variables to the query

{
  "startUTC": "2023-06-01T00:00:00Z",
  "endUTC": "2023-06-02T00:00:00Z"
}

Voila! Image description

Releases

No releases published

Packages

No packages published