The Prisma API Route That Changed More Than It Should Have

https://hackernoon.imgix.net/images/a-cinematic-editorial-tech-illustration-of-a-glowing-database-table-connected-to-a-prisma-api-route-one-successful-200-ok-response-on-screen-hidden-fiel...

A lab-verified example of a successful update that changes too much and returns too much

Use this verified reconstruction: a seller sends a normal update for a plant's name and price. The generated call succeeds, but the configuration also adds isPublished: false and may return more fields than expected.

The lab verifies those emitted arguments. It does not claim that this happened to a user or in production. The example combines two separately verified behaviors: forced fields in update data are written on every call, and mutation return fields are not automatically limited unless projection enforcement is enabled.

Both problems are easy to miss in a normal success test. The requested name and price still change, so the test must also assert every server-added field and every returned key.

The shape that looks defensive

The team begins with a mutation shape like this:

import { force } from 'prisma-guard'const sellerUpdate...

Copyright of this story solely belongs to hackernoon.com. To see the full text click HERE

Read more