Wiznet
Wiznet
Explore posts from servers
TtRPC
Created by Wiznet on 8/30/2024 in #❓-help
Passing input as a prop
No description
2 replies
PPrisma
Created by Wiznet on 8/21/2024 in #help-and-questions
find first on relation queries
Hey all, how do I run a find first but only on the relations of a query? For example I want to get all the users in my db, but only return the first result for their relation. Using the posts example from the docs, I would want to get all the users and only one post.
3 replies
TTCTheo's Typesafe Cult
Created by Wiznet on 8/1/2024 in #questions
API Patching Strategy
For patches on objects that update single fields, is it better to push each patch to its own route or have one route for all patches? Say you have a simple object
color
shape
angle
color
shape
angle
if I wanted to just change the color field, should that be its own route or catch all field updates into one route that handles patching any of the object fields?
4 replies
DTDrizzle Team
Created by Wiznet on 5/14/2024 in #help
Enforcing DB level foreign keys
Hey guys, I've read the docs on the relation key word and the docs note that the relations are only on the application level. How can we create foreign key relations via the schema that are enforced on the DB level?
2 replies
PPrisma
Created by Wiznet on 5/14/2024 in #help-and-questions
Prisma format fails with disambigious relations
Hey all, not sure if this is my own error here. But I've got the below schema that fails to get formatted by prisma format. I've got quite a few relations setup on a user model. However, running prisma format fails when trying to insert the relations onto the user model. I've added both the errpr and my source schema below. It seems like prisma format fails to name the ambigious relations on the user model.
model ListingApplication {
id String @id @default(cuid())
description String?
listingId String
brandId String
userId String
applicationStatus ApplicationStatus

createdOn DateTime
createdBy String
updatedOn DateTime
updatedBy String
status String

user User @relation("applyingUser", fields: [ userId], references: [id])
creatingUser User @relation("creatingUser", fields: [ createdBy], references: [id])
updatingUser User @relation("updatingUser", fields: [ updatedBy], references: [id])
listing Listing @relation(fields: [listingId], references: [id])
brand Brand @relation(fields: [brandId], references: [id])
}
model ListingApplication {
id String @id @default(cuid())
description String?
listingId String
brandId String
userId String
applicationStatus ApplicationStatus

createdOn DateTime
createdBy String
updatedOn DateTime
updatedBy String
status String

user User @relation("applyingUser", fields: [ userId], references: [id])
creatingUser User @relation("creatingUser", fields: [ createdBy], references: [id])
updatingUser User @relation("updatingUser", fields: [ updatedBy], references: [id])
listing Listing @relation(fields: [listingId], references: [id])
brand Brand @relation(fields: [brandId], references: [id])
}
Error: Prisma schema validation - (validate wasm)
Error code: P1012
error: Field "ListingApplication" is already defined on model "User".
--> schema.prisma:64
|
63 | ListingApplication ListingApplication[]
64 | ListingApplication ListingApplication[]
|
error: Field "ListingApplication" is already defined on model "User".
--> schema.prisma:65
|
64 | ListingApplication ListingApplication[]
65 | ListingApplication ListingApplication[]
|

Validation Error Count: 2
[Context: validate]
Error: Prisma schema validation - (validate wasm)
Error code: P1012
error: Field "ListingApplication" is already defined on model "User".
--> schema.prisma:64
|
63 | ListingApplication ListingApplication[]
64 | ListingApplication ListingApplication[]
|
error: Field "ListingApplication" is already defined on model "User".
--> schema.prisma:65
|
64 | ListingApplication ListingApplication[]
65 | ListingApplication ListingApplication[]
|

Validation Error Count: 2
[Context: validate]
5 replies
TtRPC
Created by Wiznet on 5/11/2024 in #❓-help
GraphQL Mutation API Design
may be a dumb question. I'm new to graphql type api design coming from a rest controller api. Now often times with our rest api well have one service method to patch an object from a given patch. It seems like this may not be the way to go with graphql? Instead writing specific actions. Aka 'patchObjectName' instead of just 'patchObject' which takes a patch object. Is this correct design?
2 replies
TTCTheo's Typesafe Cult
Created by Wiznet on 4/11/2024 in #questions
Do TRPC fetches need to be wrapped in react.useeffect?
I'm curious on how the use of TRPC api calls works with client and server components. Does TRPC handling the caching of results or do we need to still wrap our calls in a react use effect to prevent unnecessary calls? thank you!
4 replies
TTCTheo's Typesafe Cult
Created by Wiznet on 1/31/2024 in #questions
Google security error on next auth js redirect
No description
3 replies
TTCTheo's Typesafe Cult
Created by Wiznet on 1/17/2024 in #questions
Can two frontend services point to the same base url?
for example we have a landing page: foobar.com which runs on service A. Once a user signs in, they are redirected to foobar.com/home running on service b. And any further links from foobar.com/* are directed to service b while the baseurl foobar.com always goes to service A.
43 replies
TTCTheo's Typesafe Cult
Created by Wiznet on 1/17/2024 in #questions
Next-auth.js: Redirect to custom URL after successful login.
Hey all, I'm trying to figure out how to redirect after a successful login to a custom url. Specifically, I want to point to localhost/home instead of just the default localhost. Thank you!
7 replies
TTCTheo's Typesafe Cult
Created by Wiznet on 1/6/2024 in #questions
Please make sure your database server is running at `z`
Anyone hit this before when trying a connection to a cloud hosted DB? Seems like zod is failing to parse the env variables. Although I do print them out and it seems they are actually set correctly. So I'm not quite sure how prisma is pulling in 'z' as a string.
5 replies