godgraphdgraph-dgo

is it possible to retrieve the current schema using dgo


Is there a way to retrieve the dgraph schema using the dgo client?

What I want to do is compare my existing schema with the one on the server in order to avoid re-sending it as it triggers reindexing each time I send a schema which is already set.


Solution

  • It is actually possible to retrieve information about the entires schema:

    txn := client.NewTxn()
    res, err := txn.Query(ctx, `schema{}`)
    if err != nil {
        return err
    }
    
    for _, predicate := range res.GetSchema() {
        log.Printf("predicate: %#v ", predicate)
    }