3

Is there a way I can query for all objects where a child object is null?

I am trying to do something like this:

{
GetAllAccounts (  where: { accountManager: { eq: null} })  {
    accountManagerFid,
      accountManager {
        userLastName 
      }
  }
}

That doesn't work because accountManager is an object with it's own filter so it's expecting me to filter on some field on the accountManager object once I open that nested curly bracket after "accountManager:".

I am looking for the right way to query for "All Accounts where accountManager child object does not exist at all"

2
  • Did you ever solve this? Facing the same issue myself. Commented May 24, 2022 at 10:28
  • I never found what I thought was the perfect solution, but I posted a work-around below. Commented May 27, 2022 at 20:28

1 Answer 1

1

I never found the perfect solution, but here are the notes I took that describe a work-around I used:

So far this is the closest I have figured out (I have to look at the foreign key and not for the child object itself):

{
GetAllAccounts(  where: {  accountManagerFid: {eq: null} }) {
    accountManagerFid,
      accountManager {
        userLastName 
      }
  }
}
 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.