Hello. I'm loving graph.cool so far, great work. I...
# prisma-whats-new
d
Hello. I'm loving graph.cool so far, great work. I'm trying to accomplish something that seems like it should be simple, but I'm not sure what the right approach is. Basically I have a Type with a relationship to User. When a user creates an instance, I want the user relationship automatically set to the currently authenticated user. Sort of a post-author situation.
n
@defrex hey 👋! You can use nested mutations to set the author of the post when creating the post:
Copy code
createPost(title: "Coolness" authorId: "some-user-id")
this assumes the user field on
Post
is called
author
d
That's what I ended up doing. Can I prevent a user from assigning someone else's
userId
to a post they create?
n
Yes - that's possible with the permission system
Let me send you an example right away
d
🙏
n
ouch, looks like I missed out on this - here's a very similar example than what you need @defrex: https://www.graph.cool/docs/tutorials/authorization-content-management-system-miesho4goo/#editors-can-only-assign-themselves-as-the-document-owner
d
No worries, not in a rush. Thanks for the help!
n
cheers! 🙂 Let me know if you need further help hehe