November 2022
Intermediate to advanced
294 pages
5h 58m
English
To use the graph services API, we’re going to define some wrapper functions for the Dlex library functions.
First, let’s add a special function to the DGraph.Service module to upload our Dgraph schema:
| | def schema_update(%GraphCommons.Graph{} = graph) do |
| | Dlex.alter(DGraph.Service.get_pid(), graph.data) |
| | end |
We’ll use a %GraphCommons.Graph{} struct to hold the schema data, which we’ll access with the usual read_graph/1 function. We can then retrieve the schema body and pass that to Dlex.alter/3.
The graph service functions are simply defined as:
| | def graph_create(graph) do |
| | graph_delete() |
| | graph_update(graph) |
| | |
Read now
Unlock full access