Fork me on GitHub
#pathom
<
2022-07-29
>
sheluchin16:07:37

What is the way to use Pathom with a fully normalized SQL database that uses natural composite primary keys instead of surrogate keys (uuids)? Is it more pragmatic to just add a UUID column and use that?

souenzzo17:07:35

with pathom3 placeholders https://pathom3.wsscode.com/docs/placeholders/#provide-data Should be more natural to pass multiple parameters when asking for an attribute for example

[{(:>/user {:user/username "souenzzo" :user/org-id "clojurians"})
  [:user/name
   :user/email]}]
With this query, you should be able to create a resolver that receives :user/username and :user/org-id, and lookup in the DB using the composite key.

roklenarcic11:07:29

there is nothing stopping you from having a composite value in ident.

roklenarcic11:07:20

{[:user/composite-id ["souenzzo" "clojurians]] [:user/name]}

souenzzo11:07:35

Yes you can do this since pathom2

sheluchin12:07:56

@U2J4FRT2T thank you for the suggesting to use placeholders for this. I'll take a look at that approach. I understand that your ident value can be anything and that this makes using composite keys possible. I am wondering whether this is a good approach to take in practice instead of just using a uuid. Sometimes the composite PKs can be quite a number of fields - I think technically up to 32 or so - and while passing around the whole composite key would have technical merit, most of my pre-clojure experience is with Django, where using a UUID instead of a composite key is the standard practice and mostly works okay. There's an open 17 year old https://code.djangoproject.com/ticket/373 about it in the tracker 😄 Have you guys tried both ways? If so, did any significant tradeoffs lead you to prefer one option over the other?

roklenarcic12:07:04

I mean i have never worked with such a massive amount of components in a key mostly 2 or 3

roklenarcic12:07:58

As far as software goes there really isn’t much of a difference between putting 32 keys into a placeholder or ident

sheluchin12:08:19

I think there's an ergonomic/DX factor to using a large number of keys. I guess I'll try both ways and see what sticks. Thanks for the input.