maticzav / graphql-shield

🛡 A GraphQL tool to ease the creation of permission layer.

Home Page:https://graphql-shield.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Shield permissions only working properly with 'debug: true'

prestonbrown-me opened this issue · comments

Bug report

  • I have checked other issues to make sure this is not a duplicate.

Describe the bug

  • shield permissions fails no matter the configuration or return value of the rule.
  • when setting debug to true, shield works exactly as intended

To Reproduce

  • configure shield as usual with these versions:
"graphql": "^16.7.1",
"graphql-middleware": "^6.1.35",
"graphql-shield": "^7.6.5",

Steps to reproduce the behavior, please provide code snippets or a repository:

  • here is my current shield configuration:
export const permissions = shield(
  {
    Query: {
      "*": allow,
    },
    Mutation: {
      "*": allow,
    },
  },
);

I receive this shield error:

"errors": [
    {
      "message": "Not Authorised!",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "signIn"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "stacktrace": [
          "Error: Not Authorised!",
          "    at normalizeOptions (/Users/user/Documents/GitHub/webrec/node_modules/graphql-shield/cjs/shield.js:27:52)",
          "    at shield (/Users/user/Documents/GitHub/webrec/node_modules/graphql-shield/cjs/shield.js:40:31)",
          "    at Object.<anonymous> (/Users/user/Documents/GitHub/webrec/packages/server/src/permissions/index.ts:4:34)",

so I add debug: true to options and see what's going on, but now shield is working as defined in permissions.

Expected behavior

I expect the permissions for "*": allow to work.

Actual behaviour

The permissions only work when I have debug: true in options

Up, same problem in here! Thank you