Git Product home page Git Product logo

aenesgur / graphql-jwt-.netcore_bookstoreservice Goto Github PK

View Code? Open in Web Editor NEW
5.0 4.0 0.0 13.13 MB

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

C# 100.00%
graphql dotnetcore entity-framework-core json-web-token identity-server jwt jwt-authentication jwt-bearer-tokens jwt-tokens kibana elasticsearch serilog monitoring

graphql-jwt-.netcore_bookstoreservice's Introduction

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
  }
}

graphql-jwt-.netcore_bookstoreservice's People

Contributors

aenesgur avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.