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,757 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: 6 packages by
Country: Canada Canada
Age: ???
All time rank: 414388 in Canada Canada
Week rank: 170 Up7 in Canada Canada Up
Innovation award
Innovation award
Nominee: 2x

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

  Files folder image Files (86)  /  app  
File Role Description
Files folder imageConsole (1 file)
Files folder imageExceptions (1 file)
Files folder imageHttp (1 file, 2 directories)
Files folder imageProviders (5 files)
  Plain text file Department.php Class Class source
  Plain text file Employee.php Class Class source
  Plain text file Role.php Class Class source
  Plain text file User.php Class Class source

  Files folder image Files (86)  /  app  /  Console  
File Role Description
  Plain text file Kernel.php Class Class source

  Files folder image Files (86)  /  app  /  Exceptions  
File Role Description
  Plain text file Handler.php Class Class source

  Files folder image Files (86)  /  app  /  Http  
File Role Description
Files folder imageControllers (1 file, 1 directory)
Files folder imageMiddleware (7 files)
  Plain text file Kernel.php Class Class source

  Files folder image Files (86)  /  app  /  Http  /  Controllers  
File Role Description
Files folder imageAuth (6 files)
  Plain text file Controller.php Class Class source

  Files folder image Files (86)  /  app  /  Http  /  Controllers  /  Auth  
File Role Description
  Plain text file ConfirmPasswordController.php Class Class source
  Plain text file ForgotPasswordController.php Class Class source
  Plain text file LoginController.php Class Class source
  Plain text file RegisterController.php Class Class source
  Plain text file ResetPasswordController.php Class Class source
  Plain text file VerificationController.php Class Class source

  Files folder image Files (86)  /  app  /  Http  /  Middleware  
File Role Description
  Plain text file Authenticate.php Class Class source
  Plain text file CheckForMaintenanceMode.php Class Class source
  Plain text file EncryptCookies.php Class Class source
  Plain text file RedirectIfAuthenticated.php Class Class source
  Plain text file TrimStrings.php Class Class source
  Plain text file TrustProxies.php Class Class source
  Plain text file VerifyCsrfToken.php Class Class source

  Files folder image Files (86)  /  app  /  Providers  
File Role Description
  Plain text file AppServiceProvider.php Class Class source
  Plain text file AuthServiceProvider.php Class Class source
  Plain text file BroadcastServiceProvider.php Class Class source
  Plain text file EventServiceProvider.php Class Class source
  Plain text file RouteServiceProvider.php Class Class source

  Files folder image Files (86)  /  bootstrap  
File Role Description
  Plain text file app.php Class Class source

  Files folder image Files (86)  /  config  
File Role Description
  Plain text file app.php Class Class source
  Plain text file auth.php Class Class source
  Accessible without login Plain text file broadcasting.php Aux. Auxiliary script
  Accessible without login Plain text file cache.php Aux. Auxiliary script
  Accessible without login Plain text file crud.php Aux. Auxiliary script
  Accessible without login Plain text file database.php Aux. Auxiliary script
  Accessible without login Plain text file filesystems.php Aux. Auxiliary script
  Accessible without login Plain text file hashing.php Aux. Auxiliary script
  Plain text file logging.php Class Class source
  Accessible without login Plain text file mail.php Aux. Auxiliary script
  Accessible without login Plain text file queue.php Aux. Auxiliary script
  Accessible without login Plain text file services.php Aux. Auxiliary script
  Accessible without login Plain text file session.php Aux. Auxiliary script
  Accessible without login Plain text file view.php Aux. Auxiliary script

  Files folder image Files (86)  /  database  
File Role Description
Files folder imagefactories (1 file)
Files folder imagemigrations (7 files)
Files folder imageseeds (4 files)

  Files folder image Files (86)  /  database  /  factories  
File Role Description
  Plain text file UserFactory.php Class Class source

  Files folder image Files (86)  /  database  /  migrations  
File Role Description
  Plain text file 2014_10_12_000000_create_users_table.php Class Class source
  Plain text file 2014_10_12_100000_...rd_resets_table.php Class Class source
  Plain text file 2019_08_19_000000_...iled_jobs_table.php Class Class source
  Plain text file 2019_12_04_193029_create_roles.php Class Class source
  Plain text file 2019_12_04_193122_create_departments.php Class Class source
  Plain text file 2019_12_04_193213_create_employees.php Class Class source
  Plain text file 2019_12_13_140652_seed_data.php Class Class source

  Files folder image Files (86)  /  database  /  seeds  
File Role Description
  Plain text file DatabaseSeeder.php Class Class source
  Plain text file DepartmentsTableSeeder.php Class Class source
  Plain text file EmployeesTableSeeder.php Class Class source
  Plain text file RolesTableSeeder.php Class Class source

  Files folder image Files (86)  /  graphql  
File Role Description
  Accessible without login Plain text file schema.graphql Data Auxiliary data

  Files folder image Files (86)  /  public  
File Role Description
  Accessible without login Plain text file .htaccess Data Auxiliary data
  Accessible without login Plain text file index.php Example API server script
  Accessible without login Plain text file robots.txt Data Crawler robots configuration
  Accessible without login Plain text file web.config Data Auxiliary data

  Files folder image Files (86)  /  resources  
File Role Description
Files folder imagejs (2 files)
Files folder imagelang (1 directory)
Files folder imagesass (1 file)
Files folder imageviews (1 file)

  Files folder image Files (86)  /  resources  /  js  
File Role Description
  Accessible without login Plain text file app.js Data Auxiliary data
  Accessible without login Plain text file bootstrap.js Data Auxiliary data

  Files folder image Files (86)  /  resources  /  lang  
File Role Description
Files folder imageen (4 files)

  Files folder image Files (86)  /  resources  /  lang  /  en  
File Role Description
  Accessible without login Plain text file auth.php Aux. Auxiliary script
  Accessible without login Plain text file pagination.php Aux. Auxiliary script
  Accessible without login Plain text file passwords.php Aux. Auxiliary script
  Accessible without login Plain text file validation.php Aux. Auxiliary script

  Files folder image Files (86)  /  resources  /  sass  
File Role Description
  Accessible without login Plain text file app.scss Data Auxiliary data

  Files folder image Files (86)  /  resources  /  views  
File Role Description
  Accessible without login Plain text file welcome.blade.php Aux. Auxiliary script

  Files folder image Files (86)  /  routes  
File Role Description
  Accessible without login Plain text file api.php Example Example script
  Accessible without login Plain text file channels.php Example Example script
  Accessible without login Plain text file console.php Example Example script
  Accessible without login Plain text file web.php Aux. Auxiliary script

  Files folder image Files (86)  /  tests  
File Role Description
Files folder imageFeature (1 file)
Files folder imageUnit (1 file)
  Plain text file CreatesApplication.php Class Class source
  Plain text file TestCase.php Class Class source

  Files folder image Files (86)  /  tests  /  Feature  
File Role Description
  Plain text file ExampleTest.php Class Class source

  Files folder image Files (86)  /  tests  /  Unit  
File Role Description
  Plain text file ExampleTest.php Class Class source

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,757
This week:71Up