maticzav / graphql-shield

🛡 A GraphQL tool to ease the creation of permission layer.
https://graphql-shield.com
MIT License
3.55k stars 172 forks source link

Shield rules object typings from schema or schema-based types #466

Open olup opened 5 years ago

olup commented 5 years ago

I don't know if it allready exist and I could find the doc or if I am asking something completely crazy. Somewhere in that spectrum.

I wonder if there was any way allready implemented to type the first argument to shield() so that it allows only existing object/fields in the rules keys. I would LOVE intellisense on vscode.

This typing should come from the schema itself or from some prisma2-generated Typescript types.

To be more specific : my schema has a Role type. When writing my shield's rules I would love to be able to choose Role from the intellisense menu. In the other hand, creating a rule on a Query field that does not exist in my schema would result in a red flag in the IDE, indicating that I just can't do this.

Cheers !

open-collective-bot[bot] commented 5 years ago

Hey @olup :wave:,

Thank you for opening an issue. We will get back to you as soon as we can. Also, check out our Open Collective and consider contributing financially.

https://opencollective.com/graphql-shield

PS.: We offer priority support for all financial contributors. Don't forget to add priority label once you start contributing :smile:

maticzav commented 5 years ago

I think that's a fantastic idea. I have thought of it many times as well but eventually always dismissed it due to the lack of funding since it requires more code change than regular maintenance.

gidich commented 2 years ago

I've contributed a little to help keep this project going - I too would agree that this would be a great feature to have.

Thanks again for this project!

maticzav commented 2 years ago

Thanks! This is definitely coming in the next month or so with version 8.0.

Also, thank you for your contribution, I can't wait to see you try it. 🚀😄