Exposing API with Hasura
Last updated
Was this helpful?
Last updated
Was this helpful?
is an easy way to expose indexed data using a GraphQL REST API. All you need is to download the latest Hasura engine docker image, set the database connection string, and run it.
You will need the following for this guide:
We assume you already have an existing Dappetizer project with Postgresql database. Check out our guide to learn how to set up one. PostgreSQL support needs to be .
installed
If you don't have a local Hasura instance running, you can spawn one using Docker:
Dappetizer can automatically configure your Hasura instance to expose the entities you defined in your project. To do this, add the following section to your file:
You can run queries using the Hasura UI in your browser (for example, open http://localhost:8080
if you are running Hasura locally using Docker).
Example of simple GraphQL query of latest indexed block:
Should result output:
The url
specifies the Hasura instance Dappetizer will connect to on startup. The properties autotrackEntities
and dropExistingTracking
mean Dappetizer will automatically set up fields based on all known TypeORM entities. Check out the to learn more about this configuration section.
You can also secure your Hasura instance by limiting access to your Hasura endpoint, controlling permissions, and setting query limits for particular objects. Read more in the .