Making a directive mandatory for every query/mutation

Viewed 41

I am using github.com/99designs/gqlgen to create my GraphQL in Go. I have a directive in there called hasRole for authorization purposes. The thing is that I want to make this directive apply to every field in Query/Mutation, in case a developer forgets adding it when creating new Query/Mutation. E.g.:

createUser(name: String): String @hasRole(role: [Admin]) - this is ok

createUser(name: String): String - not ok

Any way to prevent the query/mutation from happening is acceptable. Is there any way to make this possible? Doesn't matter if it is done during generation, starting of the program, etc.

0 Answers
Related