I'm using Hasura and I have a table called "settings" where primary_key or pk is key and not id
How can I use custom pk and its type as String?
I saw an old post idColumnName but that is not working
3 Replies
Hi @narayandreamer. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
To use a custom primary key and its type as
String
in a Hasura table with refine, you can follow these steps:
1. Override the ID Type: By default, the refine Hasura data provider assumes the ID
type is uuid
. However, you can change this behavior by using the idType
option. Unfortunately, the current implementation only supports Int
and uuid
as options for idType
. To use String
, you would need to modify the data provider code directly.
2. Modify the Data Provider: You can copy the data provider files to your project and make changes to support String
as an idType
. Here's a suggestion based on the knowledge sources:
This involves changing the type definition and logic to accommodate String
as a valid idType
.
3. Use Custom Metadata: When making queries, you can specify the id
type in the metaData
of your query. Here's an example of how you might specify a custom variable type:
This example shows how to pass a custom variable type in the query metadata.
4. Contribute to refine: If you want to make this change available for others, consider contributing to the refine project by creating a pull request with your changes.
For more detailed guidance, you might want to refer to the refine documentation or the specific GitHub issues related to ID customization in Hasura:
- Hasura Data Provider Documentation (https://refine.dev/docs/examples/data-provider/hasura/)
- GitHub Issue on Custom ID Types (https://github.com/refinedev/refine/issues/3981)
If you encounter any issues or need further assistance, you can also check the refine community forums or GitHub discussions for more support.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@689530553313394880> kapa.ai is still learning and improving, please let us know how it did by reacting below
like-goldOP•4mo ago
can this be used in useForm?