Welcome to the GraphQL playground for managing, users, posts, comments, and much more. This project leverages Apollo GraphQL, Node Express, PostgreSQL, and JWT for user authentication, providing a robust and secure environment for managing data.
Before proceeding, you need to register or log in to access the GraphQL endpoint.
- Open http://localhost:5000/playground in your browser after running the server locally.
- You'll be directed to the GraphQL authentication page to register or log in.
- Navigate to http://localhost:5000/graphql/auth/ within the GraphQL playground.
Use the following mutation:
mutation register {
registerUser(
email: String!
username: String!
password: String!
role: String! # admin or user
): Users
}
- Provide your email, username, password, and role (admin or user).
Once registered, log in using your credentials:
- Navigate to http://localhost:5000/graphql/auth/ within the GraphQL playground.
Use the following mutation:
mutation login {
loginUser(email: String!, password: String!) {
id
username
email
role
token # Use this token for authorization
}
}
- Provide your username and password to receive a token for authentication.
- After logging in, copy the token received and add it to the request headers for authorization in the GraphQL playground.
Mutations |
---|
registerUser: (email: String!, username: String!, password: String!, role: String!): Users |
loginUser(username: String!, password: String!): Users |
Queries | Mutations |
---|---|
getUsers | updateUser |
getUserById | deleteUser |
getPosts | createPost |
getPostId | updatePost |
getComments | deletePost |
getCommentId | addComment |
updateCommentID |
Queries | Mutations |
---|---|
getAuthors | createAuthor |
getAuthorId | deleteAuthor |
getBooks | addBook |
getBookId | deleteBook |
updateBooks |
User Registration and Login: Seamlessly register and log in users with secure authentication. Manage Users, Posts, and Comments: Perform CRUD operations on users, posts, and comments with user authentication. Authors and Books Management: Efficiently handle authors and books data with authentication in place.
After registering or logging in, obtain the authentication token. Use the token in the request headers for authorization. Access the GraphQL endpoint for managing data with user authentication.