hello all! This may be a simple question and maybe...
# prisma-whats-new
m
hello all! This may be a simple question and maybe the answer is buried in the history somewhere here but... is there a way to specify some sort of server variables for mutations? Basically i would like to assign the current user id to a field in a create mutation. is that possible or do i need to create a fancy mutation callback to allow this
h
@mannigan Hello 🙂 I believe you will have to pass the id to the mutation by yourself, if I understand you correctly. Nothing too fancy! mutation myFancyMutation($currentUserId : ID!) { createStuff( userId : $currentUserId, title : "a fancy title" ){ userId } } Hope that helps 😉
m
it worries me a bit doing that on the client side, i dont want users to be able to create fancy objects for other users
h
Then you'll have to do it server-side, but I believe this type of permission is on the roadmap
m
i guess i can do it this way for now while im playing around and if i need to fix it before they add this feature then i will create a mutation callback
y
@mannigan try to do it with a serverless function
m
@yannik is this not a common problem? the majority of my graphql types are associated with the logged in user and i want to create objects tied to that particular user
i would have to do almost all of my mutations through a serverless function
which i could do... but seems like a waste of all the nice mutations created automagically by graphcool
y
maybe there's a way I'm not aware of yet but seems like everything you don't want the user to tamper with is better to move to the server
h
It's a problem indeed right now, but my guess is they will work on something before I hit the 100 active users a month 😉
😅 1