Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #771 from B77Mills/excludeLabels
Browse files Browse the repository at this point in the history
Add excludeLabels support to all published content query
  • Loading branch information
brandonbk authored Aug 18, 2023
2 parents f673ff3 + 981f618 commit a688efc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const date = (v) => (v instanceof Date ? v.valueOf() : v);
* @param {number} params.sectionId The section ID.
* @param {number[]} [params.includeTaxonomyIds] An array of taxonomies to include.
* @param {string[]} [params.includeLabels] An array of labels to include.
* @param {string[]} [params.excludeLabels] An array of labels to exclude.
* @param {string[]} [params.contentTypes] An array of content types to include.
* @param {boolean} [params.withSite] Whether the content must belong to the current site.
* @param {boolean} [params.requiresImage] Whether the content must have an image.
Expand Down Expand Up @@ -47,6 +48,7 @@ module.exports = async (apolloClient, {
includeTaxonomyIds,

includeLabels,
excludeLabels,

excludeContentIds,

Expand All @@ -69,6 +71,7 @@ module.exports = async (apolloClient, {
excludeContentTypes,
includeTaxonomyIds,
includeLabels,
excludeLabels,
excludeContentIds,
siteId,
withSite,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -533,10 +533,12 @@ input AllPublishedContentQueryInput {
excludeContentTypes: [ContentType!] = []
"Limit results to items matching none of these ids."
excludeContentIds: [Int!] = []
"Limit results to items matching at least one of these ids."
"Limit results to items having at least one of these labels."
excludeLabels: [String!]! = []
"Limit results to items that have at least one of these taxonomy ids."
includeTaxonomyIds: [Int!] = []
"Limit results to items matching at least one of these labels."
includeLabels: [String!] = []
includeLabels: [String!]! = []
"Limit results to items that have a primary image."
requiresImage: Boolean = false
"Include child sections when limiting by primary section id."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,7 @@ module.exports = {
excludeContentIds,
includeTaxonomyIds,
includeLabels,
excludeLabels,
requiresImage,
sectionBubbling,
sort,
Expand Down Expand Up @@ -967,9 +968,10 @@ module.exports = {
if (includeTaxonomyIds.length) {
query['taxonomy.$id'] = { $in: includeTaxonomyIds };
}
if (includeLabels.length) {
query.labels = { $in: includeLabels };
}

if (includeLabels.length) query.$and.push({ labels: { $in: includeLabels } });
if (excludeLabels.length) query.$and.push({ labels: { $nin: excludeLabels } });

if (requiresIndexed) {
query.$and.push({ $or: [{ 'mutations.Website.noIndex': { $exists: false } }, { 'mutations.Website.noIndex': false }] });
}
Expand Down

0 comments on commit a688efc

Please sign in to comment.