Codebits GraphQL
API for a microblogging platform for writing code snippets. A use can like and reply to snippets
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 key:generate
php artisan migrate
php artisan serve
Visit http://localhost:8000/graphiql on your browser to test the API
Alternatively you can use Postman or Insomnia
Use this url: http://localhost:8000/graphql
query {
allBits {
id
user {
name
}
snippet
replies {
id
user {
name
}
reply
}
likes_count
created_at
updated_at
}
}
query {
bitById(id: 1) {
id
user {
name
}
snippet
replies {
id
user {
name
}
reply
}
likes_count
created_at
updated_at
}
}
mutation {
signUp(
name: "Ryan Wire"
email: "ryanwire@outlook.com"
password: "123456"
)
}
mutation {
logIn(
email: "ryanwire@outlook.com"
password: "123456"
)
}
The mutations below require authorization using the token generated on sign up or login
mutation {
newBit(snippet: "<html>Hello world</html>") {
id
snippet
}
}
mutation {
replyBit(bit_id: 1, reply: "Hello world!") {
id
user {
name
}
bit {
snippet
}
reply
}
}
mutation{
likeBit(bit_id:1)
}
mutation{
unlikeBit(bit_id:1)
}