Package Graphs and Queries
Explore how to build Elixir structs that encapsulate graph serializations and database queries into reusable data packages. Understand defining graph and query structs with appropriate fields, constructors, and type checks for handling text-based graph formats within an Elixir umbrella project.
Overview
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 ...