Articles GraphQL
A GraphQL app to create articles, view articles with user auth
It's very simple to get the API up and running. First, create the database (and database user if necessary) and add them to the .env file.
DB_DATABASE=your_db_name
DB_USERNAME=your_db_user
DB_PASSWORD=your_password
Then install, migrate, seed, and run the server:
composer install
php artisan migrate
php artisan serve
Use this url: http://localhost:8000/graphql to test the API on Postman or Insomnia
Run the following command on your terminal
composer seed
{
user(id: 1) {
id
name
email
}
}
{
users(count:11) {
paginatorInfo {
total
hasMorePages
}
data {
id
name
email
}
}
}
{
user(id:1) {
articles {
id
title
}
}
}
{
articles(count:4) {
paginatorInfo {
total
hasMorePages
}
data {
id
title
author {
name
email
}
}
}
}
mutation {
createUser(
name:"John Doe"
email:"john.doe@example.com"
password: "secret"
) {
id
name
email
}
}
mutation {
login(email:"graphql@test.com", password:"secret")
}
Add the token from login as a Bearer Token
{
me {
email
articles {
id
title
}
}
}
Add the token from login as a Bearer Token
mutation {
createArticle(
title:"Building a GraphQL Server with Laravel"
content:"In case you're not currently familiar with it, GraphQL is a query language used to interact with your API..."
) {
id
author {
id
email
}
}
}