Disable Permissions checks on Saleor locally


Saleor and Docker can sometimes be a little bitchy, making problems where there shouldn´t be any. May it be a temporary hick-up. Or a caching issue. You can always do a restart of docker. Or your container. Or your whole machine.

But it always costs time and you have to remember to do so, while it interrupts your Flow.


The solution is quite simple and has 2 steps:

Step 1: Disable Permission checks in the code you are working on

Step 2: On your pre-commit checklist add a reminder to re-enable the permission checks.

To do Step 1 open the file mutations.py in the folder saleor/graphql/core .

Find the classmethod check_permissions (def check_permissions(cls, context, permissions=None):)

This is the place where all regular GraphQL Permission checks happen (e.g. when you use GraphQL to query OrderDetails and it checks if your current user is allowed to view this Order).

Add one extra line before the regular code and you are done already:

return True

Don´t forget to test your code with Permission checks enabled at the end. And to re-enable permissions before committing.

Personally, I often use it when I need to adjust GraphQL Queries or add new fields to the GraphQL Models. Too often it´s just annoying to run into Permission errors in the GraphQL explorer.

Let me know if and how you use it.



Leave a Reply