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.

Conflict between options `debug`, `fallback` and `allowExternalErrors`

See original GitHub issue

Bug report

  • I have checked other issues to make sure this is not a duplicate.

Describe the bug

Hey @maticzav I have tests some config, and it’s seems there is some conflicts between debug, fallback and allowExternalErrors.

In my config, I just put allowExternalErrors to true (like in my previous settings in the v2) The bug is here: https://github.com/maticzav/graphql-shield/blob/eb333b85db36afff5729e37553985f213f8513e4/src/rules.ts#L69-L73

The problem is that the try/catch is managed here by the options.debug, why?

Example rule

const authRule = rule()(async (parent, args, ctx: Context) => {
  const user = ctx.user
  if (!user || !user.id) {
    throw new MyAwesomeAuthenticationError()
  }
  return true
})

shield({
  Query: {
    me: authRule
  }
}, {
  allowExternalErrors: true
}

Expected behavior

Receive a custom error like Not Authenticated or You're not allowed etc.

Actual behaviour

I always receive the default fallback error Not Authorised!.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
johannpinsoncommented, Sep 19, 2018

Hey! As discussed together, I understand better the difference between “returning” and “rejecting” eventual errors between an rule and the middleware function. All is good for me, I close the issue 👍

0reactions
maticzavcommented, Sep 17, 2018

I think you should return a custom error if you want to provide additional information. I imagine fallback could be a function but can hardly see significant benefits in doing it.

I am still confused about the 3. topic. If I remember the tests correctly, there is no difference in returning an error and throwing it. Could you provide the expected and actual response so I can better understand what the nucleus of the issue is?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Conflict between options debug , fallback and ... - GitHub
I have tests some config, and it's seems there is some conflicts between debug , fallback and allowExternalErrors . In my config, I...
Read more >
Errors – GraphQL Shield
Errors thrown in resolvers can be tracked using debug option. This way Shield ensures your code is production ready at all times.
Read more >
@webiny/plugins | Yarn - Package Manager
Important: This documentation covers modern versions of Yarn. For 1.x docs, see classic.yarnpkg.com.
Read more >
Use Rover with graphql-shield - node.js - Stack Overflow
export const permissions = shield( { Query: { SubgraphIntrospectQuery: allow, }, }, { fallbackRule: deny, debug: true, allowExternalErrors: true ...
Read more >
Debugging/Running of Blazor Server not possible due to ...
Debugging /Running of Blazor Server not possible due to "InvalidOperationException: Cannot find the fallback endpoint specified by route values: { page: /_Host, ...
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