GraphQL.Conventions
7.0.0
See the version list below for details.
dotnet add package GraphQL.Conventions --version 7.0.0
NuGet\Install-Package GraphQL.Conventions -Version 7.0.0
<PackageReference Include="GraphQL.Conventions" Version="7.0.0" />
paket add GraphQL.Conventions --version 7.0.0
#r "nuget: GraphQL.Conventions, 7.0.0"
// Install GraphQL.Conventions as a Cake Addin #addin nuget:?package=GraphQL.Conventions&version=7.0.0 // Install GraphQL.Conventions as a Cake Tool #tool nuget:?package=GraphQL.Conventions&version=7.0.0
GraphQL Conventions Library for .NET
Introduction
GraphQL .NET has been around for a while. This library is a complementary layer on top that allows you to automatically wrap your .NET classes into GraphQL schema definitions using existing property getters and methods as field resolvers.
In short, this project builds on top of the following components:
- The GraphQL library written by Joe McBride (MIT licence)
- The GraphQL lexer/parser originally written by Marek Magdziak (MIT licence)
Disclaimer: I am providing code in this repository to you under an open source licence (MIT). Because this is my personal repository, the licence you receive to my code is from me and not my employer (Facebook).
Installation
Download and install the package from NuGet:
PS> Install-Package GraphQL.Conventions
This project targets .NET Standard 2.0.
Getting Started
Implement your query type:
[ImplementViewer(OperationType.Query)]
public class Query
{
[Description("Retrieve book by its globally unique ID.")]
public Task<Book> Book(UserContext context, Id id) =>
context.Get<Book>(id);
[Description("Retrieve author by his/her globally unique ID.")]
public Task<Author> Author(UserContext context, Id id) =>
context.Get<Author>(id);
[Description("Search for books and authors.")]
public Connection<SearchResult> Search(
UserContext context,
[Description("Title or last name.")] NonNull<string> forString,
[Description("Only return search results after given cursor.")] Cursor? after,
[Description("Return the first N results.")] int? first)
{
return context
.Search(forString.Value)
.Select(node => new SearchResult { Instance = node })
.ToConnection(first ?? 5, after);
}
}
Construct your schema and run your query:
using GraphQL.Conventions;
var engine = GraphQLEngine.New<Query>();
var result = await engine
.NewExecutor()
.WithUserContext(userContext)
.WithDependencyInjector(dependencyInjector)
.WithRequest(requestBody)
.Execute();
Examples
More detailed examples can be found in the unit tests.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. 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 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. |
-
.NETStandard 2.0
- GraphQL (>= 7.0.0)
- GraphQL.DataLoader (>= 7.0.0)
- GraphQL.NewtonsoftJson (>= 7.0.0)
- GraphQL.SystemReactive (>= 4.8.0)
- System.Reflection (>= 4.3.0)
- System.Reflection.Extensions (>= 4.3.0)
- System.Reflection.TypeExtensions (>= 4.7.0)
- System.Runtime (>= 4.3.1)
-
net6.0
- GraphQL (>= 7.0.0)
- GraphQL.DataLoader (>= 7.0.0)
- GraphQL.NewtonsoftJson (>= 7.0.0)
- GraphQL.SystemReactive (>= 4.8.0)
- System.Reflection (>= 4.3.0)
- System.Reflection.Extensions (>= 4.3.0)
- System.Reflection.TypeExtensions (>= 4.7.0)
- System.Runtime (>= 4.3.1)
NuGet packages (5)
Showing the top 5 NuGet packages that depend on GraphQL.Conventions:
Package | Downloads |
---|---|
GraphQL.Conventions.NodaTime
Very simple package that maps NodaTime's types to their graph type implementations provided by GraphQL.NodaTime. |
|
GraphQlRethinkDbLibrary
Framework to create web apps with GraphQL and RethinkDb |
|
Rekyl.io
Framework to create web apps with GraphQL and RethinkDb. Core library |
|
GraphQLDoorNet
Rely on GraphQL query, this library propose a solution to dynamic query fron client by linq |
|
GraphQlRethinkDbCore
Framework to create web apps with GraphQL and RethinkDb. Core library |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
8.0.0 | 2,067 | 8/24/2024 |
7.5.0 | 4,381 | 6/1/2024 |
7.4.0 | 4,433 | 1/11/2024 |
7.3.0 | 27,889 | 5/25/2023 |
7.2.0 | 26,975 | 12/20/2022 |
7.1.0 | 4,155 | 12/11/2022 |
7.0.0 | 16,287 | 11/11/2022 |
5.3.0 | 11,410 | 7/4/2022 |
4.3.0 | 50,796 | 12/15/2021 |
4.2.0 | 4,337 | 11/17/2021 |
4.1.0 | 216,863 | 4/27/2021 |
4.0.0 | 5,593 | 3/31/2021 |
3.3.2 | 43,031 | 3/2/2021 |
3.0.0 | 10,091 | 11/14/2020 |
2.5.5 | 6,021 | 10/28/2020 |
2.5.4 | 16,331 | 6/10/2020 |
2.5.3 | 11,661 | 2/29/2020 |
2.5.2 | 12,541 | 12/19/2019 |
2.5.1 | 13,184 | 12/14/2019 |
2.5.0 | 1,768 | 10/24/2019 |
2.4.0 | 2,916 | 10/17/2019 |
2.3.0 | 903 | 10/13/2019 |
2.2.0 | 799 | 10/13/2019 |
2.1.0 | 21,299 | 6/16/2019 |
2.0.4 | 10,262 | 3/12/2019 |
2.0.3 | 822 | 3/7/2019 |
2.0.2 | 972 | 3/3/2019 |
2.0.1 | 17,550 | 10/15/2018 |
2.0.0 | 37,023 | 10/8/2018 |
1.4.0 | 4,339 | 4/21/2018 |
1.3.9 | 15,022 | 10/26/2017 |
1.3.8 | 1,145 | 10/24/2017 |
1.3.7 | 2,130 | 10/24/2017 |
1.3.6 | 8,696 | 8/22/2017 |
1.3.5 | 1,308 | 8/22/2017 |
1.3.4 | 1,121 | 8/20/2017 |
1.3.3 | 1,117 | 8/18/2017 |
1.3.2 | 1,116 | 8/17/2017 |
1.3.1 | 1,130 | 8/17/2017 |
1.3.0 | 1,091 | 8/16/2017 |
1.2.16 | 1,076 | 8/16/2017 |
1.2.15 | 1,055 | 8/16/2017 |
1.2.14 | 1,098 | 8/16/2017 |
1.2.13 | 1,727 | 8/1/2017 |
1.2.12 | 1,144 | 7/26/2017 |
1.2.11 | 1,112 | 7/26/2017 |
1.2.10 | 1,579 | 6/30/2017 |
1.2.9 | 1,107 | 6/30/2017 |
1.2.8 | 1,165 | 6/20/2017 |
1.2.7 | 2,428 | 5/11/2017 |
1.2.6 | 1,254 | 5/10/2017 |
1.2.5 | 1,219 | 5/4/2017 |
1.2.4 | 1,281 | 4/22/2017 |
1.2.3 | 1,116 | 4/20/2017 |
1.2.2 | 1,175 | 3/28/2017 |
1.2.1 | 1,123 | 3/27/2017 |
1.2.0 | 2,141 | 3/13/2017 |
1.1.10 | 1,104 | 3/12/2017 |
1.1.9 | 1,113 | 3/12/2017 |
1.1.8 | 1,191 | 3/1/2017 |
1.1.7 | 1,118 | 3/1/2017 |
1.1.6 | 1,216 | 2/21/2017 |
1.1.5 | 1,169 | 2/20/2017 |
1.1.4 | 1,101 | 2/20/2017 |
1.1.3 | 1,105 | 2/17/2017 |
1.1.2 | 1,131 | 2/16/2017 |
1.1.1 | 1,093 | 2/15/2017 |
1.1.0 | 1,147 | 2/10/2017 |
1.0.9 | 1,136 | 1/30/2017 |
1.0.8 | 1,106 | 1/19/2017 |
1.0.7 | 1,135 | 1/16/2017 |
1.0.6 | 1,195 | 11/25/2016 |
1.0.5 | 1,166 | 11/25/2016 |