If fallbackRule is defined, it ignores the other rules
See original GitHub issueBug report
I just tried to set the fallbackRule
to deny
. The problem is, when this is set, even if the other rules pass, the server gives a Not authorized error.
- This is my GraphQL Schema.
type Branch {
id: ID!
name: String
}
type Query {
branch(where: BranchWhereUniqueInput!): Branch
branches(
where: BranchWhereInput
orderBy: BranchOrderByInput
skip: Int
after: String
before: String
first: Int
last: Int
): [Branch]!
}
- This is the invoked query
query {
restaurant(where: { id: "_" }) {
id
}
}
- I use these permissions
const isAuthenticated = rule({ cache: 'no_cache' })(async (parent, args, ctx) => {
console.log(ctx.user);
return ctx.user !== null;
});
const permissions = shield(
{
Query: {
branches: isAuthenticated,
branch: isAuthenticated,
},
},
{
fallbackRule: allow,
graphiql: true
}
);
- This is the error I see
Error: Not Authorised!
Expected behaviour
The user is coming to the isAuthenticated
method. But if fallbackRule
is defined, the isAuthenticated
method runs and the user gets console logged. But it still returns Error: Not Authorised!
. If I remove fallbackRule
or set it to allow
, the query runs without issue and also blocks if the user is actually not there.
Actual behaviour
The fallbackRule
should be executed only if there are no rules set for the query.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:14
Top Results From Across the Web
If fallbackRule is defined, it ignores the other rules #211 - GitHub
I just tried to set the fallbackRule to deny . The problem is, when this is set, even if the other rules pass,...
Read more >"Fallback" rule in Webpack config - Stack Overflow
I have tried specifying a rule in last position with a very permissive test: , however it seems to take precedence regardless of...
Read more >FALLBACK Rule - TechDocs - Broadcom Inc.
Use the FALLBACK rule to enable a user or group to use (or be denied use of) the LOGON ... Defines the set...
Read more >base rule - definition - Pega Community
The base rule supporting a circumstance-qualified rule or time-qualified rule is the fallback rule that is selected by rule resolution when the circumstances...
Read more >Shield - GraphQL Code Generator
A rule map must match your schema definition. You should create a collection of rules that you use in your map to define...
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
Make sure response type also allowed.
Example:
Not enough for login whitelist:
Should be:
Or just add custom
fallbackRule
and allow fields:In following example, deny queries and mutations which have no rules but allow types and fields. So once you have rule that allows Query or Mutation you don’t have to add rule for returned type and (or) it’s fields.
You can play further with fallback for your needs.
#300