Skip to content

r1g023/nodeExpress-graphQL

Repository files navigation

Introduction

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.

Accessing GraphQL Playground

  • 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.

Registration

To register as a new user:

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).

graphQL api

Login

Once registered, log in using your credentials:

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.

authToken

User Registration and Login

Mutations
registerUser: (email: String!, username: String!, password: String!, role: String!): Users
loginUser(username: String!, password: String!): Users

Users/Posts/Comments Queries and Mutations with User Authentication

Queries Mutations
getUsers updateUser
getUserById deleteUser
getPosts createPost
getPostId updatePost
getComments deletePost
getCommentId addComment
updateCommentID

Authors and Books Data with User Authentication

Queries Mutations
getAuthors createAuthor
getAuthorId deleteAuthor
getBooks addBook
getBookId deleteBook
updateBooks

Features:

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.

Usage:

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.

For detailed usage instructions, refer to the provided GraphQL playground.

About

express api with graphql

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published