graphql-shield icon indicating copy to clipboard operation
graphql-shield copied to clipboard

Shield permissions only working properly with 'debug: true'

Open 0xPBIT opened this issue 1 year ago • 2 comments

Bug report

  • [x] 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

0xPBIT avatar Aug 14 '23 05:08 0xPBIT

Up, same problem in here! Thank you

chimpwidablastuh avatar Oct 09 '23 09:10 chimpwidablastuh