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.
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!
This post is part of a series on how to leverage your existing Salesforce data in external tools: https://cloudanswers.com/build-fast-static-sites-with-salesforce-and-netlify/
Related Articles
Tips for Becoming a Salesforce Developer
Interested in becoming a Salesforce developer? In this blog post Jagmohan has put together his favorite tips and resources to get started in the world of Salesforce development.
April 4, 2024
6 Min Read
Designing User Security and Visibility in Salesforce
Trust and security are at the top of Salesforce's priority list. The platform has everything you need if you're looking to construct a robust user security paradigm. However, this security approach has flaws that an attacker can exploit to gain access to your data. The Salesforce Architect has the duty to ensure that these features are set up correctly.
March 16, 2022
7 Min Read
Batch Apex Error Event - CloudAnswers Hackathon
A hackathon is an event usually put together by a tech organization. The event brings programmers together over a specific period to collaborate on a project.
June 28, 2021
5 Min Read