From 65a66ac007e2aa84770383f2ca6d29ce83a47d53 Mon Sep 17 00:00:00 2001 From: cotko Date: Mon, 3 Dec 2018 19:26:21 +0100 Subject: [PATCH] Included relations if static resource is post | page (#10148) refs #10082 - this is a requirement if a static route represents a single resource e.g. `data: page.team` - the page resource will no longer live on it's original static url - instead, it now lives somewhere else - that means the whole site needs to act the same than the original static url - the resource does not contain any relations - we don't forward the correct context (page, post, user?) - we override the `include` property for now - need to wait for more use cases or bug reports for this controller - more changes will follow asap --- core/server/services/routing/controllers/static.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/server/services/routing/controllers/static.js b/core/server/services/routing/controllers/static.js index fad03dd412e..76404417dc4 100644 --- a/core/server/services/routing/controllers/static.js +++ b/core/server/services/routing/controllers/static.js @@ -7,6 +7,16 @@ function processQuery(query, locals) { const api = require('../../../api')[locals.apiVersion]; query = _.cloneDeep(query); + // CASE: If you define a single data key for a static route (e.g. data: page.team), this static route will represent + // the target resource. That means this static route has to behave the same way than the original resource url. + // e.g. the meta data package needs access to the full resource including relations. + // We override the `include` property for now, because the full data set is required anyway. + if (_.get(query, 'resource') === 'posts') { + _.extend(query.options, { + include: 'author,authors,tags' + }); + } + // Return a promise for the api query return (api[query.alias] || api[query.resource])[query.type](query.options); }