Skip to content

Commit

Permalink
Included relations if static resource is post | page (#10148)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
cotko authored and kirrg001 committed Dec 3, 2018
1 parent ed77192 commit 65a66ac
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions core/server/services/routing/controllers/static.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 65a66ac

Please sign in to comment.