This is a sample Laravel Project to illustrate API creation using GraphQL using grapgql-laravel package
Fork and Clone the project then;
composer install
cp .env.example .env
php artisan key:generate
php artisan migrate
php artisan serve
- Register
- Login
- Update Avatar
- CRUD
- Pagination
http://localhost:8000/graphql/auth
mutation {
signUp(
name: "tester"
email:"123@test.com"
password:"123"
) {
id,
email,
name,
api_token
}
}
{
"data": {
"signUp": {
"id": 1,
"email": "123@test.com",
"name": "tester",
"api_token": "09SBifku0BCSNS7VBFNqQg0goDYqCX43tL4pNtl7lJPmVOJOjDdjD42mnmuOLBybwW7DHZmrnVTey0p8nH4EWGGa7oRKErnZMm9c"
}
}
}
http://localhost:8000/graphql/auth
mutation {
logIn(
email:"123@test.com"
password:"123"
) {
id,
email,
name,
api_token
}
}
{
"data": {
"logIn": {
"id": 1,
"email": "123@test.com",
"name": "tester",
"api_token": "09SBifku0BCSNS7VBFNqQg0goDYqCX43tL4pNtl7lJPmVOJOjDdjD42mnmuOLBybwW7DHZmrnVTey0p8nH4EWGGa7oRKErnZMm9c"
}
}
}
mutation {
newBit (snippet: "<?php ehco phpinfo(); ?>") {
id
user {
id
name
}
snippet
created_at
updated_at
}
}
{
"data": {
"newBit": {
"id": 2,
"user": {
"id": 1,
"name": "tester"
},
"snippet": "<?php ehco phpinfo(); ?>",
"created_at": "2020-04-16 18:27:07",
"updated_at": "2020-04-16 18:27:07"
}
}
}
mutation($file: Upload!)
{ UpdateUserProfilePhoto(profilePicture: $file)
{
id,
name,
avatar,
email,
api_token
}
}
The sample project is created from serries of lessons from;
The Laravel framework is open-sourced software licensed under the MIT license.
Happy coding, Star then Fork 😊💪💯