在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):graphql-dotnet/graphql-dotnet开源软件地址(OpenSource Url):https://github.com/graphql-dotnet/graphql-dotnet开源编程语言(OpenSource Language):C# 99.0%开源软件介绍(OpenSource Introduction):GraphQL for .NETThis 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:
You can get all preview versions from GitHub Packages. Note that GitHub requires authentication to consume the feed. See here. Documentation
DebuggingAll 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. Installation1. GraphQL.NET engineThis is the main package, the heart of the repository in which you can find all the necessary classes for GraphQL request processing.
2. SerializationFor serialized results, you'll need an
3. Document CachingFor caching of parsed GraphQL documents you'll need an
For more information see Document Caching. 4. DataLoaderDataLoader 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.
For more information see DataLoader.
5. Subscriptions
6. Advanced Dependency InjectionAlso we provide some extra classes for advanced dependency injection usage on top of
For more information see Thread safety with scoped services. Exampleshttps://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
Upgrade GuidesYou can see the changes in public APIs using fuget.org. Basic UsageDefine your schema with a top level query object then execute that query. Fully-featured examples can be found here. Hello Worldusing 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 ApproachThis 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 } }";
}); Parameterspublic 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 }} }}";
}); RoadmapGrammar / AST
Operation Execution
Validation
Schema IntrospectionGraphQL.NET supports introspection schema from October 2021 spec with some additional experimental introspection extensions. Publishing NuGet packagesThe package publishing process is automated with GitHub Actions. After your PR is merged into Stable versions of packages are published to NuGet when a release is created. ContributorsThis 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 BackersThank you to all our backers! |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论