Hello.. I’m about to setup permissions in my app and I have read a few posts on the topic, but I can only find info on how to write permission queries to define permissions on the server, I can’t find any info on how to ask for permissions from the client. I guess I approach this the wrong way, I assume permissions on the server should just feed me the relevant data which should populate my UI etc, right? Does anyone have an example on how to handle this “best practise”? This article did not give me the full pcture:
https://www.graph.cool/docs/tutorials/authorization-content-management-system-miesho4goo/
Josef Henryson
10/03/2017, 9:41 PM
I need to let admin in app be able to create custom roles and set roles/permissions to other users, and also ask server for current roles/permissions to display in UI. I figure I’m not alone having the need to query/mutate permissions from client? Thanks for any input 🙂
a
agartha
10/03/2017, 10:13 PM
There's no ready-made solution for it. You have to add the needed types for Role, Permission, with the relations to User, and set up basic CRUD functionality in the client to edit those.
j
Josef Henryson
10/04/2017, 5:14 AM
Thanks. My initial thought was to build everything myself, but since there is permission handling in place I thought I should make use of it where possible. Is there no way from client to read/update pemissions on server?
a
agartha
10/04/2017, 9:01 AM
Not the permission queries themselves. But as you can use any Type you want in those permissions queries, you can of course update the relevant nodes to reflect that. For example, if your permission query checks if a user is part of a Group, you don't need to update the permission query itself, you can just add a User to a Group.
j
Josef Henryson
10/04/2017, 5:24 PM
Ah, I think I get the idea 🙂 Still a newbie to GQL. Thanks for answering! Appreciated!