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
- Signup to Hasura Cloud
- Create a free tier project
Step 2: Configure & Deploy Custom Resolver
- I've created a project in Glitch so you can remix and spin up your own project.
- 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 theseMEWS_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.
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"
}
Top comments (0)