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.

Always getting global fallback error, how to know which field caused it

See original GitHub issue

Question about GraphQL Shield

Is there a way to know on which field definition shield is deciding to use global fallbackRule. When I have set it to fallbackRule: deny I am seeing it always throwing the fallbackError. I am using createCollection mutation, and I have tried setting createCollection: allow and Collection: allow too, and it doesn’t make any difference vs setting rules on all of their fields individually as I have in my permissions system. My options object (I am getting no debug info too, it’s all the way fallback):

{
    debug: true, //process.env.NODE_ENV !== "production",
    // to see errors thrown inside resolvers
    allowExternalErrors: true, // process.env.NODE_ENV !== "production",
    fallbackError: new Error(
      "You are not authorised to access these resources!"
    ),
    fallbackRule: deny // FIXME: fallback error is thrown on deny
  }

Error logged is:

{"message":"You are not authorised to access these resources!","locations":[{"line":14,"column":5}],"path":["updateCollection","collection"],"extensions":{"code":"INTERNAL_SERVER_ERROR","exception":{"stacktrace":["Error: You are not authorised to access these resources!","    at Object.<anonymous> (G:\\apollo\\prod\\apollo-server\\src\\auth\\permissions.ts:252:20)","    at
Module._compile (module.js:652:30)","    at Module.m._compile (G:\\apollo\\prod\\apollo-server\\node_modules\\ts-node\\src\\index.ts:439:23)","    at Module._extensions..js (module.js:663:10)","    at Object.require.extensions.(anonymous function) [as .ts] (G:\\apollo\\prod\\apollo-server\\node_modules\\ts-node\\src\\index.ts:442:12)","    at Module.load (module.js:565:32)","    at
tryModuleLoad (module.js:505:12)","    at Function.Module._load (module.js:497:3)","    at Module.require (module.js:596:17)","
at require (internal/module.js:11:18)","    at Object.<anonymous> (G:\\apollo\\prod\\apollo-server\\src\\makeExecutableSchema.ts:14:1)","    at Module._compile (module.js:652:30)","    at Module.m._compile (G:\\apollo\\prod\\apollo-server\\node_modules\\ts-node\\src\\index.ts:439:23)","    at Module._extensions..js (module.js:663:10)","    at Object.require.extensions.(anonymous function) [as .ts] (G:\\apollo\\prod\\apollo-server\\node_modules\\ts-node\\src\\index.ts:442:12)","    at Module.load (module.js:565:32)"]}}}

I should be reproducing this, but since my whole night is lost to this, I am assuming it’s something silly that I am doing.

  • [x ] I have checked other questions and found none that matches mine.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7

github_iconTop GitHub Comments

3reactions
devautorcommented, Feb 18, 2019

@maticzav This current design definitely makes sense. I had let my mind totally slip setting permissions on these mutation responses types. So much of my time wasted not following simple rules. Thanks maticzav, strucking out genius title against myself 😦

I will try this and let this thread know!

1reaction
maticzavcommented, Feb 18, 2019

Hey @devautor 👋,

Thanks for the reproduction. I believe you are experiencing the problem because createCustomerCartItem returns CreateCustomerCartItemMutationResponse which is, as defined by fallbackRule, denied by default.

There’s an open issue about the auto-guessed types and their rules, but as mentioned there, it is not possible to have a system which would meaningfully guess the provisions of the return types because a particular type can be returned by multiple fields with different restraints.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Always getting global fallback error, how to know which ...
I am using createCollection mutation, and I have tried setting createCollection: allow and Collection: allow too, and it doesn't make any ...
Read more >
Full Stack Error Handling with GraphQL and Apollo
If networkError is present in your response, it means your entire query was rejected, and therefore no data was returned. For example, the ......
Read more >
fallback method wasn't found: fallback
I am new to micro-services and I keep have challenges which I believe are minor but can't solve ...
Read more >
15.00 - ALTER TABLE, FALLBACK, and Read From Fallback
When a read error occurs in this case, the file system reads the fallback copy of the rows and reconstructs a memory‑resident image...
Read more >
Best Practices for Node.js Error-handling
Developers working with Node.js sometimes find themselves writing not-so-clean code while handling all sorts of errors. This article will introduce you to ...
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