You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
The GraphQL-Based Blog System is a powerful and modern blog application that allows users to read, create, update, and delete blog posts, manage comments, and perform various other operations through a GraphQL API. It offers a more intuitive and customizable way of querying data compared to RESTful APIs.
Welcome to the GraphQL-Based Blog System, a full-featured and feature-rich blog application developed in Laravel 10 and PHP 8.2. This application leverages GraphQL instead of a traditional RESTful API to provide a more flexible and efficient way of fetching data.
The GraphQL-Based Blog System is a powerful and modern blog application that allows users to read, create, update, and delete blog posts, manage comments, and perform various other operations through a GraphQL API. It offers a more intuitive and customizable way of querying data compared to RESTful APIs.
Features
User Authentication: Allow users to sign up, log in, and manage their profiles.
Blog Posts: Create, read, update, and delete blog posts with different attributes like title, content, tags, and date.
Comments: Users can leave comments on blog posts.
Categories and Tags: Organize blog posts into categories and add tags for easy navigation.
Search: Implement a powerful search functionality to find blog posts by keywords.
Pagination: Handle large sets of data with pagination support.
Error Handling: Gracefully handle errors and provide helpful messages in responses.
Security: Implement authentication and authorization to protect sensitive operations.
GraphQL Subscriptions (Real-Time Updates): Optionally, you can add real-time updates for comments or new blog posts using GraphQL subscriptions.
Requirements
To run this blog system, you need the following software and tools installed on your server:
PHP 8.2
Laravel 10 or higher
Composer
MySQL or any compatible database system
Installation
Clone the repository or download the source code.
Runcomposer install to install the required dependencies.
Create a new MySQL database for the blog system.
Copy the.env.example file to.env and configure your database connection settings.
Runphp artisan migrate to create the necessary database tables.
Configuration
Customization: The application is highly customizable. You can modify views, styles, andGraphQL schema to suit your needs.
Environment Variables: The.env file contains various environment variables to control the behavior of the application. Make sure to configure them correctly.
Usage
To run the blog system, use the following command:
php artisan serve
Now openhttp://localhost:8000/graphiql. this is a environment for running graphql queries and get response. in below window you can add Authorization token(you can get that after login or register) and dont forget to addContent-Type: application/json header.
GraphQL
Queries:
Get all blog posts: Retrieve a list of all blog posts with their titles and dates.
{"data": {"posts": [ {"title":"pizza","content":"here we want to learn how make a pizza.","author": {"username":"AliAhmadi" },"created_at":null,"updated_at":null } ] }}
Get a single blog post: Retrieve detailed information about a specific blog post by its ID.
{"data": {"post": {"id":"2","title":"pizza","content":"here we want to learn how make a pizza.","created_at":null,"updated_at":null,"author": {"name":"Ali","username":"AliAhmadi","email":"aliahmadi82c@gmail.com" } } }}
Search blog posts: Search for blog posts based on keywords and retrieve a list of matching posts.
{"data": {"search": [ {"id":"2","title":"pizza","content":"here we want to learn how make a pizza.","created_at":null,"updated_at":null,"category": {"description":"posts related to food world" } } ] }}
Get all categories: Retrieve a list of all blog categories.
{"data": {"popularPosts": [ {"id":"2","title":"pizza","content":"here we want to learn how make a pizza.","author": {"username":"AliAhmadi","email":"aliahmadi82c@gmail.com" },"likes":34,"views":2974,"isPublished":true,"created_at":null,"updated_at":null } ] }}
Get user profile: Retrieve information about the currently logged-in user.
{"data": {"category": {"posts": [ {"title":"pizza","content":"here we want to learn how make a pizza.","likes":34,"views":2974,"isPublished":true }, {"title":"moon and mars","content":"i want to be first person walked throught mars","likes":0,"views":0,"isPublished":true } ] } }}
Get posts by tag: Retrieve all blog posts associated with a specific tag.
Get total number of posts: Retrieve the total number of blog posts in the system.Get posts by author: Retrieve all blog posts written by a specific author.
query {countOfPosts}
{"data": {"countOfPosts":2 }}
Get user by ID: Retrieve detailed information about a user by their ID.
We welcome contributions from the community. If you want to contribute to the project, please fork the repository, make your changes, and submit a pull request.
License
The GraphQL-Based Blog System is open-source software released under the GPL-3.0 License. See the LICENSE file for more information.
Authors
Ali
Max
Copyright 2023, Max Base
About
The GraphQL-Based Blog System is a powerful and modern blog application that allows users to read, create, update, and delete blog posts, manage comments, and perform various other operations through a GraphQL API. It offers a more intuitive and customizable way of querying data compared to RESTful APIs.