If existing DGraph schema compatible with new GraphQL feature? Naming convention of DGraph?

I have played around the new GraphQL feature and I noticed that this is something like managing DGraph schema through GraphQL schema. Is this right?

But what if I already have existing schema of DGraph, do I need to redeclare my schema in GraphQL and generate the new DGraph schema?

Or I should not care about that now and continue to develop with DGraph. and by the time there is some tools to do the translation automatically?

another thing is what is the naming convention of DGraph schema?
I have seen some patterns from tour of dgraph and blogs. For value edge, it should be noun? For uid edge, it should be verb + past tense? what about the dot notation like “director.film”, “Answer.inAnswerTo”.


Hi, thanks for the question.

GraphQL does indeed manage the Dgraph schema - it needs types and edges in Dgraph to store the data to.

There’s more docs just about to hit https://graphql.dgraph.io/ that will clarify. But for now, the basics are that for GraphQL type Typ { fld: String } a corresponding Dgraph type Typ and predicate Typ.fld are generated.

Not released in the binary, but working and coming in the release soon, is

type Typ @dgraph(type: "MyDgraphTypeName") {
  fld: String @dgraph(pred: "MyActualEdgeName")

Which allows you to override the default and map a GraphQL schema to whatever underlying names you already have - there’s some restrictions in GraphQL type and field names that Dgraph doesn’t have, so this can also be necessary if your Dgraph schema contains characters that aren’t GraphQL valid.

We are also planning a tool that will help you translate an existing Dgraph schema to a GraphQL one.

1 Like