Often referred to as a platform or programming language agnostic query language, GraphQL is a comprehensive approach to guide software engineers in building data-driven applications. It is, in my opinion, the new API standard, offering client applications the flexibility to request exact data and not an entire record from the database. If you are not yet conversant with this technology or looking for simplified technical content to guide you through, you are in the right place.

In this tutorial, you will learn some of the fundamental concepts required to build a Laravel API powered by GraphQL. This is a shift from the conventional architecture of building REST APIs, as we will take a different approach in this tutorial. To help us explore GraphQL, we will build a bookstore API with an ability to carry out CRUD ( Create, Read, Update, Delete ) operations on data, in your database.

Prerequisites

You should have basic knowledge of building web applications with Laravel to easily complete this tutorial. Lastly, you need to installComposer globally on your computer to manage dependencies.

Creating a New Laravel Project

To begin, we will create a new Laravel application using Composer, by running the following command from the terminal:

$ composer create-project --prefer-dist laravel/laravel lara-bookstore

The preceding command will create a Laravel project in a new directory named lara-bookstore in your local development folder, or whenever you ran the command from. Go to the project folder and run the Laravel project to interact with the default functionality, using the following command:

// Move into project
$ cd lara-bookstore

// Run the application
$ php artisan serve

Laravel default page

#graphql #laravel #api

How to Build a GraphQL Powered API with Laravel
4.45 GEEK