Biff.graph: Structure Your Clojure Codebase as a Queryable Graph
I created biff.graph to offer a lightweight, approachable alternative to Pathom for Clojure developers. By structuring your data model as a queryable graph, you can unify database access and business logic into small, independent resolvers. This design makes your codebase easier to understand and test, especially as it grows, without the steep learning curve of heavier frameworks.
For people working on small projects who haven't even heard of Pathom yet, I'm not extremely confident that the code structure benefits would outweigh the extra learning effort required.
- geokon
It's very cool you managed to make a mini Pathom - esp in so few lines of code :))
But the end result looks almost identical? Resolver declarations are a bit reorganized and look a bit cleaner - though you could do that with a wrapper around Pathom. Why not fork Pathom and just make some QOL adjustments?
If you are okay only having a subset, then I think you could streamline Pathom quite a bit more.. Off the top of my head:
- adding and "registering" resolvers in to an environment is always annoying. To me this feels like it should be abstracted away and you should never has to manage this stuff. Each time you add a resolver you have to copy the new resolver name, scroll down to the bottom of the file and paste it in to the resolver list. Stale resolvers floating around in the ns and forgetting to register resolvers regularly leads to weird scenarios where you're wondering why something isn't resolving. I think the user shouldn't really have to think about any of this.. the environment should be constructed automatically by the engine. Scan the namespace and register ever resolver.
I get that it'd be not as flexible this way.. but I've never had to make multiple environments in one namespace.
- You should be able to safely reregister resolvers. This happens when you try to decouple sub-systems that depend on common resolvers. Ex: I have some utility resolvers that do some format conversions. If I add them to the environments of two namespaces, then those two namespaces can't […]
- chamomeal
> biff.graph is basically a lightweight version of Pathom. It implements only a subset of Pathom's functionality with the intention of being easier to understand.
I’ve heard of pathom but I’ve never actually dove in and tried it out. It sounds super neato though.
I have a bunch of microservice DB’s (that should really just be on DB, but I think we’re created in the peak of microservices hype). I def need a better way to explore the data. “Easier to understand” sounds sick and I think I’ll check it out this week!
- adamfeldman
There are a few great talks on YouTube by the creator of Pathom explaining the value of the graph: https://m.youtube.com/watch?v=IS3i3DTUnAI
- arikrahman
Amazing project, getting into Clojure and will no doubt have use for this as a solo dev
- Capricorn2481
My experience with Pathom, and other graph query libraries, is it feels like a deliberately confusing way to reason about a program. I'd like to know your thoughts on it.
From what I hear, the main draw is separating what you want from how you get it, so your calling code can just focus on what it needs. But you can use regular functions to do that. What libraries like Pathom do is leave it open to the caller what shape of data they need.
But I think letting the caller do subtle query changes that can completely change which resolvers are triggered and how something is fetched is kinda leaky. How do you write the perfect resolver for all situations? How do you keep them from accidentally exploding their fetches? Is it not better to have things be explicit through function calls instead of chasing down disjointed call graphs?