Skip to main content

Posts

Showing posts with the label GraphQL

Dotnet Core GraphQL API Authorization

Introduction: GraphQL API Authorization can be done by implementing GraphQL.Validation.IValidationRule . By implementing IValidationRule we have to implement our own custom rules for validating queries. So we can implement our own custom logic for authorization. IValidationRule is the perfect way of implementing authorization because these rules always get executed prior to the query execution. Here we are going to implement a sample of GraphQL API protecting it by creating claims-based authorization. To know more about  GrapQL API Integration In Asp.Net Core Application Click Here. Identity Server4 Token Based Authentication: In this sample, we are going to use token-based authentication by IdentityServer 4. If you want you can use any other authentication type like cookie authentication or OAuth2.0 or Microsoft Login Identity.  Click here for Identity Server4 Sample Source Code . Dotnet Core Web API Verify IdentityServer4 Authentication Token: Let's create a Do

GraphQL API Integration In Asp.Net Core Application

Introduction: GraphQL 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 ASP.NET, Java, NestJs, etc and it isn't tied to any specific database or storage engine and is instead backed by your existing code and data. How GraphQL API Different From Rest API: GraphQL exposes a single end-point or route for the entire application, regardless of its responses or actions. HTTP-POST is the only Http verb recommended by the GraphQL. The client applications (consumers of API) can give instructions to GraphQL API about what type of properties to be returned in the response. Building Blocks Of GraphQL API: The main building blocks of GraphQL API is Schemas and Types.  A 'Schema' in GrpahQL API describes the functionality available to the clients connect to API. Schema mostly consists of GraphQL Object Types, Queries, Mutations, etc. T