Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

nested pagination

default discord avatar
sibergenome2 years ago
6

Heyo! I've run into an issue where a the elements of a relationship field gets paginated.



I have the collection

Lineups

which have an

Artists

relation (hasMany: true) field, however there are usually > 100 artists for each lineup.



When i request lineups through the REST api, the artists are automatically paginated to size 10.



I tried accessing the properties on artists on a lineups query by using

artists.limit=500

as a guess, but no luck.



Is there a way to paginate for nested values, or (preferably) set a higher limit for them? Do i have to use the GraphQL endpoint to fix this?



Thanks for any help!

  • default discord avatar
    jessrynkar2 years ago

    What does the request you're making look like?

  • default discord avatar
    sibergenome2 years ago

    Querying lineups with GET

    http://localhost:3000/api/lineups/{lineup_id}?depth=3

    , which returns:



    {
        "id": "649011d4bab507b4315d8c66",
        "artists": [
            "648ffe81281ddf5744f8197c",
            {+ 9 more IDs...}
        ],
        "createdAt": "2023-06-19T08:29:08.340Z",
        "updatedAt": "2023-06-19T08:29:08.340Z"
    }

    My (simplified) schema looks like this:



    const Lineups: CollectionConfig = {
      slug: 'lineups',
      access: {
        ...
      },
      fields: [
        {
          name: 'name',
          type: 'text',
          required: true,
          unique: true,
        },
        {
          name: 'artists',
          type: 'relationship',
          relationTo: 'artistprofiles',
          hasMany: true,
        }
    };
  • default discord avatar
    jessrynkar2 years ago
    @969226489549713438

    is this at all related to the relationship field issue you worked on recently?

  • discord user avatar
    dribbens
    2 years ago

    No, I made some frontend changes but nothing on the backend where this bug seems to be located

  • default discord avatar
    sibergenome2 years ago

    FWIW I've noticed it behaves the same in the admin UI, I can only get 10 artists.



    Opened an issue on github:

    https://github.com/payloadcms/payload/issues/2885
  • discord user avatar
    dribbens
    2 years ago

    Thank you for making an issue for it. I think I have an understanding on what is going on. We'll get working on it so we can get a patch out, likely early next week.

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.