question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue
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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
maticzavcommented, Apr 15, 2021

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 😉

0reactions
nikunj321commented, Apr 15, 2021

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

401 Unauthorized Error: What It Is and How to Fix It
The 401 Unauthorized Error is an HTTP response status code indicating that the client could not authenticate a request.
Read more >
403 Forbidden vs 401 Unauthorized HTTP responses
There's a problem with 401 Unauthorized, the HTTP status code for authentication errors. And that's just it: it's for authentication, not authorization.
Read more >
When I went to use my credit card the store told me ...
If a charge is not authorized, it usually means that there is a problem with the account or that you are at, near,...
Read more >
HTTP Error 403 Forbidden: What It Means and How to Fix It
The 403 (Forbidden) status code indicates that the server understood the request but refuses to authorize it... If authentication credentials ...
Read more >
How to Quickly Fix the 401 Unauthorized Error (5 Methods)
The 401 (Unauthorized) status code indicates that the request has not been applied because it lacks valid authentication credentials for the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found