Skip to content

Simple Book Store application that developed with using .Net Core 3.1, GraphQL, JWT, Serilog, Kibana, Elasticsearch,Identity, EF Core.

Notifications You must be signed in to change notification settings

aenesgur/GraphQL-JWT-.NetCore_BookStoreService

Repository files navigation

Book Store Service with GraphQL, JWT, Serilog, Kibana, Elasticsearch

GraphQL, JWT, Serilog(with Kibana and Elasticsearch to monitoring logs) technologies was combined with .Net Core 3.1 and a simple Book Store service was developed. Query and Mutations queries have been added and SeedData added. Adding Book and Author in the associated database can be inserted with mutations. Just change the ConnectionString and run :)

Monitoring the logs with Kibana

Before starting the app, enter the project file and write "docker-compose up" in command line. If you have Elasticsearch and Kibana images in your Docker, it will run. If not, it will pull from DockerHub, install and run. After the docker images up, you can go to these links from browser to check if its run correctly http://localhost:9200/ , http://localhost:5601/ . After you run the project you can set the Index name from Manage Space and then Index pattern in Kibana and monitor the logs in Discover section

kibana-monitoring

Authentication:

$ Register to identity server. Post request to "http://localhost:54811/api/authentication/register"

{
    "Email":"[email protected]",
    "Password":"Info.123",
    "ConfirmPassword":"Info.123"
}

register

$ Login to identity server. Post request to "http://localhost:54811/api/authentication/login"

{
    "Email":"[email protected]",
    "Password":"Info.123"
}

login

Sample queries:

We will have a token in response After we get token, we can easily access datas with Graphql queries. In Postman, enter Authorization field and change type with "Bearer Token" and paste our token which we got after login's response. Set url with "http://localhost:54811/graphql/" and Post request. After that try queries which I explain and wrote belows.

Auth queryWithJwt

$ Get all authors. You can modify it according to the variable you want to receive

{
  all_authors{
    name
    surname
    citizen
      books{
	name
      	description
      	isStock
      	price
        authorId
      }
  }
}

$ Filtering the number of books in the book list

{
  all_authors{
    name
    surname
    citizen
      books(piece : 1){
	name
      	description
      	isStock
      	price
        authorId
      }
  }
}

$ Get author by id and filtering the number of books in the book list

{
  author_by_id (id: 2){
    name
    surname
    citizen
      books(piece : 1) {
	name
      	description
      }
  }
}

$ Get book by id

{
  book_by_id(id : 2){
    name,
    description,
    isStock
  }
}

$ Add author with mutation. After adding, we call Id and Name to be sure added to database

mutation ($author: AuthorInputType!) {
  addAuthor(author: $author) {
    id
    name
  }
}
(Query of under the this line should added GRAPHQL VARIABLES region)
{
  "author": {
    "name": "Dan",
    "surname": "Brown",
    "citizen": "USA"
  }
}

$ Add book with mutation. After adding, we call Id and Name to be sure added to database

mutation ($book: BookInputType!) {
  addBook(book: $book) {
    id
    name
  }
}
(Query of under the this line should added GRAPHQL VARIABLES region)
{
  "book": {
    "name": "The Da Vinci Code",
    "description": "The Da Vinci Code Descripion",
    "publisher": "Alfa",
    "isStock": true,
    "price": 50,
    "authorId": 6
  }
}

Releases

No releases published

Packages

No packages published

Languages