You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm encountering an issue where my extended Prisma client (prisma.$extends()) doesn't add the __typename field to the root element inside the generated relation resolvers.
This is my extenstion
It adds the __typename field to each object coming from prisma. This field contains the name of its Model
I am using the Auth Checker to check the root object to verify if the user is authorized to request certain fields of it.
Prisma context: I made sure i only use the extended prisma client everywhere and also put it in the context.
For my own resolvers and the generated CrudResolvers, this setup works perfectly, and I can detect the model of each object by its __typename field inside the auth checker.
Example that works:
queryUser {
user {
email
}
}
However, when using the generated RelationResolvers, the root object of the nested objects does not include the __typename field.
Example that doesn't work:
queryPost {
post {
titleuser {
email
}
}
}
In this case, the user object from the PostRelationResolver doesn't contain the __typename field in the root object.
How can I ensure the __typename field is included in the root object for auto-generated relation resolvers?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi everyone,
I'm encountering an issue where my extended Prisma client (
prisma.$extends()
) doesn't add the__typename
field to the root element inside the generated relation resolvers.This is my extenstion
It adds the
__typename
field to each object coming from prisma. This field contains the name of its ModelHere's a detailed breakdown:
__typename
field of each object coming from prisma.MFAuth
to add authorization checks to certain fields usingModelsEnhanceMap
:root
object to verify if the user is authorized to request certain fields of it.For my own resolvers and the generated
CrudResolver
s, this setup works perfectly, and I can detect the model of each object by its__typename
field inside the auth checker.Example that works:
However, when using the generated
RelationResolver
s, the root object of the nested objects does not include the__typename
field.Example that doesn't work:
In this case, the user object from the
PostRelationResolver
doesn't contain the__typename
field in the root object.How can I ensure the
__typename
field is included in the root object for auto-generated relation resolvers?Thank you for your assistance!
Beta Was this translation helpful? Give feedback.
All reactions