Our Section Resolver use a Content Source that hits Arc's GET Section endpoint. Here is what that Content Source looks like:
const resolve = ({ sectionId = "/" }) => {
return `/site/v3/website/dallas-news/section/?_id=${sectionId}`;
};
export default {
resolve,
params: {
sectionId: "text"
}
};
Sections are apparently never deleted, but flagged inactive: true. With our Content Source ☝️, users can get to deprecated inactive sections, which resolve with a status code 200 but are not associated with any content. When this happens, they get blank Section templates. For example:
We want to prevent users from getting to broken, deprecated, inactive Sections. We want https://www.dallasnews.com/cowboys/ and https://www.dallasnews.com/crime/ to display a 404 page instead of a Section template with no content.
The GET ALL Sections has a flag include_inactive that can be used to filter out unwanted sections, but this API endpoint doesn't work for this resolver scenario. It never 404's, it just returns an empty array. Moreover, the filtering sucks– a query of /cowboy returned 100 results... not going to work.
You can apparently throw synthetic 404's from Content Sources. This isn't adequately documented and there are no canonical examples of doing this with fetch.
I tried it anyway. The resultant implementation is more complex and painful to debug– debugging Content Resolvers is opaque and even though it worked locally I couldn't get it to work on any other environment. I don't think this is a good solution.
Can a flag like include_inactive be added to the GET Section API endpoint? I just want to add a query param that prevents old deleted Sections from resolving.
For example:
/site/v3/website/dallas-news/section/?_id=/cowboys&include_inactive=false
/site/v3/website/dallas-news/section/?_id=/sports/cowboys&include_inactive=false
This would make the API endpoint easier to consume via Content Sources. It prevents users from being able to get to inactive sections. It saves me from slogging through an implementation that leans on undocumented features of Content Sources.
Hi Nigel -- Happy to report that the development of this feature is underway and it should be released in the next Publishing Platform release (Sandbox on 5/7/2020).