Docs Menu
Docs Home
/ /
Atlas App Services
/ /

Migrate GraphQL to Hasura Data Delivery Network

On this page

  • Before You Begin
  • Migrate to Hasura
  • Authorize Hasura for MongoDB
  • Create a new project and connect to Hasura
  • Test Your GraphQL Queries
  • Authorization and Authentication
  • Set Up Custom Resolvers or Business Logic
  • Update Client Applications
  • Shut down MongoDB Atlas App Services Endpoints

Important

Always refer to the official documentation of both MongoDB Atlas and Hasura for the most up-to-date and accurate information. Specific steps may vary depending on the details of your project and the technologies used.

Hasura empowers developers to rapidly build and deploy GraphQL and REST APIs on MongoDB and many other data sources. By radically cutting down API development times, Hasura enables rapid access to data, reduces friction across teams and services, and enables enterprises to shorten time to market on data-powered products and features.

If you haven't already, Create an account on Hasura's website cloud.hasura.io.

Migrating your GraphQL API endpoints from MongoDB Atlas App Services to Hasura is a multi-step process that encompasses setting up your environment in Hasura, configuring database connections, migrating schemas, and implementing authorization and authentication mechanisms. Below is an expanded guide detailing each step, with a focus on authorization and role-based access control (RBAC) within Hasura. For more information, check out the Hasura docs.

To migrate to Hasura:

  1. Authorize Hasura for MongoDB

  2. Create a new project and connect to Hasura

  3. Test your GraphQL queries

  4. Handle authorization and authentication

  5. Set up custom resolvers

  6. Update client applications

  7. Shut down MongoDB Atlas App Services

Hasura can connect to a new or existing MongoDB Atlas database and generate the GraphQL API for you.

1

Go to cloud.mongodb.com and navigate to the Network Access page on the Atlas dashboard.

2

Click the ADD IP ADDRESS button and enter 0.0.0.0/0. Describe this entry as Hasura. For a unique IP address, contact Hasura sales about deploying on Private DDN.

Now, Hasura Cloud can communicate with your MongoDB Atlas instance.

Network access page.
3

On the Database page, find the Atlas cluster that is connected to your App Services app and click on Connect. Select the Drivers option and copy the connection string.

Get Atlas clust connection string.

The Hasura docs contain the details to perform the following steps:

  1. Install CLI (Prerequisites)

  2. Log in using the CLI

  3. Initialize a new supergraph in an empty directory

  4. Connect to data

  5. Introspect your data source

  6. Build your local supergraph

  7. Start your supergraph

  8. Create a Hasura cloud project

  9. Build and deploy your supergraph

You can use the API Explorer page on the Hasura Console to test out some GraphQL queries.

Hasura also uses the GraphiQL interface, which is similar to how you test queries in Atlas App Services.

Use the GraphiQL interface to test queries.

Hasura does not directly handle authentication. Instead, it relies on session variables provided by an external authentication service. These session variables include user, role, and organization information crucial for determining data access rights. For details, refer to the Hasura authentication docs

Data access permissions, including roles and rule expressions, can be converted into Hasura role-based permission rules.

All Authentication methods that Atlas provides are compatible with Hasura's Webhook and JWT auth methods. If you are using Email/Pass, Anonymous, or API Key authentication, use Hasura Webhook. If you are using a Custom JWT, integrate directly with Hasura's JWT auth method.

Hasura recommends using an external IdP for managing authentication processes for enhanced security and flexibility. You can integrate Hasura with any authentication provider of your choice, such as Auth0, Firebase Auth, AWS Cognito, or even a custom solution, to verify the user and set the necessary session variables. For configuring JWT or webhook authentication in Hasura, refer to the documentation at:

If your existing GraphQL API endpoints include custom resolvers or business logic, you'll need to implement these in Hasura. Hasura supports:

Update any client applications that interact with your GraphQL API endpoints to point to the new Hasura endpoint URLs. Any existing Apollo client will work with Hasura. Refactor your application GraphQL queries and mutations to align with Hasura syntax and schema, ensuring compatibility with the new GraphQL API structure.

Once you have verified that your GraphQL API endpoints are fully migrated and operational on Hasura, you can delete your MongoDB Atlas App Services app to avoid unnecessary costs. As a reminder, Atlas GraphQL endpoints will no longer be supported beginning March 12, 2025.

Back

Run GraphQL Operations from a CLI