Help with SelectField from DB

Noobie here. I have a form where I want to show a dropdown of choices. I can hard code this in my page JS file using SelectField. I want the list to be read from a DB table. I have created the table using prisma but don’t know how/where to fetch the list and how/where to display. I have tried raw query but clearly don’t understand how to use correctly. I also saw post: Using SelectField component for related data inside scaffold form not applying selection or displaying on refetch BUT I don’t have the knowledge to grok it. So? how and where to read the table and create the selectfield?
Thanks for any help/direction! - Andy

Hey @AndyOfLinux, Welcome!

You probably want to use a Cell to fetch the data, and then build and populate the SelectField in the Success component. I have posted a couple of links below, but search the forums for “SelectField” or similar and you should find a list of similar questions to help you out.

BTW, the tutorial is fairly quick and dives into the general way that RW works. It is definately worth working through, if you have not yet.

Please let us know if you still need guidance.

Regards,

B

Thanks! I had worked through the tutorial but obviously did not learn the Cell Lesson very well - lol! I now have SelectField retrieving data from a Cell and displaying and saving selections :slight_smile: Onward!

1 Like

Also please take a look at useLazyQuery if you need a simple way to fetch data and when you might not need a Cell it is much easier than creating a new Cell for every query you want to invoke: Hooks - Apollo GraphQL Docs

2 Likes