Golang Back-end and Angular Front-end with Prisma Generated Models import


I’m planning to have an application that will be having a Golang API Back-End with Angular Front-End and PostgreSQL Database. Few days ago I discovered Prisma and it rang a bell for me; if I create the DB schema first with Prisma-Go-Client then I’d be able to write Front-End and Back-End without creating any beans/models for DB manually and especially for the Front-End I’d directly start coding without any Database connection and API just using prisma generated imports that are Typescript models. So basically I could mock some temporary data with imported models and when Back-End would be ready consistent data types would flow and all I have to do it switch from mock data to bind it to the API request of the required data.

Now the question is; for Golang Back-End side its fine, I’ll import prisma-go-client and generate the models and use them for any schema change and CRUD then return that data as a result etc. but what about Front-End? Should I create prisma TS client into existing Angular Front-End and generate models or this will result of a database reveal after the build of the code into the dist? Or if I create another project only for this purpose that will create TS prisma models and only get and import that models into the existing angular project will that work or will it still contain DB reveal?

Lastly, if prima-go-client creates models for GoLang and I parse the DB result into that model and return it as JSON to the Front-End, will TS generated prisma models be able to parse that response? or they will not be consistent since they are generated between two different languages and they will have difference (which I expect them to be same)?


This wouldn’t work because the Prisma TS Client is not meant to be used on the frontend. It’s a backend library, just like the Prisma Go Client.

You could use the Go Client within a type-safe GraphQL server like https://github.com/99designs/gqlgen and then use a type-safe GraphQL client on the frontend.

Just a note that the Go Client is no longer officially maintained: https://github.com/prisma/prisma-client-go/issues/707. We’d recommend you use the TS client, if possible.

Answered By – Matt

Answer Checked By – Pedro (GoLangFix Volunteer)

Leave a Reply

Your email address will not be published.