Skip to content

How can I have custom identifiers/primary keys for my resources? #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
akamit21 opened this issue Jul 21, 2020 · 9 comments
Open

How can I have custom identifiers/primary keys for my resources? #57

akamit21 opened this issue Jul 21, 2020 · 9 comments

Comments

@akamit21
Copy link

My table has a primary key other than id and react-admin enforces id to be returned in the response by the DataProvider. So can I configure different primary keys/identifiers for my resources?

@caston1981
Copy link

hi Akamit21,

I am a novice (at least as a developer) myself but I hope this helps you.

In the readme for ra-data-hasura it has a section on different primary keys

best regards,

Chris

@avimoondra
Copy link

Have a similar question as @akamit21 !

(@affluent-bilby-classifieds that is for a different library that is not compatible with ra-data-hasura-graphql. I'm actually in the process of migrating from that library to this one.)

@avimoondra
Copy link

@akamit21
Copy link
Author

Have a similar question as @akamit21 !

(@affluent-bilby-classifieds that is for a different library that is not compatible with ra-data-hasura-graphql. I'm actually in the process of migrating from that library to this one.)

Yes, I tried to implement but didn't work out.

@polymeris
Copy link

Having the same issue, with the added complication that I am using composite primary keys. Did any of you figure it out?

@akamit21
Copy link
Author

akamit21 commented Aug 18, 2020

Nope, not yet, but to resolve my primary key problem I rename the primary key column to id when it fetches the data and generates the data-list, in that way I receive my primary-key column renamed as id.

@divramod
Copy link

divramod commented Dec 3, 2020

@akamit21 can you show an example of your workaround on how you are renaming the primary key to id while fetching the data?
it would be nice to have a option to configure that.

@diazhector98
Copy link

@divramod agreed. @akamit21 could you show an example?

@akamit21
Copy link
Author

Well, I made the changes in getResponseParser.js file of the library. I had a employee table with primary_key name emoloyee_id. So I add only these line in code and it worked.

if (key === 'employee_id') { return { ...acc, id: dataKey }; }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants