Package Graphs and Queries

Learn how to create graph and query structs to capture graph serializations and database queries.


We want to save our graph serializations and database queries in the graph store, and we’ll need some data access properties to describe them. To keep things simple here, let’s make the decision that we’ll work with text-based formats only.

We'll encapsulate those graph and query serializations, together with some properties we need to access them, into data packages for transporting to and from the graph store. Essentially we’ll build containers for the graphs and queries. We’ll use structs for those data packages—one for graphs and one for queries.

Graph and query structs

So let’s extend our module structure to add in a new module for a %GraphCommons.Graph{} struct to capture a graph serialization. Let’s also add a module for a %GraphCommons.Query{} struct to capture a graph database query.

We need to cd back to the apps/graph_commons directory and then create a file for each of the structs in a new graph_commons directory under the lib directory:

Get hands-on with 1200+ tech skills courses.