apostrophe
apostrophe copied to clipboard
Apos3: document the need to include 'type' in the publicApiProjection and flag a missing type as a probable missing projection property.
To Reproduce
Step by step instructions to reproduce the behavior:
- Create a piece-type with the given file, in the
module/presentation
folder :
module.exports = {
extend: '@apostrophecms/piece-type',
options: {
label: 'Présentation',
pluralLabel: 'Présentations',
publicApiProjection: {
title: 1,
body: 1,
}
},
fields: {
add: {
title: {
label: 'Titre de la sous-section de présentation',
type: 'string',
required: true
},
body: {
label: 'Corps de la présentation',
type: 'area',
options: {
widgets: {
'@apostrophecms/rich-text': {
toolbar: ['styles', 'bold', 'italic'],
styles: [
{
tag: 'p',
label: 'Paragraph (P)'
},
{
tag: 'h3',
label: 'Heading 3 (H3)'
}
]
}
}
},
required: true
},
},
group: {
homePresentationFields: {
label: 'Section Présentation',
fields: ['title', 'body']
}
}
}
};
- Run the apostrophe server with
npm run dev
- Make an API call to
http://localhost:3001/api/v1/homePresentation
- See the warning in the console
Expected behavior
There should not be warning in this case.
Details
Version of Node.js: Node v16.13.2. but reproduced on 12 too.
Server Operating System: Reproduced on Windows, Linux, inside a Docker.
Workaround
Adding type :1
to publicApiProjection
makes the warning disapear.
If type
is not part of the response then Apostrophe cannot figure out what to do with the documents because it cannot figure out what type they have and therefore what module manages them.
That doesn't mean this isn't a legitimate ticket, but it might be recast as "document the need to include 'type' in the publicApiProjection and flag a missing type
as a probable missing projection property."
I changed the title accordingly. Perhaps you'd be interested in submitting PRs to a3-docs
and apostrophe
to take care of those things?
Since Apostrophe requires it is there a reason we wouldn't ensure that it's there regardless of the option? I'm not sure why we'd require developers using the public api projection option to know about a core code requirement.
That's a fair question. We could always add type
.
I agree with Alex, if it is always needed by the Apostrophe core we should not be specially aware about it.
@boutell I think I'm witnessing the same behavior (console warning) without any custom projections but using the piece built in relation filter (think of articles filtered by a tag). The strange part is I'm seeing it only when not logged in. I can not confirm it 100% yet because I really lack time to set up a clean PoC. The debug shows me can
receives only `{ _id: xxx } object. Could it be an internal routine (the built in relation type query)?
Totally possible, reproducible steps would be great
On Thu, Jan 27, 2022 at 8:25 AM Miro Yovchev @.***> wrote:
@boutell https://github.com/boutell I think I'm witnessing the same behavior (console warning) without any custom projections but using the piece built in relation filter (think of articles filtered by a tag). The strange part is I'm seeing it only when not logged in. I can not confirm it 100% yet because I really lack time of set up a clean PoC. The debug shows me can receives only `{ _id: xxx } object. Could it be an internal routine (the built in relation type query)?
— Reply to this email directly, view it on GitHub https://github.com/apostrophecms/apostrophe/issues/3626#issuecomment-1023207160, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAH27LKHIX32IM4BWVW4SLUYFBSZANCNFSM5MHT5VTA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you were mentioned.Message ID: @.***>
--
THOMAS BOUTELL | CHIEF TECHNOLOGY OFFICER APOSTROPHECMS | apostrophecms.com | he/him/his
@boutell https://github.com/myovchev/apos-issue-3626 Ccreate an article, assign a tag, create and navigate to an article page type, click the tag, logout and look at the console logs.
Thanks Miro, can we move that to a separate ticket? This issue was more about Apostrophe helping to define better projections automatically.
On Thu, Jan 27, 2022 at 9:49 AM Miro Yovchev @.***> wrote:
@boutell https://github.com/boutell https://github.com/myovchev/apos-issue-3626 Ccreate an article, assign a tag, create and navigate to an article page type, click the tag, logout and look at the console logs.
— Reply to this email directly, view it on GitHub https://github.com/apostrophecms/apostrophe/issues/3626#issuecomment-1023287683, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAH27OEOIY7ZRL7US4BR7LUYFLOBANCNFSM5MHT5VTA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you were mentioned.Message ID: @.***>
--
THOMAS BOUTELL | CHIEF TECHNOLOGY OFFICER APOSTROPHECMS | apostrophecms.com | he/him/his