Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
28 lines
832 B
Plaintext
28 lines
832 B
Plaintext
export const resolveFilterOptions = async (filterOptions, options) => {
|
|
const {
|
|
relationTo
|
|
} = options;
|
|
const relations = Array.isArray(relationTo) ? relationTo : [relationTo];
|
|
const query = {};
|
|
if (typeof filterOptions !== 'undefined') {
|
|
await Promise.all(relations.map(async relation => {
|
|
query[relation] = typeof filterOptions === 'function' ? await filterOptions({
|
|
...options,
|
|
relationTo: relation
|
|
}) : filterOptions;
|
|
if (query[relation] === true) {
|
|
query[relation] = {};
|
|
}
|
|
// this is an ugly way to prevent results from being returned
|
|
if (query[relation] === false) {
|
|
query[relation] = {
|
|
id: {
|
|
exists: false
|
|
}
|
|
};
|
|
}
|
|
}));
|
|
}
|
|
return query;
|
|
};
|
|
//# sourceMappingURL=resolveFilterOptions.js.map |