Docs Menu
Docs Home
/ /
Atlas App Services
/ /

Migrate GraphQL to WunderGraph

On this page

  • Migrate to WunderGraph
  • Create a WunderGraph Application
  • Add npm Scripts
  • Start the WunderGraph Server
  • Configure MongoDB Atlas Data Source
  • Add Query Operations
  • Browse Data with the GraphiQL UI
  • Use WunderGraph's JSON-RPC Interface for Production
  • Update Client Applications
  • Shut Down Atlas App Services Endpoints
  • Next Steps
  • WunderGraph Cosmo for GraphQL Federation

Important

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

WunderGraph is a comprehensive developer platform that comes equipped with an extensive variety of open-source tools and SDKs.

One of these tools is a Backend for Frontend (BFF) Framework. This BFF Framework is a robust, specification-compliant server framework that you can add to production environments. This framework can integrate data from any source. This includes data from MongoDB Atlas. For more details, refer to the WunderGraph docs page for Atlas. If you plan on using GraphQL Federation, take a look at WunderGraph Cosmo.

The WunderGraph BFF is an open source gateway that bundles up your data and generates type-safe clients for your frontend framework. You can also use hooks to add additional business logic, or custom GraphQL resolvers to decouple the clients from the database.

The following is an overview of how to migrate your GraphQL host from Atlas App Services to WunderGraph. Specific steps may vary depending on the details of your project and the technologies used.

1
# Init a new project
npx create-wundergraph-app my-project --example simple
# Move to the project directory
cd my-project
# Install dependencies
npm i
2

Add the following scripts to package.json, so you can run the WunderGraph server.

{
"scripts": {
"start": "wunderctl up --debug",
"build": "wunderctl generate"
}
}
3
npm run start

After starting the server, WunderGraph does some code generation. Check the server status at http://localhost:9991.

4

You need to configure your MongoDB Atlas datasource. Inside your wundergraph.config.ts file add the following:

wundergraph.config.ts
const Atlas = introspect.mongodb({
apiNamespace: 'my_db',
databaseURL: 'YourAtlasURL',
});
configureWunderGraphApplication({
apis: [Atlas],
});
5

To work with your Atlas data, you need to add query operations. Navigate to the operations folder and create a new GraphQL file called Users.graphql and add the following:

/operations/Users.graphql
{
Mongo_findFirstusers {
id
name
email
}
}
6

After you get your WunderGraph server running and add query operations, you can use the GraphiQL user interface to explore your Atlas data through a GraphQL API. This can be useful when your app is in development. For apps in production, we recommend using WunderGraph's JSON-RPC interface (see next step).

  1. With your WunderGraph server running, navigate to http://localhost:9991/graphql.

  2. Add these queries to the GraphiQL user interface:

    query Users {
    db_findManyusers {
    id
    name
    email
    }
    }
  3. Click the Play button.

7

GraphiQL is good for development, but in production, you should consider using WunderGraph's JSON-RPC interface to interact with your Atlas data.

In short, WunderGraph compiles your GraphQL operations into JSON-RPC endpoints that you can call.

After running wunderctl up, WunderGraph checks the .wundergraph/operations directory for *.graphql files and processes them. For this to work, each file should contain exactly one GraphQL Operation.

Each file will be compiled into a JSON-RPC endpoint. The name of the endpoint is determined by the file name.

Here's an example JSON-RPC API query:

curl http://localhost:9991/operations/Users
8

Update any client applications that interact with your GraphQL API endpoints to point to the new WunderGraph endpoint URLs.

9

Once you have verified that your GraphQL API endpoints are fully migrated and operational on WunderGraph, 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.

Check out the WunderGraph Cosmo docs to learn how to build a distributed GraphQL architecture that combines multiple GraphQL APIs to create a unified graph.

Cosmo enables teams and Organizations to manage and scale (federated) GraphQL Architectures with ease. Quickly iterate without breaking anything through composition checks.

WunderGraph Cosmo can easily run locally, on-premises, or in the cloud as a managed service. Cosmo is a batteries-included solution, covering everything from routing to analytics with the whole platform.

Cosmo supports monolithic GraphQL APIs as well as Federation v1 and v2 including Subscriptions.

← Migrate GraphQL to Apollo