How do you correctly type helper functions to share fields between Prisma objects? #1316
Unanswered
oliverbaseimmune
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
For example if you have models that often expose the same fields like the following:
It is possible to create a helper exactly as described in the documentation but it does not work if you try to use
PrismaObjectRef
andbuilder.prismaObjectFields
:Does anyone know what I'm doing wrong with this implementation?
I went down this rabbit hole because it seemed like it would be possible (and quite useful) that instead of using a helper function after declaring the model, you could instead convert the helper to take
t: PrismaObjectFieldBuilder
and just spread the return from a helper like this:However, this presents new errors with incompatibilities between
relation
, orexposeBoolean
if I importPrismaObjectFieldBuilder
from the plugin directly vs. usingPothosSchemaTypes.PrismaObjectFieldBuilder
.Any tips would be greatly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions