The @dgraph directive in the GraphQL schema should help you here: https://dgraph.io/docs/graphql/dgraph/
Dgraph’s DQL data model doesn’t rely on a type system that’s strongly typed or structured like GraphQL schemas are. You can definitely connect these two together using the @dgraph directive in GraphQL schemas (here’s the docs again). That way, you can load your data and then expose it via GraphQL for your frontend folks.
For example, given your mutation example your GraphQL schema can look like this:
type Deposit {
id: ID!
type: String @dgraph(pred: "type")
subtype: String @dgraph(pred: "subtype")
title: @search(by: [hash]) String @dgraph(pred: "title")
code: String @dgraph(pred: "code")
institution: Institution @dgraph(pred: "institution")
}
type Institution {
id: ID!
name: String @dgraph(pred: "name")
}
The @dgraph(pred: "...") directives are needed so that you can map the predicate name in your actual data (e.g., "type", "subtype") to the GraphQL schema fields. Otherwise, Dgraph will create a new predicate following the naming convention Type.field e.g., Deposit.type. Putting type: String @dgraph(pred: "type") specifies that you already have a predicate called type that will be used for the field.
Another thing to remember when using @dgraph is that your @search directives in the GraphQL schema must match the corresponding indexes that you want to set in the Dgraph schema. e.g., if the Dgraph schema for title is title: string @index(hash) ., then the GraphQL field schema should be title: String @search(by: [hash]) @dgraph(pred: "title"). That way the index is set as you expect it to be.