-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Labels
Description
In apostrophe-global, when there is an object field containing a joinByOne field, the relationship is not resolved as expected when in Live mode, the field will be missing completely (and the ID field will retain draft version's ID).
Steps to Reproduce
- Start an empty project with apostrophe cli and
npm iinside - cd into the new project and do
npm install --save apostrophe-workflow - Add the default snippet
'apostrophe-workflow': {
// IMPORTANT: if you follow the examples below,
// be sure to set this so the templates work
alias: 'workflow',
// Recommended to save database space. You can still
// export explicitly between locales
replicateAcrossLocales: false
},
'apostrophe-workflow-modified-documents': {}
- Create
lib/modules/apostrophe-global/index.jswith the following content:
module.exports = {
addFields: [
{
name: 'demoField',
label: 'Demo Field',
type: 'object',
schema: [{
"type": "joinByOne",
"required": true,
"name": "_demoFieldInner",
"label": "Demo Field Inner",
"withType": "apostrophe-page",
}],
},
{
"type": "joinByOne",
"required": true,
"name": "_demoField2",
"label": "Demo Field 2",
"withType": "apostrophe-page",
}
]
}- In
lib/modules/apostrophe-pages/views/pages/home.html, add<script>console.log({{ data.global|json }})</script>for testing. - Start the app, login as admin, edit Global, for both field pick Home itself, then save draft, open Global again, commit.
- In Draft mode, observe in terminal that
demoField2Id,_demoField2,demoField.demoFieldInnerId,demoField._demoFieldInnerare all present as expected:

- Switch to Live mode, observe in terminal that
demoField2Id,_demoField2, anddemoField.demoFieldInnerIdare present, butdemoField._demoFieldInneris not. Moreover, the ID indemoField.demoFieldInnerIdis still storing draft version's ID (maybe hinting the commit flow is forgetting to update this ID to point to the Live home page's ID):

Notes
The field setup should be valid, this works perfectly fine before workflow module is installed.