Skip to main content

Posts

Showing posts from March, 2022

Hot Chocolate GraphQL Pagination Using UseOffsetPaging Middleware[.NET6]

In this article, we are going to understand the GraphQL pagination using the 'UseOffsetPaging' middleware. UseOffsetPaging Middleware: Hot chocolate provides default pagination middleware that is 'UseOffsetPaging'. Simply applying 'UseOffsetPaging' on the resolver method will enable the pagination. This middleware implicitly reads the variables like 'skip' and 'take' from the request query and then generates the raw SQL query from the IQueriable. Create A .NET6 Web API Project: Let's create a .Net6 Web API sample application to accomplish our demo. We can use either Visual Studio 2022 or Visual Studio Code(using .NET CLI commands) to create any .NET6 application. For this demo, I'm using the 'Visual Studio Code'(using the .NET CLI command) editor. .NET CLI Command: dotnet new webapi -o Your_Project_Name Sample Table Data: Let's have a sample Todo table as shown. Setup EntityFramework Core Database Context: Let's

Part-5 Ocelot API Gateway For Microservices[.NET6 Microservice Series]

In this article, we are going to implement API Gateway for our microservices to define a unified URL with that all client applications can consume it instead of consuming individual URLs of the microservices. Part-4 Asynchronous Data Communication Between Microservices Using RabbitMQ Message Broker With MassTransit[.NET6 Microservice Series] Need Of API GateWay?: Consider our microservice where we have two microservice applications. The 'Manufacture.API' application runs at 'https://localhost:7132' and The 'SalesBusiness.API' runs at 'https://localhost:7456' so from this we can understand we have 2 different domains bound to our each microservices. So in the real-world application, we may deal with 10plus microservices base on our business. So handling or managing or consuming 10plus different domains by a client application is very hard. So to solve this problem API Gateway comes into the picture. So API Gateway is also a simple API project with its

Part-4 Asynchronous Data Communication Between Microservices Using RabbitMQ Message Broker With MassTransit[.NET6 Microservice Series]

In this article, we are going to establish asynchronous data communication between microservice using the RabbitMQ message broker along with MassTransit. Now let's take look at the 'Orders' GET endpoint response. Here we can understand we don't have 'Product' information. So we have to make a way to save the required 'Product' information into the 'SalesBusiness.API' microservice application from the 'Manufacture.API' microservice application. Steps we are going to accomplish this demo are: Configure RabbitMQ message broker with MassTransit for asynchronous data communication between the microservices. In the 'Manufacture' database we have a 'Products' table(like Master table), now we will create a new 'Products' table(like child table) in 'SalesDatabase', but here we will add only required columns. So that while fetching the 'Orders' endpoint it is to fetch required products information. So with he

Part-3 Create A Microservice For The Orders Endpoint[.NET6 Microservice Series]

In this article, we will create our second microservice application that contains the orders endpoint. The microservice application consists of simple or single module logic endpoints. So here I'm going to create 2 endpoints like HTTP GET, HTTP POST for the 'Orders' to accomplish our demo. Part-2 Create A Microservice For The Products Endpoint[.NET6 Microservice Series] Create A .NET6 Web API Application: Let's create our second microservice application with .NET6 Web API application. Let's name our microservice project 'SalesBusiness.Api'. To create .NET6 application recommended IDE's are 'Visual Studio 2022', 'Visual Studio Code'. In this demo, I'm using .NET CLI and Visual Studio Code editor. CLI command dotnet new webapi -o Your_Project_Name Install NuGet Packages: Install EntityFramework Core NuGet. .NET CLI command dotnet add package Microsoft.EntityFrameworkCore --version 6.0.3 Package Manager command Install-Packa

Part-2 Create A Microservice For The Products Endpoint[.NET6 Microservice Series]

In this article, we will create a microservice application that contains the product endpoint. So creating a microservice means the application contains endpoints related to a specific module or component. So here I'm going to create 2 endpoints like HTTP GET, HTTP Post for the products to accomplish our demo. (We can implement the entire CRUD operation endpoint if we want). Click here for Part-1 of the .NET6 Microservice Series . Create A .NET6 Web API Application: Let's create our first microservice application with .NET6 Web API application. Let's name our microservice project as 'Manufacture.Api'. To create .NET6 application recommended IDE's are Visual Studio 2022', 'Visual Studio Code'. In this demo, I'm using .NET CLI and Visual Studio Code editor. CLI command dotnet new webapi -o Your_Project_Name Install NuGet Packages: Install EntityFramework Core NuGet. .NET CLI command dotnet add package Microsoft.EntityFrameworkCore --ve

Part -1 Introduction On Microservice And SQL Database Design For Microservices [.NET 6 MicorService Series]

In the .NET6 Microservice series, this is the first installment article, where we are going to understand about the Microservices and also we are going to create SQL databases for our sample microservices of this series. Monolithic Architecture: Monolithic architecture is traditional or most commonly used for developing the application. In this approach, all the business units or logic are implemented under a single application. A single database can be used for data serving. Microservice Architecture: In Microservice architecture each business unit or logic is developed as separate small individual applications. So each separate application is lightweight and they have their own responsibilities to carry on and these individual services are called Microservices. In Microservices each service has its own code and databases so anyone service down remaining microservice services are unaffected. Each microservice can be hosted anywhere on the web. Each microservice can interact wi