Switch Dgraph Cloud Schema Modes
Dgraph Cloud provides a variety of schema modes that let you configure how the underlying Dgraph Cloud instance responds to schema changes or mutation requests that seek to change data stored in your backend.
We’re overhauling Dgraph’s docs to make them clearer and more approachable. If you notice any issues during this transition or have suggestions, please let us know.
Dgraph Cloud uses the following three schema modes, which control how the underlying Dgraph database instance is configured:
- Read-Only mode (dedicated instances only): In this mode, no schema changes or mutations are allowed
- Strict mode: In this mode, only mutations on predicates that are already present in the schema are allowed
- Flexible mode (dedicated instances only): In this mode, there are no global restrictions on schemas and mutations; this mode also provides access to advanced Dgraph features
Each mode is pre-configured to provide simplicity and ease-of-use. By default, your Dgraph Cloud schema runs in Strict mode. If you want your dedicated instance to have the same behavior as a local Dgraph instance, change your schema to Flexible mode.
Read-only mode
In read-only mode, all mutations and attempts to alter the Cloud schema are blocked. You can still access your data through read-only queries.
Strict mode
Strict mode is the default mode on Dgraph Cloud, and the only mode available for free and shared instances. In this mode, Dgraph Cloud enforces a strict schema, only allowing mutations on predicates already present in the schema.
You can use GraphQL and DQL queries and mutations in this mode. However, all queries and mutations must be valid for the applied schema.
In Strict mode, before executing a mutation on a predicate that doesn’t
exist in the schema, you need add that predicate to the schema. To add a
predicate, perform an alter
operation
with that predicate and its schema type (dedicated instances only), or update
your schema to include that predicate and its schema type.
Flexible mode
Flexible mode is suitable for users who are already familiar with Dgraph. It removes global restrictions on schemas and mutations, and also provides access to advanced Dgraph features like the following:
- Directly altering the schema with the
alter
HTTP and gRPC endpoints - Support for access control lists (ACLs)
Switch schema modes with the Dgraph Cloud console
To change your schema mode on a dedicated instance, go to the settings page, click the
General tab, and then select a mode from the Schema Mode list box.
Switch schema modes with the /admin
endpoint
Dgraph Labs recommends using the Dgraph Cloud settings page to change your dedicated instance’s schema mode for most scenarios, instead of directly modifying your schema.
You can change the schema mode for your dedicated instance directly in the
schema using the updateGQLSchema
mutation on the /admin
HTTP and gRPC
endpoints. To learn more, see Fetch and Update Your Schema.
To set your schema mode, configure UpdateOption
to use one of the following
values in your schema:
- To use Read Only mode, set
UpdateOption
toreadonly
- To use Strict mode, set
UpdateOption
tographql
- To use Flexible mode, set
UpdateOption
toflexible
Was this page helpful?