Skip to content

mazraara/laravel-graphql

Repository files navigation

laravel-graphql

A simple app to try out GraphQL using Laravel with SQLite

composer install

Duplicate .env.example and rename it .env

Add full path to SQL lite

DB_CONNECTION=sqlite

DB_DATABASE=/app/laravel-graphql/database/database.sqlite

Then run:

php artisan key:generate

Then create the tables by running:

php artisan migrate

And finally, start the application:

php artisan serve

now visit http://localhost:8000/graphiql to see the application running.

Example of API call

http://localhost:8000/graphiql?query={ tasks { id title is_completed } }

A similar REST API endpoint will be like

http://localhost:8000/tasks/

This will respond

{ "data": { "tasks": [ { "id": 1, "title": "Earum aut voluptatem fugit officia qui.", "is_completed": false }, { "id": 2, "title": "Repellat eos sint enim pariatur odio et deserunt.", "is_completed": false }, { "id": 3, "title": "Aut eius ad consequatur eveniet rerum.", "is_completed": false }, ] } }

Acknowledgments

https://github.com/Folkloreatelier/laravel-graphql

About

Weekend fun with GraphQL using Laravel & SQLite

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages