CloudAnswers
Published in

CloudAnswers

Deploy a Hasura GraphQL API for Salesforce in minutes — Make Salesforce API limits a thing of the past

This post is part of a series on how to leverage your existing Salesforce data in external tools: https://medium.com/cloudanswers/build-fast-static-sites-with-salesforce-netlify-67858f5e7b2a

Salesforce API limits can prevent you from using Salesforce data at scale in your other public web projects. As a Salesforce customer, you only get 1,000 api calls per user per 24h period when you use the Salesforce APIs directly.

This article will show you how to get around that by using the open source Hasura GraphQL engine in front of Salesforce to maximize developer happiness and data throughput.

Here’s how epic you’ll look after you learn this! … Has Photo Credit: Jason Briscoe

Overview

We will create a GraphQL API for Salesforce using Heroku and the open source version of Hasura. You need access to Heroku and Salesforce to make this work.

The following steps will take you between 10-30 minutes depending on your skill level.

Step 1: Launch a new Hasura Heroku instance

Time Required: 2 minutes

This is the fastest way to getting everything configured because the people at Hasura already prepared a heroku deploy button based on their docker images!

Click this link to deploy the app to Heroku:
https://heroku.com/deploy?template=https://github.com/hasura/graphql-engine-heroku

Just pick name and click “Deploy”:

Step 2: Heroku Connect

Time Required: 5–10 minutes

The Heroku marketplace has an add-on called “Heroku Connect” (Salesforce acquired the company that offers this app, so it is officially supported and sold by Salesforce). The free level of Heroku Connect allows for 10,000 records which has enough space for many use cases. The paid levels don’t have prices listed, but they’re about $4k/mo from the recent deals I’ve seen done.

“enterprise” means you need to talk to *humans* to get the prices :)

Add the free version:
In your app, click the “Resources” tab at the top, then search and add “Heroku Connect”:

After the add-on is installed you will connect (oauth) to your Salesforce instance and select a table to synchronize. It’s self-explanatory for many users, but the official trailhead has explicit steps if you need them: https://trailhead.salesforce.com/content/learn/projects/develop-heroku-applications/set-up-heroku-connect#create-heroku-mappings

In my example I mapped a custom object in Salesforce called “Content__c”:

Table mapping example in Heroku

Do NOT enable “Database -> Salesforce” unless you understand the consequences!

Step 3: Hasura Table Tracking

Time Required: 5 minutes

The last step is to tell Hasura to expose our newly mapped table!

Load the Heroku Hasura app in your browser, click “Data” at the top, switch the schema to “Salesforce” and then click “track” next to your object:

Large, vibrantly colored arrows on a screenshot, how condescending!

With the table “tracked” we can now query it from GraphQL, our setup is done!

Use the API

Switch back to the “GraphQL” tab, select your object in the left panel named “explorer” and execute live queries of your salesforce data:

This UI shown above is just a wrapper on top of the GraphQL APIs that are provided, which means that integrating into existing projects is a snap:

You now have a scalable API: Your limits on this setup are probably closer to 1k requests per second instead of 1k per day (the salesforce limit). And even better, your developers can use GraphQL!

If you have a scaling challenge or need help optimizing your Salesforce systems then we can help! Come chat with us at our website: https://cloudanswers.com

--

--

--

We are a group of developers that mostly work on salesforce and technologies that integrate with it. Automation is the name of the game.

Recommended from Medium

Building Salesforce Apps Through Lightning

Building A Microservices Application Using Spring Boot

Different ways to calculate Cosine Similarity in Python

Unity AR Foundation and CoreML: Hand detection and tracking

Implement Queue in C Array

How to Copy Files from Linux to Windows (and vice versa)

Summary Basic Golang Part 1–20

Why Children Should Learn to Code

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
James Sullivan

James Sullivan

Words from the Development Team at CloudAnswers

More from Medium

11 Best Practices for Writing API Documentation

Using Salesfoce’s Scratch Orgs for Jest integration tests.

5 Reasons that Make CRM Software Beneficial for Every Business

5-reasons-that-make-crm-software-beneficial-for-every-business

Heroku Integration Capabilities: The Mini Guide