BowlingX/ra-postgraphile

primaryKeys limited to names `id` only

Closed this issue · 3 comments

is requiring an id field a limitation of ra-postgraphile or react-admin?

from the looks of https://github.com/BowlingX/ra-postgraphile/blob/master/src/buildQuery.ts#L123 it seems that there could be the possibility to add primary keys that are compound primary keys or not named id is possible.

I'm opening this as I may have some solutions for this, but wanted to ask first.

NOTE: We don't use the NodePlugin, so for our use case without that plugin, any tables that have compound keys or another field name breaks the admin.

Hi :). If the id field is not available, it will use the generated nodeId field. So the only requirement is to have a primary key.

Ah sorry, I did not see that you do not use the NodePlugin; I think we always require a unique identifiable "thing", as react-admin uses this to navigate around; I would think this is rather a limitation of react admin, but nodeId solves this issue if you have a compound key with nodeId.

Thanks for the reply! Makes sense. My current solution was to remove my compound primary keys, replace them with unique constraints, and just stick an id on there - works!

I'll probably read the code here some more and see if there could be a way to hash compound primary keys to generate a client id.