dataprovider
I have Hasura-Graphql on top of Postgres which I used in Refine Graphql data provider. I have a table which has
email
as primary key instead of id
. When I'm trying to use useOne
, it requires id
field which internally makes a query with id instead of email. How can I use useOne with tables having non-ID primary key?4 Replies
Hi @mayurdhurpate. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
You can customize the
idType
in your Hasura data provider to handle tables with non-ID primary keys. In your case, you can create a mapping for the email
primary key. Here's an example of how to do this:
Replace tableNameWithEmailPrimaryKey
with the actual name of the table that has the email
primary key.
However, the useOne
hook still expects an id
parameter. To handle this, you can modify your data provider's getOne
method to use the custom primary key based on the resource name. Unfortunately, the provided extracts do not contain enough information to show you how to modify the getOne
method specifically for this case.
For more information on Hasura data provider and useOne
, you can refer to the following sources:
- Hasura Data Provider (https://refine.dev/docs/examples/data-provider/hasura)
- useOne Hook (https://refine.dev/docs/api-reference/core/hooks/data/useOne)
----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:
----------------------Hasura | refine
Any REST or GraphQL custom backend work integrated with refine. refine Hasura GraphQL Data Provider comes out-of-the-box. Thanks to refine, you can connect to your Hasura database and create special queries and use your data easily. This example shows in detail how you can use the data in your Hasura database with refine project.
useOne | refine
useOne is an extended version of TanStack Query's useQuery. It supports all the features of useQuery and adds some extra features.
<@461768875919278081> kapa.ai is still learning and improving, please let us how it did by reacting below
foreign-sapphire•2y ago
you can sent any variables with metaData