payloadcms / next-payload

A utility to deploy Payload serverlessly within a Next.js app
308 stars 42 forks source link

Versions API not filtering parent correctly #82

Closed ghardin1314 closed 7 months ago

ghardin1314 commented 1 year ago

When setting drafts: true on my collection, for each record in the collection its shows the drafts for every other record in the same collection. This doesn't seem to happen on a server deployment of payload so I think it has to do with the route handler in this package.

Checking the network requests I see

http://localhost:4000/api/articles/versions?depth=0&where%5Band%5D%5B0%5D%5Bparent%5D%5Bequals%5D=65370802b2cc1bc88ae4a087&where%5Band%5D%5B1%5D%5BupdatedAt%5D%5Bgreater_than%5D=2023-10-23T23%3A55%3A46.069Z

which decoded is (and seems correct)

depth: 0
where[and][0][parent][equals]: 65370802b2cc1bc88ae4a087
where[and][1][updatedAt][greater_than]: 2023-10-23T23:55:46.069Z

The api response I am getting is

{
    "docs": [
        {
            "id": "65370802b2cc1bc88ae4a089",
            "parent": "65370802b2cc1bc88ae4a087",
            "version": {
                ...
            },
            "createdAt": "2023-10-23T23:55:46.069Z",
            "updatedAt": "2023-10-23T23:55:46.069Z",
            "latest": true
        },
        {
            "id": "65370765b2cc1bc88ae49f61",
            "parent": "6531779e75328c00b23c4f3b",
            "version": {
                ...
            },
            "createdAt": "2023-10-19T18:38:22.513Z",
            "updatedAt": "2023-10-23T23:53:09.162Z",
            "latest": true
        },
        {
            "id": "653177dd75328c00b23c4faa",
            "parent": "653177dd75328c00b23c4fa8",
            "version": {
                ...
            },
            "createdAt": "2023-10-19T18:39:25.528Z",
            "updatedAt": "2023-10-19T18:39:25.528Z"
        },
        {
            "id": "6531779e75328c00b23c4f3d",
            "parent": "6531779e75328c00b23c4f3b",
            "version": {
                ...
            },
            "createdAt": "2023-10-19T18:38:22.513Z",
            "updatedAt": "2023-10-19T18:38:22.513Z"
        },
        {
            "id": "6531770d75328c00b23c4def",
            "parent": "6531770d75328c00b23c4ded",
            "version": {
                ...
            },
            "createdAt": "2023-10-19T18:35:57.285Z",
            "updatedAt": "2023-10-19T18:35:57.285Z",
            "latest": true
        },
        {
            "id": "653176d075328c00b23c4d82",
            "parent": "653176d075328c00b23c4d80",
            "version": {
                ...
            },
            "createdAt": "2023-10-19T18:34:56.219Z",
            "updatedAt": "2023-10-19T18:34:56.219Z",
            "latest": true
        }
    ],
    "totalDocs": 6,
    "offset": null,
    "limit": 6,
    "totalPages": 1,
    "page": null,
    "pagingCounter": null,
    "hasPrevPage": false,
    "hasNextPage": false,
    "prevPage": null,
    "nextPage": null
}

as you can see, the filtering by parent does not seem to be working properly

ghardin1314 commented 11 months ago

@JarrodMFlesch have you had a chance to look at this yet? Its the main issue from allowing us to use this in production.

I created a minimal reproduction pulled from our code here with instructions

https://github.com/ghardin1314/payload-next-issues

jacobsfletch commented 7 months ago

Hey @ghardin1314, this repo will soon be archived because it's been merged into the main Payload repo here: https://github.com/payloadcms/payload/tree/main/packages/next. Payload 3.0 ships with native support for Next.js and is currently out in beta here: https://github.com/payloadcms/payload-3.0-demo. I'm going to close this issue now but feel free to keep the conversation going either as a GitHub Discussion or on Discord. If think issue persists, feel free to open a new ticket on either the demo repo or the monorepo with the 3.x-beta label, and be sure to include a reproduction so we can fix it faster.