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

Not Authorised Error even when i doesn't apply any rule to it.

nikunj321 opened this issue ยท comments

const { shield, and, } = require('graphql-shield');
const { isAuthenticated, onlyCompany, onlyUser, ownJobOnly } = require('./authUtils');


module.exports = shield({
    Query: {
        user: and(isAuthenticated, onlyUser)
    },
    Mutation: {
        updateJob: and(isAuthenticated, onlyCompany, ownJobOnly),
        deleteJob: and(isAuthenticated, onlyCompany, ownJobOnly),
        createJob: and(isAuthenticated, onlyCompany),
    }
})

and myMutation is

mutation{
askQuestion(title: "any question", companyId: "flkjdsofiajwek" ) {
    id
    title
}

i got not authorised Error

Hey @nikunj321 ๐Ÿ‘‹,

Thank you for opening an issue. We will get back to you as soon as we can. Have you seen our Open Collective page? Please consider contributing financially to our project. This will help us involve more contributors and get to issues like yours faster.

https://opencollective.com/graphql-shield

We offer priority support for all financial contributors. Don't forget to add priority label once you become one! ๐Ÿ˜„

i have create new Query

query searchQuestion($keyword: String!, $companyId: ID!) {
  searchQuestion(keyword: $keyword, companyId: $companyId) {
    title
  }
}

again same error

Could you create a small reproduction codesandbox? This way I can help you more quickly.

Thanks mate for your time. it's not issue in Graphql-shield.
it's because of my resolver. some error was there but shows 'Not Authorised!' Error so i thought it's because of Graphql-shield

Try setting debug option to true. This way shield won't mask internal errors.

PS.: Feel free to Tweet about the response time on new issues in GraphQLShield ๐Ÿ˜‰