Hey @nathanmarz, in a few of your blog posts you mention using specter for some pretty interesting graph stuff. I was interested in making specialized navigators for https://jsonapi.org/ and thought some examples of defining navigators for "specialized" domains might be helpful. Do you have any more information / examples about your graph implementation?
IDK if ur familiar with the spec but the most kludgey thing it requires me to do is to hold onto the top level document, or some kind of id -> entity index, while I'm navigating through the tree structure w/ specter
I'm handling that by attaching metadata onto the things I'm navigating into, but like I said, its a little kludgy
@npetryk my graph navigators are specifically for dag's
TOPSORT
is like ALL
but visits nodes in topological order
REVERSE-TOPSORT
is the same but opposite order
CHILDREN
goes from node to all children
likewise PARENTS
, DESCENDANTS
NODE
goes from a pointer to a node (which the aforementioned ones navigate you to) to the value for that node
node-nav
navigates to a specific node
and then a couple navigators for navigating to sub-dag's, with metadata and ids on nodes used to determine how to attach the transformed sub-dag into the parent dag
there's a few more but those are the main ones
for navigating a tree you probably don't need custom navigator implementations, just a few composite navigators using recursive-path
if you have some examples I can walk you through it
Thanks! https://github.com/nathanmarz/specter/issues/241 also gave me some insight. It looks like that instead of passing [graph node-id]
around I can just pass my tree "context" as metadata on individual nodes. The bit about reducing in the transform is also helpful for when I need to make updates to my tree