Conflict between options `debug`, `fallback` and `allowExternalErrors`
See original GitHub issueBug 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:
- Created 5 years ago
- Reactions:1
- Comments:7 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 👍
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?