Should I use Dgraph DB directly or the GraphQL API according to Dgraph Documentation?

Updated

Dgraph Documentation presents two entry paths, and the right one depends on what you are building. Choose Dgraph DB when you need direct database operations and administration, such as running DQL queries, managing clusters, and controlling data at the database level. Choose the GraphQL API when you want to generate a GraphQL API and a graph backend from your GraphQL schema, which is aimed at rapid application development with schema-driven APIs. The documentation frames this as "Choose your path," so the decision is about your working style and control needs rather than one path being strictly better.

Dgraph DB: direct database operations and administration

The Dgraph DB path is for teams that want to work with Dgraph as a property graph database directly. According to the documentation, this path covers getting started, using, and operating the Dgraph database.

Typical work in this path includes:

  • Writing and running queries against the graph using Dgraph's own query language
  • Managing schema and data at the database layer
  • Operating the database, including the concerns that come with a distributed system
  • Handling administration tasks for a scalable, highly available deployment

This path suits you if you want operational control and are comfortable treating Dgraph as the database itself, with your application talking to it through the database's native interfaces.

GraphQL API: schema-driven API and graph backend generation

The GraphQL API path is for teams that want to start from a GraphQL schema. The documentation describes it as generating a GraphQL API and a graph backend from your GraphQL schema.

Typical work in this path includes:

  • Defining your data model as a GraphQL schema
  • Letting Dgraph generate the API and the backing graph
  • Building applications against a schema-driven API rather than hand-writing database operations
  • Moving faster on application development where the schema is the source of truth

This path suits you if rapid application development matters more than direct, low-level database control, and if your team already thinks in GraphQL.

How the two paths compare

Dimension Dgraph DB GraphQL API
Primary focus Direct database operations and administration Rapid application development with schema-driven APIs
Starting point The database itself Your GraphQL schema
What you get A property graph database you query and operate directly A generated GraphQL API plus a graph backend
Best when You need operational control and database-level work You want to move fast from a schema to a working API
Documentation entry The Dgraph DB section The GraphQL API section

The documentation does not present these as mutually exclusive in every scenario, but it does ask you to choose a path, which suggests picking the one that matches your primary workflow.

How to decide

Use these questions to pick a path:

  1. Is your schema already defined in GraphQL? If yes, the GraphQL API path lets you generate the API and backend from it.
  2. Do you need direct database operations and administration? If yes, the Dgraph DB path is the one described for that work.
  3. Is your priority speed of application development or depth of database control? The documentation associates the GraphQL API path with rapid application development and the Dgraph DB path with direct operations and administration.
  4. Who will operate the system? If your team wants to manage the database directly, start with Dgraph DB; if your team wants to work mainly through a generated API, start with the GraphQL API.

Where to go in the documentation

The documentation homepage splits into two sections that match these paths:

  • Dgraph DB — "Get started, use and operate Dgraph database."
  • GraphQL API — "Generate a GraphQL API and a graph backend from your GraphQL schema."

Start with the section that matches your answer above. If you are unsure, begin with the path whose description matches your immediate task: operating and querying the database directly points to Dgraph DB, while generating an API from a schema points to the GraphQL API.