imJohnBon
3 years ago

Fractal Paginating Subresources

Posted 3 years ago by imJohnBon

I'm currently working on integrating Fractal into an API Lumen project.

However, I have a question about paginating embeds. Let's say we have API response for books that also has a sub-embed for the books authors:

{
    "data":  [
        { "id": 11 },
        { "id": 12 },
        { "id": 13 },
        { "id": 14 },
        { "id": 15 }
        "authors":  [
            "data": [
                { "id": 14 },
                { "id": 15 },
                { "id": 16 }
                { "id": 17 }
                { "id": 18 }
            ],
            "meta": {
                "pagination": {
                    "previous": 5,
                    "current": 10,
                    "next": 15,
                    "count": 5
                }
            }
        ]
    ],
    "meta": {
        "pagination": {
            "previous": 5,
            "current": 10,
            "next": 15,
            "count": 5
        }
    }
}

Fractal has pretty great documentation on setting up pagination, but I don't see anything on how I would create a URL to paginate the "authors" embed there, which has it's own pagination. Anyone done this?

Please sign in or create an account to participate in this conversation.