Closed PlagueFPS closed 1 month ago
I tried to reproduce this but couldn't. I'm getting the draft data as expected with my fields filled in.
If you're still encountering this on the latest beta, could you provide a reproduction please?
sounds like it could be the same issue as this one: https://github.com/payloadcms/payload/issues/6813
I provided some repro steps there
Edit: nvm sorry 😅
I tried to reproduce this but couldn't. I'm getting the draft data as expected with my fields filled in.
If you're still encountering this on the latest beta, could you provide a reproduction please?
What? That's even worse, the issue I was stating is that there shouldn't be any drafts being returned at all. It's a production environment why are drafts being returned via the local API if we are not in draftMode
sounds like it could be the same issue as this one: #6813
I provided some repro steps there
Commented on that issue but linking here for visibility: https://github.com/payloadcms/payload/issues/6813#issuecomment-2358997794
Also experiencing the same where I am getting draft docs while explicitly specifying drafts: false
using the Local API
I am going to close this issue as I do not think it is real.
When querying with draft: false, currently this means the returned documents will be the last published version of a doc or the last saved version if no published versions exist for a document.
If you are looking to query only published documents you will need to constrain your query with
payload.find({
collections: 'posts',
where: {
status: {
equals: 'published'
}
}
})
The current draft argument is more of a "latest" query, as in, give me the newest updates on a document. I hope this helps!
I am going to close this issue as I do not think it is real.
When querying with draft: false, currently this means the returned documents will be the last published version of a doc or the last saved version if no published versions exist for a document.
If you are looking to query only published documents you will need to constrain your query with
payload.find({ collections: 'posts', where: { status: { equals: 'published' } } }) The current draft argument is more of a "latest" query, as in, give me the newest updates on a document. I hope this helps!
Okay, this was a bit unintuitive compared to other CMSs so I didn't realize that the where clause was needed. My expectation was if draft was true, return to me all published and non-published documents, and those published documents if they had any changes would contain them. This worked, the issue I encountered was when draft was false, it would still return me unpublished documents just with all their fields as null. That was the confusing part, now I understand I need to specify both draft: false and the where clause when working with draftMode.
This adds some additional overhead, but it isn't the end of the world. I appreciated your response Jarrod.
This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.
Link to reproduction
No response
Environment Info
Describe the Bug
In production, the local API returns draft documents with the
id
,_status
,updatedAt
, andcreatedAt
fields filled in correctly while all other fields are returned as null. The local API shouldn't return drafts at all unlessdraftMode
is enabled in production.Reproduction Steps
draft
property in the query, passing true if indraftMode
or in development and false anywhere elseAdapters and Plugins
No response