From eec3d4187ebd39a829acf5e4edcd7817963624a5 Mon Sep 17 00:00:00 2001 From: Shinsina Date: Tue, 30 Nov 2021 10:16:12 -0600 Subject: [PATCH] Use customAttributes over import entity. --- .../src/graphql/definitions/platform/content/index.js | 11 +++++++++-- .../src/graphql/resolvers/platform/content.js | 7 +++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/services/graphql-server/src/graphql/definitions/platform/content/index.js b/services/graphql-server/src/graphql/definitions/platform/content/index.js index 8657a3023..a8f473ff9 100644 --- a/services/graphql-server/src/graphql/definitions/platform/content/index.js +++ b/services/graphql-server/src/graphql/definitions/platform/content/index.js @@ -473,8 +473,6 @@ input ContentEventDatesMutationInput { } input AllPublishedContentQueryInput { - "Allows for return of the _import.entity field if requested" - importEntity: String "Limits results to content with a primary site matching the current site context " withSite: Boolean = true "A websiteSite identifier. If present, overrides the current site context." @@ -487,6 +485,8 @@ input AllPublishedContentQueryInput { sectionId: Int "Deprecated. Use includeContentTypes instead." contentTypes: [ContentType!] = [] + "Limit results to items matching specific custom attribute key value pairs" + customAttributes: [ContentCustomAttributeQueryInput] = [] "Limit results to items matching at least one of these types." includeContentTypes: [ContentType!] = [] "Limit results to items matching none of these types." @@ -568,6 +568,13 @@ input ContentCustomAttributeInput { path: String! } +input ContentCustomAttributeQueryInput { + "The object property key to query against" + key: String! + "The value of that property key to query against" + value: String! +} + input AllContentQueryInput { siteId: ObjectID status: ModelStatus = active diff --git a/services/graphql-server/src/graphql/resolvers/platform/content.js b/services/graphql-server/src/graphql/resolvers/platform/content.js index b17adc7cf..a1ba5e22d 100644 --- a/services/graphql-server/src/graphql/resolvers/platform/content.js +++ b/services/graphql-server/src/graphql/resolvers/platform/content.js @@ -861,7 +861,7 @@ module.exports = { beginning, ending, withSite, - importEntity, + customAttributes, } = input; // @deprecated Prefer includeContentTypes over contentTypes. @@ -875,7 +875,10 @@ module.exports = { excludeContentTypes, }); - if (importEntity) query['_import.entity'] = importEntity; + customAttributes.forEach(({ key, value }) => { + const fullKeyPath = `customAttributes.${key}`; + query.$and.push({ [fullKeyPath]: value }); + }); const siteId = input.siteId || site.id(); if (withSite && siteId) query['mutations.Website.primarySite'] = siteId;