Search⌘ K
AI Features

Inspect the Structs

Explore how to refine Elixir struct displays by hiding sensitive fields and truncating large graph data. Learn to implement a custom Inspect protocol for clearer, concise struct representation when working with property graph models in your Elixir projects.

Let’s try out the %GraphCommons.Graph{} struct by creating a new graph. We’ll use a property graph model example here, which generates a minimal graph with two nodes and one edge between them.

Note: Our query.ex file will be similar to the graph.ex file with the term “graph” replaced with “query.”

Default graph

The following example will serve as our default graph.

Default graph
Default graph

We can create this simple graph with the Cypher string:

iex> CREATE (a)-[:EX]->(b)

Here ...