How generete enum type from hasura?
Solution:Jump to solution
If i understand your question correctly, Prisma actually does generate TypeScript types based on your database schema, which you can use in your application. See this section of the documentation
7 Replies
Hi @RedRoss
Can you please provide more information about your request? Are you integrating it with Prisma?
I’m using hasura that handles the db in postges and hasura does not create a native type of postgres but creates a table with value and description and then is counterpointed as enum, so consequently prisma does not intercept it
https://www.youtube.com/watch?v=PljuJGLLUeM
Code Daily
YouTube
Create GraphQL Enums with Hasura Enum Tables
We'll tackle setting up user types by creating a users_types table with a value text primary key. We'll add the users type as a foreign key to our new table. Finally we'll insert values as a SQL query and track it as a migration.
Get the code repo at https://codedaily.io/tutorials/171/Create-GraphQL-Enums-with-Hasura-Enum-Tables
Prisma doesn’t natively support Hasura's custom enum implementation. Would using
$queryRaw
to directly interact with the database work for you?Raw queries | Prisma Documentation
Learn how you can send raw SQL and MongoDB queries to your database using the raw() methods from the Prisma Client API.
@RaphaelEtim Reading the documentation does not seem to me that I can create types from the records of the table, or am I wrong?
Solution
If i understand your question correctly, Prisma actually does generate TypeScript types based on your database schema, which you can use in your application. See this section of the documentation
Models | Prisma Documentation
Learn about the concepts for building your data model with Prisma: Models, scalar types, enums, attributes, functions, IDs, default values and more.