Extending a prismaObject in order to add fields #1323
Unanswered
cameronmakarchuk
asked this question in
Q&A
Replies: 1 comment 2 replies
-
Unfortunately there isn't an existing pattern for that kind of extension. The issue with this is that the prisma plugin needs to be able to fully re-load the data for its models to ensure that everything can be correctly resolved. This basically means that you can't force your resolvers to return data that Pothos wouldn't also be able to load automatically, given the models ID. If you want to go down this route you have a couple of options:
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I'm wondering what the best approach (if even possible) for creating a new type by extending a prismaObject to include additional fields not on the original prisma model?
For example, if we have a prisma model:
I'd like to use "User" as the return type in a
queryType
field, to get the benefits of...query
:But the data going from the
queryType
resolver to theUser
type resolver is going to have additional properties not on the originalUserModel
prisma model, so it's giving an error.Is there a way to interface a prismaObject and extend it with additional fields?
Beta Was this translation helpful? Give feedback.
All reactions