Prakrishtha.GraphqlHttpClient 1.0.1

dotnet add package Prakrishtha.GraphqlHttpClient --version 1.0.1
                    
NuGet\Install-Package Prakrishtha.GraphqlHttpClient -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Prakrishtha.GraphqlHttpClient" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Prakrishtha.GraphqlHttpClient" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Prakrishtha.GraphqlHttpClient" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Prakrishtha.GraphqlHttpClient --version 1.0.1
                    
#r "nuget: Prakrishtha.GraphqlHttpClient, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Prakrishtha.GraphqlHttpClient@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Prakrishtha.GraphqlHttpClient&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Prakrishtha.GraphqlHttpClient&version=1.0.1
                    
Install as a Cake Tool

GraphqlHttpClient

Very simple Graphql http client for .net by taking advantage of IHttpClientFactory from latest version of .net core and standard

Build Status:

Build status

Nuget package installation:

Install-Package Prakrishtha.GraphqlHttpClient -Version 1.0.0

The response object has Data, status code, response time, error message (if any) properties which will be helpful when you interpret the result.

public interface IGraphqlResponse<TEntity> where TEntity : class
{
        /// <summary>
        /// Gets or sets graphql response data
        /// </summary>
        TEntity Data { get; set; }

        /// <summary>
        /// Gets or sets the error occured on execution of the query
        /// </summary>
        IEnumerable<GraphqlError> Errors { get; set; }

        /// <summary>
        /// Gets has data flag, returns true if the response has data
        /// </summary>
        bool HasData { get; }

        /// <summary>
        /// Gets has error flag, returns true if the response has any error
        /// </summary>
        bool HasError { get; }

        /// <summary>
        /// Gets status code flag, returns true if the http status code between 200 and 300
        /// </summary>
        bool IsSuccessCode { get; }

        /// <summary>
        /// Gets or sets the http status code
        /// </summary>
        HttpStatusCode StatusCode { get; set; }

        /// <summary>
        /// Gets or sets the time taken by operation in milli seconds
        /// </summary>
        long ElapsedTime { get; set; }
}

There is an extension method available to add Graphql client with inbuilt IoC container.

services.AddGraphqlHttpClient();

If you want to set base url and time out at the time of configuration, it can be achieved with the below code.

services.AddGraphqlHttpClient(new Uri("https://github.com"), new TimeSpan(0,0,20));
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 88 1/25/2026
1.0.0 1,534 1/22/2019