GraphQL.DataLoader 7.8.0

dotnet add package GraphQL.DataLoader --version 7.8.0                
NuGet\Install-Package GraphQL.DataLoader -Version 7.8.0                
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="GraphQL.DataLoader" Version="7.8.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add GraphQL.DataLoader --version 7.8.0                
#r "nuget: GraphQL.DataLoader, 7.8.0"                
#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.
// Install GraphQL.DataLoader as a Cake Addin
#addin nuget:?package=GraphQL.DataLoader&version=7.8.0

// Install GraphQL.DataLoader as a Cake Tool
#tool nuget:?package=GraphQL.DataLoader&version=7.8.0                

GraphQL for .NET

License codecov Nuget Nuget GitHub Release Date GitHub commits since latest release (by date) Size

GitHub contributors Activity Activity Activity

❤️ Become a backer! ❤️ Backers on Open Collective Sponsors on Open Collective
💲 Get paid for contributing! 💲 GitHub issues by-label GitHub closed issues by-label

This is an implementation of Facebook's GraphQL in .NET.

Now the specification is being developed by the GraphQL Foundation.

This project uses a lexer/parser originally written by Marek Magdziak and released with a MIT license. Thank you Marek!

Provides the following packages:

Package Downloads NuGet Latest
GraphQL Nuget Nuget
GraphQL.SystemTextJson Nuget Nuget
GraphQL.NewtonsoftJson Nuget Nuget
GraphQL.MemoryCache Nuget Nuget
GraphQL.DataLoader Nuget Nuget
GraphQL.MicrosoftDI Nuget Nuget

You can get all preview versions from GitHub Packages. Note that GitHub requires authentication to consume the feed. See here.


  1. - documentation site that is built from the docs folder in the master branch.
  2. - learn about GraphQL, how it works, and how to use it.


All packages generated from this repository come with embedded pdb and support Source Link. If you are having difficulty understanding how the code works or have encountered an error, then it is just enough to enable Source Link in your IDE settings. Then you can debug GraphQL.NET source code as if it were part of your project.


1. GraphQL.NET engine

This is the main package, the heart of the repository in which you can find all the necessary classes for GraphQL request processing.

> dotnet add package GraphQL
2. Serialization

For serialized results, you'll need an IGraphQLSerializer implementation. We provide several serializers (or you can bring your own).

> dotnet add package GraphQL.SystemTextJson
> dotnet add package GraphQL.NewtonsoftJson

Note: You can use GraphQL.NewtonsoftJson with .NET Core 3+, just be aware it lacks async writing capabilities so writing to an ASP.NET Core 3.0 HttpResponse.Body will require you to set AllowSynchronousIO to true as per this announcement; which isn't recommended.

3. Document Caching

The recommended way to setup caching layer (for caching of parsed GraphQL documents) is to inherit from IConfigureExecution interface and register your class as its implementation. We provide in-memory implementation on top of Microsoft.Extensions.Caching.Memory package.

> dotnet add package GraphQL.MemoryCache

For more information see Document Caching.

4. DataLoader

DataLoader is a generic utility to be used as part of your application's data fetching layer to provide a simplified and consistent API over various remote data sources such as databases or web services via batching and caching.

> dotnet add package GraphQL.DataLoader

For more information see DataLoader.

Note: Prior to version 4, the contents of this package was part of the main GraphQL.NET package.

5. Subscriptions

DocumentExecuter can handle subscriptions as well as queries and mutations. For more information see Subscriptions.

6. Advanced Dependency Injection

Also we provide some extra classes for advanced dependency injection usage on top of Microsoft.Extensions.DependencyInjection.Abstractions package.

> dotnet add package GraphQL.MicrosoftDI

For more information see Thread safety with scoped services.


You can also try an example of GraphQL demo server inside this repo - GraphQL.Harness. It supports the popular IDEs for managing GraphQL requests and exploring GraphQL schema:

Ahead-of-time compilation

GraphQL.NET supports ahead-of-time (AOT) compilation for execution of code-first schemas with .NET 7. This allows for use within iOS and Android apps, as well as other environments where such features as JIT compilation or dynamic code generation are not available. It may be necessary to explicitly instruct the AOT compiler to include the .NET types necessary for your schema to operate correctly. Of particular note, your query, mutation and subscription types' constructors may be trimmed; register them in your DI engine to prevent this. Also, Field(x => x.MyField) for enumeration values will require manually adding a mapping reference via RegisterTypeMapping<MyEnum, EnumerationGraphType<MyEnum>>(). Please see the GraphQL.AotCompilationSample for a simple demonstration of AOT compilation. Schema-first and type-first schemas have additional limtations and configuration requirements. AOT compilation has not been tested with frameworks other than .NET 7 on Windows and Linux (e.g. Xamarin).


Upgrade Guides

You can see the changes in public APIs using

Basic Usage

Define your schema with a top level query object then execute that query.

Fully-featured examples can be found here.

Hello World

using System;
using System.Threading.Tasks;
using GraphQL;
using GraphQL.Types;
using GraphQL.SystemTextJson; // First add PackageReference to GraphQL.SystemTextJson

var schema = Schema.For(@"
  type Query {
    hello: String

var root = new { Hello = "Hello World!" };
var json = await schema.ExecuteAsync(_ =>
  _.Query = "{ hello }";
  _.Root = root;


Schema First Approach

This example uses the GraphQL schema language. See the documentation for more examples and information.

public class Droid
  public string Id { get; set; }
  public string Name { get; set; }

public class Query
  public Droid GetDroid()
    return new Droid { Id = "123", Name = "R2-D2" };

var schema = Schema.For(@"
  type Droid {
    id: ID
    name: String

  type Query {
    droid: Droid
", _ => {

var json = await schema.ExecuteAsync(_ =>
  _.Query = "{ droid { id name } }";


public class Droid
  public string Id { get; set; }
  public string Name { get; set; }

public class Query
  private List<Droid> _droids = new List<Droid>
    new Droid { Id = "123", Name = "R2-D2" }

  public Droid GetDroid(string id)
    return _droids.FirstOrDefault(x => x.Id == id);

var schema = Schema.For(@"
  type Droid {
    id: ID
    name: String

  type Query {
    droid(id: ID): Droid
", _ => {

var json = await schema.ExecuteAsync(_ =>
  _.Query = $"{{ droid(id: \"123\") {{ id name }} }}";


Grammar / AST

Operation Execution

  • Scalars
  • Objects
  • Lists of objects/interfaces
  • Interfaces
  • Unions
  • Arguments
  • Variables
  • Fragments
  • Directives
    • Include
    • Skip
    • Custom
  • Enumerations
  • Input Objects
  • Mutations
  • Subscriptions
  • Async execution


  • Arguments of correct type
  • Default values of correct type
  • Fields on correct type
  • Fragments on composite types
  • Known argument names
  • Known directives
  • Known fragment names
  • Known type names
  • Lone anonymous operations
  • No fragment cycles
  • No undefined variables
  • No unused fragments
  • No unused variables
  • Overlapping fields can be merged
  • Possible fragment spreads
  • Provide non-null arguments
  • Scalar leafs
  • Unique argument names
  • Unique directives per location
  • Unique fragment names
  • Unique input field names
  • Unique operation names
  • Unique variable names
  • Variables are input types
  • Variables in allowed position
  • Single root field

Schema Introspection

GraphQL.NET supports introspection schema from October 2021 spec with some additional experimental introspection extensions.

Publishing NuGet packages

The package publishing process is automated with GitHub Actions.

After your PR is merged into master or develop, preview packages are published to GitHub Packages.

Stable versions of packages are published to NuGet when a release is created.


This project exists thanks to all the people who contribute. <a href=""><img src="" /></a>

PRs are welcome! Looking for something to work on? The list of open issues is a great place to start. You can help the project simply respond to some of the asked questions.

The default branch is master. It is designed for non-breaking changes, that is to publish versions 7.x.x. If you have a PR with some breaking changes, then please target it to the develop branch that tracks changes for v8.0.0.


Thank you to all our backers! 🙏 Become a backer.

Contributions are very much appreciated and are used to support the project primarily via bounties paid directly to contributors to the project. Please help us to express gratitude to those individuals who devote time and energy to contributing to this project by supporting their efforts in a tangible means. A list of the outstanding issues to which we are sponsoring via bounties can be found here.

<a href="" target="_blank"><img src=""></a>


Support this project by becoming a sponsor. Your logo will show up here with a link to your website. Become a sponsor.

<a href="" target="_blank"><img src=""></a> <a href="" target="_blank"><img src=""></a> <a href="" target="_blank"><img src=""></a> <a href="" target="_blank"><img src=""></a> <a href="" target="_blank"><img src=""></a> <a href="" target="_blank"><img src=""></a> <a href="" target="_blank"><img src=""></a> <a href="" target="_blank"><img src=""></a> <a href="" target="_blank"><img src=""></a> <a href="" target="_blank"><img src=""></a>

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

NuGet packages (17)

Showing the top 5 NuGet packages that depend on GraphQL.DataLoader:

Package Downloads

GraphQL Server Core


GraphQL Server meta package with all the packages you need to get started


Orchard Core Framework is an application framework for building modular, multi-tenant applications on ASP.NET Core. Abstractions for GraphQL Apis


Package Description


GraphQL Conventions for .NET

GitHub repositories (4)

Showing the top 4 popular GitHub repositories that depend on GraphQL.DataLoader:

Repository Stars
Orchard Core is an open-source modular and multi-tenant application framework built with ASP.NET Core, and a content management system (CMS) built on top of that framework.
Headless CMS and Content Managment Hub
ASP.NET Core GraphQL Server
GraphQL Conventions Library for .NET
Version Downloads Last updated
7.8.0 120,301 2/6/2024
7.7.2 40,545 12/16/2023
7.7.1 3,335 12/13/2023
7.7.0 454 12/13/2023
7.6.1 75,223 8/11/2023
7.6.0 52,161 7/31/2023
7.5.0 63,038 6/17/2023
7.4.1 51,917 4/21/2023
7.4.0 34,765 4/14/2023
7.3.1 15,115 4/2/2023
7.3.0 75,217 2/27/2023
7.2.2 48,504 1/2/2023
7.2.1 14,490 12/8/2022
7.2.0 33,520 12/3/2022
7.1.1 211,319 9/19/2022
7.1.0 2,316 9/16/2022
7.0.2 91,569 8/23/2022
7.0.1 2,654 8/17/2022
7.0.0 273,823 8/16/2022
5.4.0 84,697 11/30/2022
5.3.3 262,899 7/19/2022
5.3.2 151,101 7/3/2022
5.3.1 2,444 6/26/2022
5.3.0 45,593 5/14/2022
5.2.0 32,418 5/6/2022
5.1.1 6,640 4/11/2022
5.1.0 1,883 4/8/2022
5.0.0 2,417 3/30/2022
4.8.0 320,541 3/30/2022
4.7.1 267,506 1/1/2022
4.7.0 6,327 12/27/2021
4.6.1 782,118 9/29/2021
4.6.0 340,612 8/18/2021
4.5.0 162,915 4/29/2021
4.4.0 2,848 4/22/2021
4.3.0 9,835 4/16/2021
4.2.0 19,937 3/30/2021
4.1.0 1,822,720 3/26/2021
4.0.2 107,433 3/19/2021
4.0.1 1,071 3/17/2021
4.0.0 3,665 3/17/2021