Skip to content

Latest commit

 

History

History
90 lines (59 loc) · 3.68 KB

README.md

File metadata and controls

90 lines (59 loc) · 3.68 KB

gRPC GraphQL WebSockets

Build Trivy and Dockle CodeFactor

The objective of this project is to make a toy example of REST API, gRPC, GraphQL and Websockets all accessing and realizing the same objective: retrieving and sending a simple message to the same database.

Table of contents

General info

Solution consists of two projects:

  1. gRPCGraphQLWebSockets.csproj - this project contains database along with REST API, gRPC, GraphQL and SignalR server
  2. Second item - this project contains SignalR client

After project is build and run the four API's can be accessed via given URL's:

For container the origin is: http://localhost:8080/

Solution structure is as following:

.
└──src
	├── GrpcGraphQlWebSockets   # Server application for REST, GraphQL, SignalR and gRPC
	│	├── Database            # Directory where database context is stored along with SQLite database itself
	│	├── google     			# This directory contains .proto files required to run gRPC, placed in here beacuse otherwise it won't work
	│	├── GraphQl   			# GraphQL mutations, queries and models are stored in here
	│	├── Grpc        		# gRPC service.cs and service.proto files are stored in here
	│	├── Rest         		# REST controller, service and model
	│	├── SignalR    			# SignalR server hub is stored in here
	│	└── SharedModel      	# Models the same throughout the whole solution
	│        
	└── SignalRClient           # Simple SignalR client console application - one file and one .csproj
		└── ...               

Screenshots

SignalR

You can see messages incoming from gRPC and REST being broadcasted to SignalR client as I wanted to be. They are with timestamp. You can also see message sent from SignalR client upon which Id was returned as indication of succesfull message sending.

SignalR

gRPC

gRPC response in swagger.

gRPC

GraphQL

GraphQL example.

GraphQL

Technologies

  • REST API
  • gRPC
  • GraphQL
  • SignalR
  • SQLite
  • Docker

Setup

If you have .NET8 and Visual Studio or JetBrains Rider just open .sln file and try to run the project.

Status

Project is: finished

Since Microsoft documentation on gRPC+Swagger is realy "so so" these two guys were my inspiration in this case:

grpc/grpc-dotnet#167 (comment)

https://github.com/bernardbr/dotnetgrpcrest

https://github.com/fl0wm0ti0n/GrpcWithHttpApiSwaggerAndDocker_Test