# Laravel Resource Reducer - ShipSaaS

Ever thinking about how to speed up your application by optimizing the response?

Laravel Resource Reducer helps you to optimize every API request by:

* Reduce the response's size, get what you need ⭐️
  * Defer execution and allow on-demand data
* Responses to consumers faster 🚀
  * No more BIG FAT JSON every item/request
* Computation only starts when required, save CPU & memory 😎
* Built-in relationship access by using dot notation 👀
* Eager-loading on steroids (automated eager-loading, no more N+1 pain) 🔋

A simple yet super effective method to skyrocketing your API responding times 🥰

### The Inspiration

{% hint style="info" %}
If you know about **GraphQL query**, in order to query for data, we have to define which ***fields*** we want to acquire (not a YOLO response, lol)
{% endhint %}

Isn't that lovely?&#x20;

Laravel Resource stands as the transformation layer and is highly reusable. But, the performance is not so good.

Imagine for a simple dropdown of Users, we'll use UserResource and it would return a lot of unnecessary fields. It takes more memory, and CPU utilization (and is slow).&#x20;

And with Laravel Resource Reducer, you get what you ask for 😎 and fast.

### Simple Usage

`GET v1/users?_f=id,name`

```json
{
    "data": [
        {
            "id": 1,
            "name": "Seth Phat from ShipSaaS"
        },
        {
            "id": 2,
            "name": "Awesome userland"
        }
    ]
}
```

`GET v1/users?_f[]=id&_f[]=name&_f[]=articles.name`

```json
{
    "data": [
        {
            "id": 1,
            "name": "Seth Phat from ShipSaaS"
            "articles": [
                {
                    "name": "The Laravel Resource Reducer"
                }
            ]
        },
        {
            "id": 2,
            "name": "Awesome userland",
            "articles": []
        }
    ]
}
```

### Demo

Some sample URLs that you can trigger and see the results & dumped queries :wink:

Coming soon <3&#x20;
