-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add types to JSON columns in prisma schema #318
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
type
prefix from isomer-componentsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, no real blockers on my end. not entirely sure if adding siteId
to the query adds more value because it's a 1:N link atm but it does add more overhead now which i'm wary of
declare global { | ||
// eslint-disable-next-line @typescript-eslint/no-namespace | ||
namespace PrismaJson { | ||
type SiteJsonConfig = _IsomerSiteConfigProps | ||
type BlobJsonContent = _IsomerSchema | ||
type NavbarJsonContent = _IsomerSiteWideComponentsProps["navBarItems"] | ||
type FooterJsonContent = _IsomerSiteWideComponentsProps["footerItems"] | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think @dcshzj had a point about how we had interfaces/types/schemas in our components
codebase and
- interfaces were to only be used for our studio codebase to work w/ components
- types is a mix of schema and interfaces (i think???)
- schemas is what we guarantee on our end built site (is a contract between us and end user so we must alw sanitise w/ schema)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't get your point here in this comment. you missing the "so what" portion lol
apps/studio/src/features/editing-experience/components/PageCreateModal.tsx
Outdated
Show resolved
Hide resolved
Huh, but you literally should query with |
bad6a32
to
8736c18
Compare
259e0ef
to
2487dcd
Compare
8736c18
to
8961126
Compare
2487dcd
to
f33862f
Compare
33082d4
to
99c65ae
Compare
15e1632
to
f693207
Compare
type folder contains constants too haha
f693207
to
4817648
Compare
TL;DR
Added the
prisma-json-types-generator
module to the project and associated it with the JSON columns in the Prisma schema. This enables the usage of strongly typed JSON columns in the database.What changed?
prisma-json-types-generator
version^3.0.4
topackage.json
andpackage-lock.json
.schema.prisma
to include a new generator forprisma-json-types-generator
.types.ts
file to define types for the JSON columns.How to test?
npm install
.npx prisma generate
.Why make this change?
This change enhances type safety and developer experience by enabling strongly typed JSON columns in the database. It also prepares the project for more advanced features that rely on typed JSON data.