How to handle schema evolution incrementally

What I want to do

Create multiple types to be consumed with graphql.

What I did

Note: Newbie here

  1. Added an schema using the guide here Fetching and Updating Your Schema - Dgraphcloud

Used variable
{ "sch" : "type Person { id: ID! name: String }" }

While trying to add another schema using the same endpoint
{ "sch" : "type Post { id: ID! name: String }" }

It replaces the existing schema.
How can we create the schema’s incrementally as well as update the relationships between 2 types.

Dgraph metadata

Dgraph version : v22.0.2
Dgraph codename : dgraph
Dgraph SHA-256 : a11258bf3352eff0521bc68983a5aedb9316414947719920d75f12143dd368bd
Commit SHA-1 : 55697a4
Commit timestamp : 2022-12-16 23:03:35 +0000
Branch : release/v22.0.2
Go version : go1.18.5
jemalloc enabled : true

Hi @rverma-nsl,

Welcome to the community!

I don’t believe what you’re looking for is possible. One approach I’ve used in the past is to stitch together multiple schema definition files (say, person.graphql.schema and post.graphql.schema) on the fly and update the schema as part of a CD process.

1 Like

Is this possible using DQL?
we are anticipating to have 1000+ types as we build our project, is the CD process good for such situation? The DDL part would be very infrequent, however changing 1 type, or add a relationship between 2 entities shouldn’t demand to fetch the whole schema.

Yes. DQL schema works a differently. Prior definitions aren’t overwritten with schema updates. However, if you’re relying on GraphQL types and their generated APIs, you cannot create them with DQL schema updates.

Honestly, I’d recommend that you maintain a complete schema outside of Dgraph (either in GraphQL or DQL) that can be placed into source control.