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0 |
4.8.0 | 0 | 0 | 0 | 0 | 0 |
4.7.1 | 0 | 0 | 0 | 0 | 0 |
4.7.0 | 0 | 0 | 0 | 0 | 0 |
4.6.1 | 0 | 0 | 0 | 0 | 0 |
4.6.0 | 0 | 0 | 0 | 0 | 0 |
4.5.0 | 0 | 0 | 0 | 0 | 0 |
4.4.0 | 0 | 0 | 0 | 0 | 0 |
4.3.0 | 0 | 0 | 0 | 0 | 0 |
4.2.0 | 0 | 0 | 0 | 0 | 0 |
4.1.0 | 0 | 0 | 0 | 0 | 0 |
4.0.2 | 0 | 0 | 0 | 0 | 0 |
4.0.1 | 0 | 0 | 0 | 0 | 0 |
4.0.0 | 0 | 0 | 0 | 0 | 0 |
8.2.1 - This version is safe to use because it has no known security vulnerabilities at this time. Find out if your coding project uses this component and get notified of any reported security vulnerabilities with Meterian-X Open Source Security Platform
Maintain your licence declarations and avoid unwanted licences to protect your IP the way you intended.
MIT - MIT License❤️ Become a backer! ❤️ |
---|
💲 Get paid for contributing! 💲 |
---|
This is an implementation of GraphQL, a query language and execution engine originally created by Facebook in 2012, in .NET.
The GraphQL specification is now being developed and maintained by the GraphQL Foundation, established in 2019 to support the GraphQL ecosystem. You can also find the specification's source and discussions on GitHub at graphql/graphql-spec.
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.
Project/Route | Description |
---|---|
GraphQL.Net/Samples | Sample projects focused on showcasing features of the core GraphQL library, an implementation of the GraphQL specification. |
GraphQL.Net.Server/Samples | Sample projects highlighting features of the server package, including utilities for integrating a GraphQL server with .NET Web APIs. |
Examples/Src | Community-provided examples. These may not represent officially supported patterns but show how others use the library. |
GraphQL.Net.Client/Examples | Example implementations for the GraphQL client library. |
master
branch.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.
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
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.
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.
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.
DocumentExecuter
can handle subscriptions as well as queries and mutations.
For more information see Subscriptions.
To easily configure GraphQL.NET with the Microsoft dependency injection provider,
you can use the GraphQL.MicrosoftDI
package. This package provides a AddGraphQL
extension method to register the necessary services. This package can also be used with
other dependency injection providers that support the Microsoft.Extensions.DependencyInjection
abstraction such as Autofac, Castle Windsor, and StructureMap.
> dotnet add package GraphQL.MicrosoftDI
You can then configure GraphQL.NET in your Startup.cs
file like this:
public void ConfigureServices(IServiceCollection services)
{
services.AddGraphQL(b => b
.AddSchema<MySchema>()
.AddSystemTextJson()
.AddDataLoader()
);
}
For more information see Dependency Injection.
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:
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).
You can see the changes in public APIs using fuget.org.
Define your schema with a top level query object then execute that query.
Fully-featured examples can be found here.
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);
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 } }";
});
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 }} }}";
});
GraphQL.NET supports introspection schema from October 2021 spec with some additional experimental introspection extensions.
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.
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.
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. Become a sponsor.