From 4c4b1e0fedab1e9051c08ef6f9cd5f1dd870e584 Mon Sep 17 00:00:00 2001 From: Jacob Bare Date: Thu, 10 Jun 2021 11:07:03 -0500 Subject: [PATCH] Use `mutations.Website.redirectTo` in `redirectTo` resolver If the `mutations.Website.redirectTo` is present, use it to resolve the `Content.redirectTo` value, otherwise resolve as normal. --- .../graphql/definitions/platform/content/interfaces/content.js | 2 +- .../graphql-server/src/graphql/resolvers/platform/content.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/services/graphql-server/src/graphql/definitions/platform/content/interfaces/content.js b/services/graphql-server/src/graphql/definitions/platform/content/interfaces/content.js index 84cd4b7a4..40bae27d3 100644 --- a/services/graphql-server/src/graphql/definitions/platform/content/interfaces/content.js +++ b/services/graphql-server/src/graphql/definitions/platform/content/interfaces/content.js @@ -74,7 +74,7 @@ interface Content @requiresProject(fields: ["type"]) { siteContext(input: ContentSiteContextInput = {}): ContentSiteContext! @projection(localField: "_id", needs: ["type", "linkUrl", "mutations.Website.slug", "mutations.Website.primarySection", "mutations.Website.primaryCategory", "mutations.Website.alias", "mutations.Website.canonicalUrl", "mutations.Website.noIndex"]) # Determines if this content item should redirect to another location. - redirectTo: String @projection(localField: "type", needs: ["linkUrl"]) + redirectTo: String @projection(localField: "type", needs: ["linkUrl", "mutations.Website.redirectTo"]) # Returns related, published content based on input flags relatedContent(input: ContentRelatedContentInput = {}): ContentConnection! @projection(localField: "_id", needs: ["relatedTo", "mutations.Website.primarySection"]) userRegistration: ContentUserRegistration! @projection(localField: "mutations.Website.requiresAccessLevels", needs: ["mutations.Website.requiresRegistration"]) diff --git a/services/graphql-server/src/graphql/resolvers/platform/content.js b/services/graphql-server/src/graphql/resolvers/platform/content.js index cf42675ca..17cc344ad 100644 --- a/services/graphql-server/src/graphql/resolvers/platform/content.js +++ b/services/graphql-server/src/graphql/resolvers/platform/content.js @@ -471,6 +471,8 @@ module.exports = { redirectTo: (content) => { const { type, linkUrl } = content; + const redirectTo = get(content, 'mutations.Website.redirectTo'); + if (redirectTo) return redirectTo; const types = ['Promotion', 'TextAd']; if (!types.includes(type)) return null;