The Social Media API is a GraphQL-based backend service that simulates basic functionalities of a social media platform. It allows users to register, log in, post content
- User registration and authentication (login)
- User can post content as a Post
- Retrieving Posts
- GraphQL Integrated
- Node.js
- npm or yarn package manager
- MongoDB database
-
Clone the repository using
git clone https://github.com/MitreshPrajapati/ideaclan
-
Navigate to the project directory by running
cd ideaclan
command on terminal. -
Install the dependencies of the application by running
npm install
oryarn install
. -
Create
.env
file at the root of the project folder and add following environment variables
- JWT_SECRET = 'YOUR_SECRETKEY'
- MONGODB_URL = 'mongodb-url' or 'mongodb://localhost:27017/IdeaClan'
- Access the GraphQL Playground at http://localhost:8080/graphql in your web browser.
- Use the provided queries and mutations to interact with the API.
- Register a User:
mutation registration($registerInput: RegisterInput){
register(registerInput : $registerInput) {
name
email
password
followers
}
}
Variables:
{
"registerInput":{
"name":"User4",
"email":"user4@gmail.com",
"password":"1234"
}
}
- Login a user:
mutation loginUser($loginInput: LoginInput){
login(loginInput: $loginInput)
}
Variables:
{
"loginInput":{
"email": "user1@gmail.com",
"password": "1234"
}
}
- Create a Post:
mutation loginUser($postInput: PostInput){
createPost(postInput: $postInput){
content
}
}
Variables:
{
"postInput":{
"userId": "65f68f6a5bbe32d67e4984fe",
"content":"Post 2 by User2",
}
}
Headers:
Authorization = token
- Retrieve User's Posts:
query getPosts ($userId: ID!){
posts(userId: $userId) {
content
createdAt
userId
}
}
Variables:
{
"userId":"65f68f6a5bbe32d67e4984fe"
}
Headers:
Authorization = token
- Node.js
- Express.js
- Graphql
- apollo-server-express
- MongoDb
- bcrypt
- jsonwebtoken
- mongoose