pragma icon indicating copy to clipboard operation
pragma copied to clipboard

Redundant authorization error messages

Open anasbarg opened this issue 4 years ago • 0 comments

Redundant authorization error messages

Pragmafile: https://gist.github.com/anasbarg/f5617d17e45e35488689408322e14a16

Problem

When I try to run the following query on the above schema:

query GetProduct($id: String!) {
  Product {
    read(id: $id) {
      	id
        name {
          ar
          en
        }
        prices {
          currency {
            name {
              ar
              en
            }
            code
          }
          value
        }
        questions {
          index
          id
          name {
            ar
            en
          }
          type
          isRequired
          options {
            id
            name {
              ar
              en
            }
            changeInPrice
          }
          changeInPrice
        }
        imageUrl
        description {
          ar
          en
        }
        discountCodes {
          code
          amount
          discountType
          minimumTotal
          expiresAt
          createdAt
        }
      }
  }
}

I get the following response:

{
  "errors": [
    {
      "message": "No `allow` rule exists that allows `READ` operations on `Product`for role `Business`"
    },
    {
      "message": "No `allow` rule exists that allows `READ` operations on `Product`for role `Business`"
    },
    {
      "message": "No `allow` rule exists that allows `READ` operations on `Localized`for role `Business`"
    },
    {
      "message": "No `allow` rule exists that allows `LIST` operations on `Price`for role `Business`"
    },
    {
      "message": "No `allow` rule exists that allows `LIST` operations on `Question`for role `Business`"
    },
    {
      "message": "No `allow` rule exists that allows `READ` operations on `Product`for role `Business`"
    },
    {
      "message": "No `allow` rule exists that allows `READ` operations on `Localized`for role `Business`"
    },
    {
      "message": "No `allow` rule exists that allows `LIST` operations on `DiscountCode`for role `Business`"
    }
  ]
}

Which are all caused by the first error (no allow READ Product on Business), because when I add it all errors disappear.

Expected

Only the parent error should be returned.

anasbarg avatar Nov 26 '20 12:11 anasbarg