Skip to main content

Posts

Showing posts with the label GraphQL

Implementing DataLoader For Query Execution Using Hot Chocolate GraphQL In .Net

In this article, we are going to understand and implement the DataLoader concept in Hot Chocolate GraphQL. Here we will use an existing Hot Chocolate sample application that was created in the introduction articles on Hot chocolate GraphQL. I recommend reading those articles: Part-1 Introduction On Hot Chocolate GraphQL Part-2 Introduction On Hot Chocolate GraphQL Issues Need To Fix: Before implementing the DataLoader into our sample we must aware of the issues we are facing. In GrphQL we have an option like Fragments Query. Fragments query is used to display the comparison results very effective way. Fragments Query: query{ Gadget1:GetByBrand(brand:"samsung"){ Id ProductName Brand } Gadget2:GetByBrand(brand:"red mi"){ Id ProductName Brand } } Here we request a GraphQL endpoint to serve the different gadgets for comparison this type of query called Fragments Query. Now this kind of Fragments Query produces issues like: We will face

Part-2 An Overview On GraphQL Implementation In .Net Application Using Hot Chocolate Library

Part-1  shown startup steps like initial configuration of Hot Chocolate GraphQL library into the .Net5 Web API application. This is a continuation part here we are going to understand a few concepts like fetching data from the database, GraphQL mutations, different GraphL queries, etc. Configure EntityFrameworkCore Database Context: Now we need to integrate our database into our GraphQL endpoint by creating an entity framework core database context. Package Manager Command: Install-Package Microsoft.EntityFrameworkCore -Version 5.0.1 .Net CLI Command: dotnet add package Micorsoft.EntityFrameworkCore -Version 5.0.1 Package Manager Command: Install-Package Microsoft.EntityFrameworkCore.SqlServer -Version 5.0.1 .Net CLI Command: dotnet add package Microsoft.EntityFrameworkCore.SqlServer -Version 5.0.1 Now add your connection string into the app settings file. appsettings.Development.json: "ConnectionStrings":{ "MyWorldDbConnection":"Your_database_Connectio

Part-1 An Overview On GraphQL Implementation In .Net Application Using Hot Chocolate Library

In this article, we are going to understand the implementation steps of GraphQL in .Net5 application using Hot Chocolate Library. GraphQL: GraphQL is an open-source data query and manipulation language for APIs. It is a query language for your API and a server-side runtime for executing queries by using a type system you define for your data. GraphQL can be integrated into any framework like .Net, Java, NetsJS, etc and it isn't tied to any specific database or storage engine and instead backed by your existing code and data. GraphQL caries two important operations: Query - fetching data Mutation - save or update. Hot Chocolate GraphQL: Hot Chocolate is an open-source GraphQL server that is compliant with the newest GraphQL latest specs. It is the wrapper library of the original .Net GraphQL library. Hot Chocolate takes the complexity away from building a fully-fledged GraphQL server. An Overview On GrphQL SDL(Schema Definition Language): A syntax to data query and manipulation

NestJS API Integration With GraphQL Using Code First Approach

What Is GraphQL?: GraphQL is a query language for your API and a server-side runtime for executing queries by using a schema type system you defined for your data. GraphQL is not tied to any specific programming language(like NestJS, Java, .NET, etc) or database or storage engine. How GraphQL Different From Rest API: GraphQL exposes a single endpoint. Http-Post is the only Http verb recommended by supported by GraphQL API. Client applications(consumers of GraphQL API) can give instructions to GraphQL API about the response data. Code First vs Schema Approach: Code First Approach: In Code First Approach we use Typescript class to which need to apply GraphQL decorator on top of classes and also on top of properties inside of the class. These decorators help to auto-generate the raw GraphQL Schema. So in Code First Approach we no need to learn or concentrate to write the GraphQL Schema. Schema First Approach: GraphQL SDL(schema definition language) is a new syntactic query type language,

NestJS API Integration With GraphQL Using Schema First Approach

What Is GraphQL?: GraphQL is a query language for your API and a server-side runtime for executing queries by using a schema type system you defined for your data. Graphql is not tied to any specific programming language(like NestJS, Java, .NET, etc) or database or storage engine. How GraphQL Different From Rest API: GraphQL exposes a single endpoint. HTTP-POST is the only Http verb recommended by GraphQL. Client applications(consumers of GraphQL API) can give instructions to GraphQL API about the response data. Schema vs Code First Approach: Schema First Approach - GraphQL SDL (Schema definition language) is a new syntax language, which is independent of any programming language and also integrates with any programming language. But while integrating with any programming language GraphQL Schema needs to be mapped with objects or classes or interface of the specific programming language to build communication between GraphQL Schema and programming language. In Nest