GraphQL.SystemTextJson
7.2.2
See the version list below for details.
dotnet add package GraphQL.SystemTextJson --version 7.2.2
NuGet\Install-Package GraphQL.SystemTextJson -Version 7.2.2
<PackageReference Include="GraphQL.SystemTextJson" Version="7.2.2" />
paket add GraphQL.SystemTextJson --version 7.2.2
#r "nuget: GraphQL.SystemTextJson, 7.2.2"
// Install GraphQL.SystemTextJson as a Cake Addin #addin nuget:?package=GraphQL.SystemTextJson&version=7.2.2 // Install GraphQL.SystemTextJson as a Cake Tool #tool nuget:?package=GraphQL.SystemTextJson&version=7.2.2
GraphQL for .NET
❤️ Become a backer! ❤️ |
---|
💲 Get paid for contributing! 💲 |
---|
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 | ||
GraphQL.SystemTextJson | ||
GraphQL.NewtonsoftJson | ||
GraphQL.MemoryCache | ||
GraphQL.DataLoader | ||
GraphQL.MicrosoftDI |
You can get all preview versions from GitHub Packages. Note that GitHub requires authentication to consume the feed. See here.
Documentation
- http://graphql-dotnet.github.io - documentation site that is built from the docs folder in the
master
branch. - https://graphql.org/learn - learn about GraphQL, how it works, and how to use it.
Debugging
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.
Installation
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.0HttpResponse.Body
will require you to setAllowSynchronousIO
totrue
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.
Examples
https://github.com/graphql-dotnet/examples
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:
Training
- API Development in .NET with GraphQL - Glenn Block demonstrates how to use the GraphQL.NET framework to build a fully functional GraphQL endpoint.
- Building GraphQL APIs with ASP.NET Core by Roland Guijt
Upgrade Guides
You can see the changes in public APIs using fuget.org.
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;
});
Console.WriteLine(json);
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
{
[GraphQLMetadata("droid")]
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
}
", _ => {
_.Types.Include<Query>();
});
var json = await schema.ExecuteAsync(_ =>
{
_.Query = "{ droid { id name } }";
});
Parameters
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" }
};
[GraphQLMetadata("droid")]
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
}
", _ => {
_.Types.Include<Query>();
});
var json = await schema.ExecuteAsync(_ =>
{
_.Query = $"{{ droid(id: \"123\") {{ id name }} }}";
});
Roadmap
Grammar / AST
- Grammar and AST for the GraphQL language should be compatible with the October 2021 specification.
Operation Execution
- Scalars
- Objects
- Lists of objects/interfaces
- Interfaces
- Unions
- Arguments
- Variables
- Fragments
- Directives
- Include
- Skip
- Custom
- Enumerations
- Input Objects
- Mutations
- Subscriptions
- Async execution
Validation
- 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.
Contributors
This project exists thanks to all the people who contribute. <a href="https://github.com/graphql-dotnet/graphql-dotnet/graphs/contributors"><img src="https://opencollective.com/graphql-net/contributors.svg?width=890&button=false" /></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.
Backers
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="https://opencollective.com/graphql-net#backers" target="_blank"><img src="https://opencollective.com/graphql-net/backers.svg?width=890"></a>
Sponsors
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. Become a sponsor.
<a href="https://opencollective.com/graphql-net/sponsor/0/website" target="_blank"><img src="https://opencollective.com/graphql-net/sponsor/0/avatar.svg"></a> <a href="https://opencollective.com/graphql-net/sponsor/1/website" target="_blank"><img src="https://opencollective.com/graphql-net/sponsor/1/avatar.svg"></a> <a href="https://opencollective.com/graphql-net/sponsor/2/website" target="_blank"><img src="https://opencollective.com/graphql-net/sponsor/2/avatar.svg"></a> <a href="https://opencollective.com/graphql-net/sponsor/3/website" target="_blank"><img src="https://opencollective.com/graphql-net/sponsor/3/avatar.svg"></a> <a href="https://opencollective.com/graphql-net/sponsor/4/website" target="_blank"><img src="https://opencollective.com/graphql-net/sponsor/4/avatar.svg"></a> <a href="https://opencollective.com/graphql-net/sponsor/5/website" target="_blank"><img src="https://opencollective.com/graphql-net/sponsor/5/avatar.svg"></a> <a href="https://opencollective.com/graphql-net/sponsor/6/website" target="_blank"><img src="https://opencollective.com/graphql-net/sponsor/6/avatar.svg"></a> <a href="https://opencollective.com/graphql-net/sponsor/7/website" target="_blank"><img src="https://opencollective.com/graphql-net/sponsor/7/avatar.svg"></a> <a href="https://opencollective.com/graphql-net/sponsor/8/website" target="_blank"><img src="https://opencollective.com/graphql-net/sponsor/8/avatar.svg"></a> <a href="https://opencollective.com/graphql-net/sponsor/9/website" target="_blank"><img src="https://opencollective.com/graphql-net/sponsor/9/avatar.svg"></a>
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. 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 is compatible. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.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. |
-
.NETCoreApp 3.1
- GraphQL (>= 7.2.2 && < 8.0.0)
-
.NETStandard 2.0
- GraphQL (>= 7.2.2 && < 8.0.0)
- System.Text.Json (>= 4.7.2)
-
.NETStandard 2.1
- GraphQL (>= 7.2.2 && < 8.0.0)
- System.Text.Json (>= 4.7.2)
-
net5.0
- GraphQL (>= 7.2.2 && < 8.0.0)
-
net6.0
- GraphQL (>= 7.2.2 && < 8.0.0)
NuGet packages (25)
Showing the top 5 NuGet packages that depend on GraphQL.SystemTextJson:
Package | Downloads |
---|---|
GraphQL.Server.Transports.AspNetCore
HTTP middleware for GraphQL |
|
GraphQL.Server.Transports.AspNetCore.SystemTextJson
GraphQL middleware using System.Text.Json for serialization |
|
Shesha.GraphQL
Package Description |
|
OrchardCore.Apis.GraphQL
Orchard Core Framework is an application framework for building modular, multi-tenant applications on ASP.NET Core. Provies apis using the GraphQL Specification. |
|
Libplanet.Explorer
Package Description |
GitHub repositories (12)
Showing the top 5 popular GitHub repositories that depend on GraphQL.SystemTextJson:
Repository | Stars |
---|---|
OrchardCMS/OrchardCore
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.
|
|
Squidex/squidex
Headless CMS and Content Managment Hub
|
|
graphql-dotnet/graphql-client
A GraphQL Client for .NET Standard
|
|
getsentry/sentry-dotnet
Sentry SDK for .NET
|
|
graphql-dotnet/server
ASP.NET Core GraphQL Server
|
Version | Downloads | Last updated |
---|---|---|
8.2.1 | 24,797 | 10/24/2024 |
8.2.0 | 4,459 | 10/20/2024 |
8.1.0 | 25,161 | 9/18/2024 |
8.0.2 | 43,726 | 8/26/2024 |
8.0.1 | 2,439 | 8/23/2024 |
8.0.0 | 6,317 | 8/20/2024 |
7.9.0 | 24,475 | 8/18/2024 |
7.8.0 | 300,149 | 2/6/2024 |
7.7.2 | 84,116 | 12/16/2023 |
7.7.1 | 2,394 | 12/13/2023 |
7.7.0 | 295 | 12/13/2023 |
7.6.1 | 101,881 | 8/11/2023 |
7.6.0 | 429,759 | 7/31/2023 |
7.5.0 | 213,085 | 6/17/2023 |
7.4.1 | 58,803 | 4/21/2023 |
7.4.0 | 92,476 | 4/14/2023 |
7.3.1 | 33,581 | 4/2/2023 |
7.3.0 | 143,442 | 2/27/2023 |
7.2.2 | 116,946 | 1/2/2023 |
7.2.1 | 38,516 | 12/8/2022 |
7.2.0 | 47,870 | 12/3/2022 |
7.1.1 | 374,083 | 9/19/2022 |
7.1.0 | 3,379 | 9/16/2022 |
7.0.2 | 135,393 | 8/23/2022 |
7.0.1 | 3,075 | 8/17/2022 |
7.0.0 | 354,285 | 8/16/2022 |
5.4.0 | 97,575 | 11/30/2022 |
5.3.3 | 281,300 | 7/19/2022 |
5.3.2 | 154,881 | 7/3/2022 |
5.3.1 | 5,616 | 6/26/2022 |
5.3.0 | 1,198,433 | 5/14/2022 |
5.2.0 | 32,396 | 5/6/2022 |
5.1.1 | 553,911 | 4/11/2022 |
5.1.0 | 1,301 | 4/8/2022 |
5.0.0 | 2,643 | 3/30/2022 |
4.8.0 | 289,607 | 3/30/2022 |
4.7.1 | 447,648 | 1/1/2022 |
4.7.0 | 53,135 | 12/27/2021 |
4.6.1 | 799,531 | 9/29/2021 |
4.6.0 | 171,530 | 8/18/2021 |
4.5.0 | 163,741 | 4/29/2021 |
4.4.0 | 15,327 | 4/22/2021 |
4.3.0 | 9,708 | 4/16/2021 |
4.2.0 | 230,695 | 3/30/2021 |
4.1.0 | 926,932 | 3/26/2021 |
4.0.2 | 125,905 | 3/19/2021 |
4.0.1 | 757 | 3/17/2021 |
4.0.0 | 595 | 3/17/2021 |
3.3.2 | 221,313 | 1/24/2021 |
3.3.1 | 5,914 | 1/14/2021 |
3.3.0 | 616 | 1/14/2021 |
3.2.0 | 352,472 | 12/7/2020 |
3.1.6 | 2,560 | 12/1/2020 |
3.1.5 | 9,082 | 11/20/2020 |
3.1.4 | 6,614 | 11/15/2020 |
3.1.3 | 187,237 | 10/30/2020 |
3.1.2 | 83,980 | 10/28/2020 |
3.1.1 | 1,270 | 10/27/2020 |
3.1.0 | 8,273 | 10/23/2020 |
3.0.0.2026 | 233,537 | 9/17/2020 |
3.0.0 | 102,193 | 9/2/2020 |
3.0.0-preview-1719 | 10,749 | 8/17/2020 |
3.0.0-preview-1648 | 17,682 | 5/5/2020 |
3.0.0-preview-1490 | 119,506 | 2/19/2020 |