I’m trying to do a semi-complicated filter of gett...
# orm-help
c
I’m trying to do a semi-complicated filter of getting users that DON’T have an Office assigned, but it’s not giving me the results I expect… There are users in my database that have no Office set Inside resolver:
Copy code
const offices = [
    'PRESIDENT': 'President',
    'VICE_PRESIDENT': 'Vice President',
    'SECRETARY': 'Secretary',
    'TREASURER': 'Treasurer',
];

return ctx.db.query.users(
      {
        where: {
          AND: [
            // Works fine
            { accountStatus: 'ACTIVE' },
            // Works fine
            { accountType_in: args.accountTypes },
            // Returns nothing
            { office_not_in: Object.keys(offices) },
          ],
        },
      },
      info,
    );
Schema:
Copy code
enum Office {
  PRESIDENT
  VICE_PRESIDENT
  SECRETARY
  TREASURER
}

type User {
  ...
  office: Office
}
I’ve tried numerous combinations of
AND
,
OR
,
NOT
,
office_in
,
office_not
, and
office_not_in
, but I can’t crack this one
Thoughts? Suggestions?
office: null,
works 🤦
j
Is there a stack trace or does it just not give you the correct results?
l
‘Offices’ is an array, not an object.
c
@lawjolla I’m grabbing the keys to make an array
@jblevins No stack trace, no error, just didn’t return any results
I got it working with this:
Copy code
return ctx.db.query.users(
      {
        where: {
          AND: [
            { accountStatus: 'ACTIVE' },
            { accountType_in: args.accountTypes },
            { office: null },
          ],
        },
      },
      info,
    );