PHP Classes

Laravel GraphQL Server: API server to demonstrate GraphQL query language

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 47 All time: 10,774 This week: 71Up
Version License PHP version Categories
lara-graph 1.0.0GNU General Publi...5PHP 5, Web services
Description 

Author

This package provides an API server to demonstrate GraphQL query language.

It provides an API application implemented using the Laravel framework that implements the GraphQL specification to define how the API will respond to query requests.

This API application reads a GraphQL schema specification file to determine how to route API requests to classes that will generate responses from parameters extracted from the request.

Innovation Award
PHP Programming Innovation award nominee
February 2022
Number 2


Prize: 1 year of Team Plan of Mailtrap
GraphQL is a specification for a way to process requests to an API.

It allows developers to create APIs by defining how to extract parameter values from the request using a GraphQL specification file.

This package demonstrates how to use a GraphQL specification to implement an API using the Laravel Framework quickly.


Manuel Lemos
Picture of TJ Webb
Name: TJ Webb <contact>
Classes: 8 packages by
Country: Canada Canada
Innovation award
Innovation award
Nominee: 4x

 

Example

<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return
$request->user();
});


Details

Laravel GraphQL Example

Install and Run

docker-composer -up

GraphQL Endpoint

/graphql

GraphQL Playground Endpoint

/graphql-playground

Sample Models

  • Department: `/departments`
  • Employees: `/employees`
  • Roles: `/roles`

Fun Stuff

  • It uses a package I created to automatically generate routes, controllers, and views for models (`webbtj/crud`).
  • Uses `nuwave/lighthouse` for GraphQL implementation.
  • Seeds data from a migration so the DB will keep a record of the action and not perform it multiple times (and will perform in on `docker-compose up` without additional docker config).

  Files folder image Files (86)  
File Role Description
Files folder imageapp (4 files, 4 directories)
Files folder imagebootstrap (1 file)
Files folder imageconfig (14 files)
Files folder imagedatabase (3 directories)
Files folder imagegraphql (1 file)
Files folder imagepublic (4 files)
Files folder imageresources (4 directories)
Files folder imageroutes (4 files)
Files folder imagetests (2 files, 2 directories)
Accessible without login Plain text file .editorconfig Data Auxiliary data
Accessible without login Plain text file .env.example Data Auxiliary data
Accessible without login Plain text file .styleci.yml Data Auxiliary data
Plain text file artisan Class Class source
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file docker-compose.yml Data Auxiliary data
Accessible without login Plain text file package.json Data Auxiliary data
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file readme.md Doc. Documentation
Accessible without login Plain text file server.php Aux. Auxiliary script
Accessible without login Plain text file webpack.mix.js Data Auxiliary data

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:47
This week:0
All time:10,774
This week:71Up