Closed arimgibson closed 3 months ago
This is a known limitation of typescript. Typescript doesn't really have a built in mechanism to limit what keys can be passed in. There are technically things you can do to cause this to error, but it's often not worth the added complexity
This is a known limitation of typescript. Typescript doesn't really have a built in mechanism to limit what keys can be passed in. There are technically things you can do to cause this to error, but it's often not worth the added complexity
Ah, gotcha. Yep, just tried with a regular object and same thing; sorry I didn't catch that earlier. Unfortunately this throws a runtime error with Prisma but manageable as I can set the return type of the function that generates those where
fields.
Thanks!!
Apologies if this is an issue with my setup/my TypeScript vs an issue with Pothos. Also open to feedback if there's a better way to DRY the logic for filtering via args and Prisma while we wait for the Prisma Utils plugin to be prod-ready!
Repro: https://github.com/arimgibson/pothos-prisma-query-where-repro
See
schema.ts
in the repro. When using properties generated by a function into thequery.where
section oft.relatedConnection
, properties that aren't part of the Prisma schema should throw an error as the return type ofquery
doesn't match something that can be queried in Prisma. However, no errors are thrown.