This is the repository for the tutorial on How to build a GraphQL Server using Laravel.
Follow the series here => https://baffouraduboampong.me/how-to-build-a-graphql-server-using-laravel-part-1/
Note: Make sure you have composer installed or you may downlaod composer at => https://getcomposer.org/download/
- git clone
- Open the console and cd into your project root directory
- Create your database
- Rename .env.example file to .env inside your project root
- Update .env with your database information.
- Run composer install or php composer.phar install
- Run php artisan key:generate
- Run php artisan migrate
- Run php artisan db:seed to run seeders (Incase of an error run => composer dump-autoload)
- Run php artisan serve
Project Url: http://localhost:8000
GraphQL Endpoint: http://localhost:8000/graphql
GraphQL Playground: http://localhost:8000/graphql-playground
query {
users(first:10, page:6) {
paginatorInfo {
total
currentPage
hasMorePages
lastPage
perPage
}
data {
id
name
email
}
}
user(id:10){
id
email
name
articles {
id
title
content
}
}
article(id: 6) {
id
title
content
user {
id
name
email
}
}
articles(first:10, page:1) {
paginatorInfo {
total
currentPage
hasMorePages
lastPage
perPage
}
data {
id
title
content
}
}
}
Note: In the query below you need to add request headers such as
{
"Authorization": "Bearer CKDL3XFeulMBEdXDtqNG1uEs69tBvCoPSkQZhfJSVKAE0AhHt5bkxKmLGtA8"
}
query {
me {
email
name
articles {
id
title
}
}
}
mutation {
createUser(
name:"Alexis Osei"
email:"alexis.osei@example.com"
password: "secret"
) {
id
name
email
}
login(
email:"me@mygraphqlapp.com"
password:"secret"
)
}