-
Notifications
You must be signed in to change notification settings - Fork 618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Headless CMS - Introduce New xBy
and xOn
Entry Meta Fields
#3725
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/cypress |
Cypress E2E tests have been initiated (for more information, click here). ✨ |
/cypress |
Cypress E2E tests have been initiated (for more information, click here). ✨ |
/cypress |
Cypress E2E tests have been initiated (for more information, click here). ✨ |
adrians5j
changed the title
Headless CMS - Introduce New
Headless CMS - Introduce New Dec 20, 2023
xBy
and xOn
Meta FieldsxBy
and xOn
Entry Meta Fields
/cypress |
Cypress E2E tests have been initiated (for more information, click here). ✨ |
brunozoric
approved these changes
Dec 22, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
The main purpose of this PR is to introduce new
xBy
andxOn
entry meta fields for all CMS entries.More specifically, instead of just having revision-level meta fields (
createdBy
,ownedBy
,modifiedBy
,createdOn
,savedOn
,publishedOn
), each CMS entry now has revision and entry level fields:With this, there are additional changes that this PR brings. More in the following section.
Other Changes
1. Eight Publishing-related Fields
Instead of having just a single
publishedOn
field, CMS entries now have eight publishing-related fields that users can use accordingly:revisionFirstPublishedOn
revisionLastPublishedOn
revisionFirstPublishedBy
revisionLastPublishedBy
entryFirstPublishedOn
entryLastPublishedOn
entryFirstPublishedBy
entryLastPublishedBy
2. Improved Meta Fields Consistency
Prior to this PR, a CMS entry did not have
savedBy
but hadsavedOn
. It also did not havemodifiedOn
, but did havemodifiedBy
. By adding the missingsavedBy
andmodifiedOn
fields, this inconsistency has now been resolved.3. Simplified Overriding of Publishing-related Meta Fields and Instant Publishing
Prior to this PR, if a user wanted to create an entry with an already set published date, the user would need to first create an entry with the published date, and then publish the record with a special
updateSavedOn
andupdatePublishedOn
flags set tofalse
. In other words, two GraphQL mutations would need to be performed.With this PR, this process is simpler. The user now can achieve the same thing with a single GraphQL mutation, where they just set the
status
field of an entry topublished
, and set the publishing date. No need to call the subsequent publish mutation.4. ACO, FM, APW Also Using New Fields
The three apps that rely on HCMS (ACO, FM, and APW) to store data were also revisited and updated accordingly.
In short, on GraphQL/SDK levels, users still use the regular
createdOn
,createdBy
,modifiedOn
, ... fields. But, behind the scenes, these fields are actually mapped to entry-level fields, so:entryCreatedOn
,entryCreatedBy
,entryModifiedOn
, ...This is fine because all of the records within the three apps do not use revisions. They are all working with the first revision of an CMS entry and never publish anything.
5. ACO Filters - Using Revision IDs instead of Entry IDs
While testing, I noticed the new Filters ACO entity works with entry IDs. At first, it looked fine, but then I noticed that when getting entries, we have to rely on
getEntry
call instead ofgetEntryById
call. This is problematic because thegetEntry
behind the scenes actually performs alistEntries
call. Meaning, in DDB+ES systems, the query would be ran against ES. In order to make this more performant, we need to usegetEntryById
, and that also means we need to work with revision IDs, not with entry IDs.6. Refactored
createEntry.crud.ts
FileOvertime, the
createEntry.crud.ts
file has grown into a file with ~2300LOC. This introduces clarity problems, and increases the possibility of merge conflicts and bugs.It'd be time consuming to refactor everything, so I just chose one single thing and that is the code that deals with the creation of
const entry = { ...
data within different CRUD methods. Ended up extractingconst entry = { ...
data preparation code for six different CRUD methods, which is now placed in six separate files:Ultimately, this reduced the LOC from ~2300 to ~1500. Not to mention that the actual
createContentEntryCrud
function now starts on L98, which was previously L260.7.
useTestModel
Testing UtilityDuring writing tests, I created a simple
useTestModelHandler
handler that works with a simple model with justtitle
andslug
fields, which enables us to test some of the more simple use cases.It exposes both manage and read API methods, and additionally the
setup
method that sets everything up for the user (creates the content model group and the actual content model). No need to import another utility (setupGroupAndModels
) in order to do this. Example usage can be found in four new test files, one of which is packages/api-headless-cms/tests/contentAPI/contentEntriesOnByMetaFieldsQueries.test.ts.8. Added
jest-extended
NPM PackageThe
jest-extended
package is a collection of often used matchers, like for exampletoBeDateString
9. Introduced
yarn webiny open
CommandIn order to access the Admin/Website apps more easily, users can now simply run
yarn webiny open admin --env xxx
oryarn webiny open website --env xxx
. No need to get the URLs viayarn webiny output
oryarn webiny info
commands and then click the URL or manually copy/paste it into the browser.How Has This Been Tested?
Jest.
Documentation