craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.25k stars 630 forks source link

Allow GraphQL in CP for non-admins #5813

Closed timkelty closed 3 years ago

timkelty commented 4 years ago

We have clients that would like to use the GraphiQL IDE in the CP to query elements, but currently it is limited to admins.

Would be great if this were a normal user permission.

narration-sd commented 4 years ago

@timkelty Tim, I wonder if it might not be a good thing to serve this need by bringing your clients the sponsored free Insomnia playground (https://insomnia.rest/)?

The further 'could you design a query for me?' you will have to choose how to handle...

The only task needed to set this up is to create a Schema with the appropriate access, and pass around the permission Token for it. Insomnia has a slot for this, so no need to instruct them how to make headers.

In fact you can do better than that. Insomnia has an Export feature that allows you to save complete Workspaces -- any number of queries, with all the urls, paths, tokens, and GraphQL itself already set up in them. You can just export and pass out the prepared setup.

Bingo, I think, and one more picture of what would really get asked for from Craft if they got into this area.

Other tools exist, of course. I think online ones like https://www.graphqlbin.com/ are out for data security, and I've used Insomnia a while over others, so on that at least can recommend it. I note there are now enterprisey features growing on it, but the free version is fully capable.

[we won't talk about the little expedition I took yesterday, thinking of what Andris would call 'over-engineered' plugins...which did give me these better thoughts in the morning]