RestQL Data Resolution Package for Laravel

RestQL Data Resolution Package for Laravel

RestQL is a data resolution package for your Laravel models by Gregori Piñeres:

RestQL is a Laravel eloquent-based data resolution package. This package tries to adopt GraphQL principles solving only the data that the client requests. RestQL uses your Laravel models as an entry point to add queries to then based on the eloquent methods.

This package has data resolution clauses, which are a way to improve queries based on parameters provided by the client. It’s RESTful but uses principles from GraphQL.

From the project’s readme, here’s an example of the RestQL route:

use Restql\Restql;
use Illuminate\Http\Request;

// The RestQL endpoint.
Route::get('restql', function (Request $request) {
  return Restql::resolve($request);
});

And with that route, how you might use this package on the frontend to retrieve author names:

axios.get('http://laravel.app/api/restql', {
  params: {
    authors: {
      select: 'name'
    }
  }
}).then(({ data: authors }) => {
    // Do something...
    console.log(authors)
});

Finally, you’d get the following JSON back:

{
  "authors": [
    { "id": 1, "name": "Kasey Yost" },
    { "id": 2, "name": "Ike Barton" },
    { "id": 3, "name": "Emie Daniel" },
    {...}
  ]
}

Learn More

You can learn more about this package, get full installation instructions, and view the source code on GitHub at gregorip02/restql.

Filed in: News
Laravel News Partners

Laravel Jobs

Senior Full Stack Engineer - Laravel
Remote
Givebutter
Laravel partner seeks Lead Developer
Remote
Kirschbaum Development Group
Senior Programmer **Immediate Opening** (send resume to daniel@sbgcorp.com)
Remote
SBG Corp
Web Developer - Laravel
Grand Forks, North Dakota
Center for Rural Health
Senior Full-Stack Laravel Developer
Berlin, Germany
felmo.de

Newsletter

Join 31,000+ others and never miss out on new tips, tutorials, and more.