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.

or rule not working

See original GitHub issue

Bug report

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

Describe the bug

Using an “or” fails to run all rules.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

(Delete the filler code and replace it with your own)

  1. This is my GraphQL Schema.
type Query {
  hello: String
}
  1. This is the invoked query
hello
  1. I use these permissions
const permissions = shield({
  Query: {
    hello: or(rules.isSuperAdmin, rules.isCompanyManager),
  }
})
  1. This is the error I see
Not Authorised!

Expected behavior

Expected to be granted permission as isCompanyManager returns true.

Additional context

Here are the rule definitions used;

export const rules = {
  isSuperAdmin: rule(options)(async (_, args, ctx, info) => {
    const res = ctx.req.user.permissions.filter(
      e => e.group === "superAdmin"
    ).length
      ? true
      : false;
    return res;
  }),
  isCompanyManager: rule(options)(async (_, args, ctx, info) => {
    const res = ctx.req.user.permissions.filter(
      e => e.group === "companyManager"
    ).length
      ? true
      : false;
    return res;
  })
};

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
seawattscommented, Aug 29, 2019

I’m actually getting the same error. Setting cache type doesn’t help.

Update: It actually only works when I don’t try to reference parent or args.

Update 2: There was actually an exception being thrown 😬in the rule.

It would be nice to be able to see the output of the error being thrown.

2reactions
mhaagenscommented, Jul 2, 2019

Sooo…i wrote no-cache instead of no_cache, thats why it broke. My bad!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix It When Outlook Rules Are Not Working - Lifewire
How to Fix Outlook Rules Not Working ; File > ; Manage Rules & Alerts. Check the box next to the rule you...
Read more >
The rule I created does not work - Microsoft Support
Cause: Rules run automatically on messages only as you receive or send them. · At the bottom of the navigation pane, click Mail...
Read more >
[Solved] Outlook Rules Are Not Working | Complete Guide
How to Fix It When Outlook Rules Are Not Working? · Open Outlook and go to Files > Rules and Alerts. · In...
Read more >
How to Fix Outlook Rules Not Working in Windows 10
Solved: Outlook Rules not working · Method 1. Optimize the size of your rules · Method 2. Enable rules for your account ·...
Read more >
Outlook Rules Not Working? Try These 11 Fixes
Open Outlook on the web and click on the Settings icon · Select View All Settings Option and go to Mail · Click...
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