Element API, query entries where relationship field ':empty:' AND the same relationship field with specified entry ID Element API, query entries where relationship field ':empty:' AND the same relationship field with specified entry ID.
Can't seem to figure out how to do this without performing two separate queries and merging the objects together. However I don't see a way to perform this within the Element API.
The answer to this other question seems like an approach? Option 1 or Option 2? Not quite sure as this looks all foreign to me with sparse documentation, and it's not specific to my issue.
How can I query entries based on a Matrix Block Type?
Seeing as you can't use ':empty:' with relatedTo, I'm stuck here.
return [
    'criteria' =&gt; [
        'section' =&gt; 'mySection',
        /* this is the myRelatedField entries field relating to other Section Entry ID */
        'relatedTo' =&gt; (['targetElement' =&gt; $otherSectionEntryId]),
        /* unable to use :empty: with the relatedTo, incorporating myRelatedField :empty: below will return zero results */
        /* cannot use this below */
        'myRelatedField' =&gt; ':empty:'
    ],
    'transformer' =&gt; function(Entry $entry) {
        return [
            'title' =&gt; $entry-&gt;title
        ];
    }
];

UPDATE with further testing. Various tests used below in trying to use simple relations with :empty:. It looks as though ':empty:' is ignored when utilized in an array.
// results returned where relationship field is empty
'relatedDrinks' =&gt; ':empty:'

// no results returned where relationship field is empty
'relatedDrinks' =&gt; [':empty:']

// results related to drink ID returned
'relatedDrinks' =&gt; [$myDrinkId]

// results returned for drink ID, no results returned with empty
'relatedDrinks' =&gt; [':empty:', $myDrinkId]
Craft will include this functionality in their next release.
https://github.com/craftcms/cms/issues/7256#issuecomment-744644568