amplify-ui
amplify-ui copied to clipboard
Fully support and document useDataStoreBinding and other internal hooks
On which framework/platform would you like to see this feature implemented?
React
Which UI component is this feature request for?
Other
Please describe your feature request in detail.
I can not able to find the documentation regarding how to use the useDataStoreBinding hook and how to pass the extra parameter in that like criteria and pagination props.
I have 2 tables, the Teacher table, and its courses table. This Teacher and course table has a one-to-many relationship. I want to use the useDataStoreBinding hook to get the teachers and their related courses using a single query.
Please describe a solution you'd like.
There should be documentation or demo provided which will show data on how to use the useDataStoreBinding and other related hooks.
We love contributors! Is this something you'd be interested in working on?
- [ ] 👋 I may be able to implement this feature request.
- [ ] ⚠️ This feature might incur a breaking change.
Hey @jaythakor-ai thanks for your feature request. The useDataStoreBinding
hook (and other similar hooks exported but not documented) are used internally within the project and not officially supported for users of the library.
I'm going to change the title of your issue to capture a request for the project to fully support and document the hooks used internally for other developers. The team will discuss adding the request to the roadmap.
If you would like to see the useDataStoreBinding
and other hooks officially supported then give this issue a thumbs-up.
Greetings, @slaymance Have a wonderful day. They are enclosing the call in this useDataStoreBinding hooks when I make the create record request on the click of a button from the Amplify Studio. So, if you don't formally support it, will I be in problems in the future? Then I have to manually construct the GraphQL request to create the database record.
@slaymance any updates on this? Because When I created the collection from the Amplify Studio, Studio generated the list of the DynamoDb table records using the useDataStoreBinding. Now I have to added that table to one-to-many relationships with another table and the useDataStoreBinding' result is not providing the records of the related table. So how can I handle this scenario?
@jaythakor-ai The useDataStoreBinding hook is fully supported in autogenerated code from Amplify Studio. However, we do not support using the internal hooks directly (by modifying the generated components) as the API's have not been finalized for direct public use (outside of Studio generated code) and may change in the future. I don't believe that one-to-many relationships are supported in Studio at this time.
As far as querying one-to-many relationships, you can use the DataStore JS API and pass the data to the Collection items
prop:
See: https://docs.amplify.aws/lib/datastore/relational/q/platform/js/#querying-relations
@jaythakor-ai The useDataStoreBinding hook is fully supported in autogenerated code from Amplify Studio. However, we do not support using the internal hooks directly (by modifying the generated components) as the API's have not been finalized for direct public use (outside of Studio generated code) and may change in the future. I don't believe that one-to-many relationships are supported in Studio at this time.
@reesscot Currently, I am triggering the Create, Update, and Delete API using the autogenerated code from the Amplify Studio. So, will I face the issue in the future If I continue using this autogenerated code from Amplify Studio? I don't want to write the code to make an API, So I preferred to use the Create, Update and Delete Action on click of a button from the Amplify Studio.
You can see in the below image that How I am Triggering the API calls from the Amplify Studio. During Create API trigger, autogenerated code of Amplify Studio is using the useDataStoreCreateAction hooks, for the Delete API trigger, autogenerated code is using the useDataStoreDeleteAction hooks, and so on.
Please do the needful if I missing something or doing anything wrong.
@jaythakor-ai Anything that currently works from Amplify Studio UI Builder will continue to work and be supported. We have extensive unit tests and integration test to make sure we don't break anything in the autogenerated code. Supporting one-to-many relationships from Amplify Studio UI Builder is on the roadmap, but it is not available yet. If you require one-to-many relationships for parts of your application, then you will need to use the DataStore API's directly.
Is there any way the useDataStoreCreateAction can be modified. For example if I wish to hide the dialog after performing the create, how would I do that?
@CKalt We do not support use of useDataStoreCreateAction
directly outside of Studio UI Builder. To use DataStore directly, please see https://docs.amplify.aws/lib/datastore/getting-started/q/platform/js/
Closing out as we are not planning on exposing these hooks.