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 addpriority
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.
https://github.com/nikunj321/findJob-server/tree/searchqs
i love to create codesandbox . but i don't know if i can setup postgresql there.
https://codesandbox.io/s/inspiring-grothendieck-giqbu?file=/src/resolvers/queryQuestion.js
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 ๐